1var ASPx = ASPx || {}; 2var dx = dx || {}; 3(function module(ASPx, dx) { 4ASPx.modules = { Utils: module }; 5if(!ASPx.attachToReady) 6 ASPx.attachToReady = function (callback) { ASPx.Evt.AttachEventToElement(window, "load", callback); }; 7if(!ASPx.attachToLoad) 8 ASPx.attachToLoad = function(callback) { ASPx.Evt.AttachEventToDocumentCore("DOMContentLoaded", callback); }; 9ASPx.EmptyObject = { }; 10ASPx.FalseFunction = function() { return false; }; 11ASPx.SSLSecureBlankUrl = '/DXR.axd?r=1_88-0LvHk'; 12ASPx.EmptyImageUrl = '/DXR.axd?r=1_89-0LvHk'; 13ASPx.VersionInfo = 'Version=\'20.1.3.0\', File Version=\'20.1.3.0\', Date Modified=\'5/1/2020 10:07:21 AM\''; 14ASPx.Platform = 'ASP'; 15ASPx.DoctypeMode = 'Html5'; 16ASPx.InvalidDimension = -10000; 17ASPx.InvalidPosition = -10000; 18ASPx.AbsoluteLeftPosition = -10000; 19ASPx.EmptyGuid = "00000000-0000-0000-0000-000000000000"; 20ASPx.CallbackSeparator = ":"; 21ASPx.ItemIndexSeparator = "i"; 22ASPx.CallbackResultPrefix = "/*DX*/"; 23ASPx.StyleValueEncodedSemicolon = "DXsmcln"; 24ASPx.AccessibilityEmptyUrl = "javascript:;"; 25ASPx.AccessibilityPronounceTimeout = 500; 26ASPx.MaxMobileWindowWidth = 576; 27ASPx.PossibleNumberDecimalSeparators = [",", "."]; 28ASPx.CultureInfo = { 29 twoDigitYearMax: 2029, 30 ts: ":", 31 ds: "/", 32 am: "AM", 33 pm: "PM", 34 monthNames: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "
34November", "December", ""], 35 genMonthNames: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December", ""], 36 abbrMonthNames: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", ""], 37 abbrDayNames: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], 38 dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], 39 invariantCultureDecimalPoint: ".", 40 numDecimalPoint: ".", 41 numPrec: 2, 42 numGroupSeparator: ",", 43 numGroups: [ 3 ], 44 numNegPattern: 1, 45 numPosInf: "Infinity", 46 numNegInf: "-Infinity", 47 numNan: "NaN", 48 currency: "$", 49 currDecimalPoint: ".", 50 currPrec: 2, 51 currGroupSeparator: ",", 52 currGroups: [ 3 ], 53 currPosPattern: 0, 54 currNegPattern: 0, 55 percentPattern: 0, 56 shortTime: "h:mm tt", 57 longTime: "h:mm:ss tt", 58 shortDate: "M/d/yyyy", 59 longDate: "dddd, MMMM d, yyyy", 60 monthDay: "MMMM d", 61 yearMonth: "MMMM yyyy" 62}; 63ASPx.CultureInfo.genMonthNames = ASPx.CultureInfo.monthNames; 64ASPx.Position = { 65 Left: "Left", 66 Right: "Right", 67 Top: "Top", 68 Bottom: "Bottom" 69};
70function setInnerHtmlInternal(el, trustedHtmlString) { 71 el.innerHTML = trustedHtmlString; 72} 73var DateUtils = { }; 74DateUtils.GetInvariantDateString = function(date) { 75 if(!date) 76 return "01/01/0001"; 77 var day = date.getDate(); 78 var month = date.getMonth() + 1; 79 var year = date.getFullYear(); 80 var result = ""; 81 if(month < 10) 82 result += "0"; 83 result += month.toString() + "/"; 84 if(day < 10) 85 result += "0"; 86 result += day.toString() + "/"; 87 if(year < 1000) 88 result += "0"; 89 result += year.toString(); 90 return result; 91}; 92DateUtils.GetInvariantDateTimeString = function(date) { 93 var dateTimeString = DateUtils.GetInvariantDateString(date); 94 var time = { 95 h: date.getHours(), 96 m: date.getMinutes(), 97 s: date.getSeconds() 98 }; 99 for(var key in time) { 100 if(time.hasOwnProperty(key)) { 101 var str = time[key].toString(); 102 if(str.length < 2) 103 str = "0" + str; 104 time[key] = str; 105 } 106 } 107 dateTimeString += " " + time.h + ":" + time.m + ":" + time.s; 108 var msec = date.getMilliseconds(); 109 if(msec > 0) 110 dateTimeString += "." + ("000" + msec.toString()).substr(-3); 111 return dateTimeString; 112}; 113DateUtils.ExpandTwoDigitYear = function(value) { 114 value += 1900; 115 if(value + 99 < ASPx.CultureInfo.twoDigitYearMax) 116 value += 100; 117 return value; 118}; 119DateUtils.GetTimeZoneOffsetDifference = function(firstDate, secondDate) { 120 if(!secondDate) 121 secondDate = DateUtils.GetUtcDate(firstDate); 122 return 60000 * (firstDate.getTimezoneOffset() - secondDate.getTimezoneOffset()); 123}; 124DateUtils.GetTimeZoneOffset = function(date) { 125 var isECMA262Support = ASPx.Browser.Chrome && ASPx.Browser.Version >= 67; 126 if(!isECMA262Support) 127 return date.getTimezoneOffset() * 60000; 128 var utcDate = DateUtils.GetUtcDate(date); 129 var utcTimezoneOffsetDifference = DateUtils.GetTimeZoneOffsetDifference(date); 130 if(utcTimezoneOffsetDifference !== 0) 131 utcDate.setTime(utcDate.valueOf() + utcTimezoneOffsetDifference); 132 return utcDate - date; 133}; 134DateUtils.GetUtcDate = function(date) { 135 var utcFullYear = date.getUTCFullYear(); 136 var result = new Date(utcFullYear, date.getUTCMonth(), date.getUTCDate(), date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds(), date.getUTCMilliseconds()); 137 if(utcFullYear < 100) 138 result.setFullYear(utcFullYear); 139 return result; 140}; 141DateUtils.ToUtcTime = function(date) { 142 var result = new Date(); 143 result.setTime(date.valueOf() + ASPx.DateUtils.GetTimeZoneOffset(date)); 144 return result; 145}; 146DateUtils.ToLocalTime = function(date) { 147 var result = new Date(); 148 result.setTime(date.valueOf() - ASPx.DateUtils.GetTimeZoneOffset(date)); 149 return result; 150}; 151DateUtils.AreDatesEqualExact = function(date1, date2) { 152 if(date1 == null && date2 == null) 153 return true; 154 if(date1 == null || date2 == null) 155 return false; 156 return date1.getTime() == date2.getTime(); 157}; 158DateUtils.FixTimezoneGap = function(oldDate, newDate) { 159 var diff = newDate.getHours() - oldDate.getHours(); 160 if(diff == 0) 161 return; 162 var sign = (diff == 1 || diff == -23) ? -1 : 1; 163 var trial = new Date(newDate.getTime() + sign * 3600000); 164 var isDateChangedAsExpected = newDate.getHours() - trial.getHours() === diff; 165 if(isDateChangedAsExpected && (sign > 0 || trial.getDate() == newDate.getDate())) 166 newDate.setTime(trial.getTime()); 167}; 168DateUtils.GetDecadeStartYear = function(year) { 169 return 10 * Math.floor(year / 10); 170}; 171DateUtils.GetCenturyStartYear = function(year) { 172 return 100 * Math.floor(year / 100); 173}; 174DateUtils.GetCorrectedYear = function(date, pickerType) { 175 var year = date.getFullYear(); 176 return pickerType != ASPx.DatePickerType.Decades ? year : DateUtils.GetDecadeStartYear(year); 177}; 178DateUtils.GetCorrectedMonth = function(date, pickerType) { 179 return pickerType < ASPx.DatePickerType.Years ? date.getMonth() : 0; 180}; 181DateUtils.GetCorrectedDay = function(date, pickerType) { 182 return pickerType == ASPx.DatePickerType.Days ? date.getDate() : 1; 183}; 184DateUtils.CorrectDateByPickerType = function(date, pickerType) { 185 if(!ASPx.IsExists(pickerType)) 186 pickerType = ASPx.DatePickerType.Days; 187 if(!date || pickerType == ASPx.DatePickerType.Days) 188 return date; 189 var correctedYear = DateUtils.GetCorrectedYear(date, pickerType); 190 var result = new Date( 191 correctedYear, 192 DateUtils.GetCorrectedMonth(date, pickerType), 193 DateUtils.GetCorrectedDay(date, pickerType), 194 date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds() 195 ); 196 result.setFullYear(correctedYear); 197 return result; 198}; 199DateUtils.GetYearRangeFormatString = function(startYear, rangeLength) { 200 return startYear + " - " + (startYear + rangeLength - 1); 201}; 202ASPx.DateUtils = DateUtils; 203var Timer = { }; 204Timer.ClearTimer = function(timerID){ 205 if(timerID > -1) 206 window.clearTimeout(timerID); 207 return -1; 208};
209Timer.ClearInterval = function(timerID){ 210 if(timerID > -1) 211 window.clearInterval(timerID); 212 return -1; 213}; 214var setControlBoundTimer = function(handler, control, setTimerFunction, clearTimerFunction, delay) { 215 var timerId; 216 var getTimerId = function() { return timerId; }; 217 var controlMainElement = control.GetMainElement(); 218 var boundHandler = function() { 219 var controlExists = control && ASPx.GetControlCollection().Get(control.name) === control && control.GetMainElement() === controlMainElement; 220 if(controlExists) 221 handler.aspxBind(control)(); 222 else { 223 clearTimerFunction(getTimerId()); 224 controlMainElement = null; 225 } 226 }; 227 timerId = setTimerFunction(boundHandler, delay); 228 return timerId; 229}; 230Timer.SetControlBoundTimeout = function(handler, control, delay) { 231 return setControlBoundTimer(handler, control, window.setTimeout, Timer.ClearTimer, delay); 232}; 233Timer.SetControlBoundInterval = function(handler, control, delay) { 234 return setControlBoundTimer(handler, control, window.setInterval, Timer.ClearInterval, delay); 235}; 236Timer.Throttle = function(func, delay) { 237 var isThrottled = false, 238 savedArgs, 239 savedThis = this; 240 function wrapper() { 241 if(isThrottled) { 242 savedArgs = arguments; 243 savedThis = this; 244 return; 245 } 246 func.apply(this, arguments); 247 isThrottled = true; 248 setTimeout(function() { 249 isThrottled = false; 250 if(savedArgs) { 251 wrapper.apply(savedThis, savedArgs); 252 savedArgs = null; 253 } 254 }, delay); 255 } 256 wrapper.cancel = function() { 257 clearTimeout(delay); 258 delay = savedArgs = savedThis = null; 259 }; 260 return wrapper; 261}; 262ASPx.Timer = Timer; 263var Browser = { }; 264Browser.UserAgent = navigator.userAgent.toLowerCase(); 265Browser.Mozilla = false; 266Browser.IE = false; 267Browser.Firefox = false; 268Browser.Netscape = false; 269Browser.Safari = false; 270Browser.Chrome = false; 271Browser.Opera = false; 272Browser.Edge = false; 273Browser.Version = undefined; 274Browser.MajorVersion = undefined; 275Browser.WindowsPlatform = false; 276Browser.MacOSPlatform = false; 277Browser.MacOSMobilePlatform = false; 278Browser.AndroidMobilePlatform = false; 279Browser.PlaformMajorVersion = false; 280Browser.WindowsPhonePlatform = false; 281Browser.AndroidDefaultBrowser = false; 282Browser.AndroidChromeBrowser = false; 283Browser.SamsungAndroidDevice = false; 284Browser.WebKitTouchUI = false; 285Browser.MSTouchUI = false; 286Browser.TouchUI = false; 287Browser.WebKitFamily = false; 288Browser.NetscapeFamily = false; 289Browser.HardwareAcceleration = false; 290Browser.VirtualKeyboardSupported = false; 291Browser.Info = ""; 292Browser.IsQuirksMode = document.compatMode === "BackCompat"; 293function indentPlatformMajorVersion(userAgent) { 294 var regex = /(?:(?:windows nt|macintosh|mac os|cpu os|cpu iphone os|android|windows phone|linux) )(\d+)(?:[-0-9_.])*/; 295 var matches = regex.exec(userAgent); 296 if(matches) 297 Browser.PlaformMajorVersion = matches[1]; 298} 299function getIECompatibleVersionString() { 300 if(document.compatible) { 301 for(var i = 0; i < document.compatible.length; i++) 302 if(document.compatible[i].userAgent === "IE" && document.compatible[i].version) 303 return document.compatible[i].version.toLowerCase(); 304 } 305 return ""; 306} 307Browser.IdentUserAgent = function(userAgent, ignoreDocumentMode) { 308 var browserTypesOrderedList = [ "Mozilla", "IE", "Firefox", "Netscape", "Safari", "Chrome", "Opera", "Opera10", "Edge" ]; 309 var defaultBrowserType = "IE"; 310 var defaultPlatform = "Win"; 311 var defaultVersions = { Safari: 2, Chrome: 0.1, Mozilla: 1.9, Netscape: 8, Firefox: 2, Opera: 9, IE: 6, Edge: 12 }; 312 if(!userAgent || userAgent.length == 0) { 313 fillUserAgentInfo(browserTypesOrderedList, defaultBrowserType, defaultVersions[defaultBrowserType], defaultPlatform); 314 return; 315 } 316 userAgent = userAgent.toLowerCase(); 317 indentPlatformMajorVersion(userAgent); 318 try { 319 var platformIdentStrings = { 320 "Windows": "Win", 321 "Macintosh": "Mac", 322 "Mac OS": "Mac", 323 "Mac_PowerPC": "Mac", 324 "cpu os": "MacMobile", 325 "cpu iphone os": "MacMobile", 326 "Android": "Android", 327 "!Windows Phone": "WinPhone", 328 "!WPDesktop": "WinPhone", 329 "!ZuneWP": "WinPhone" 330 }; 331 var optSlashOrSpace = "(?:/|\\s*)?"; 332 var version = "(\\d+)(?:\\.((?:\\d+?[1-9])|\\d)0*?)?"; 333 var optVersion = "(?:" + version + ")?"; 334 var patterns = { 335 Safari: "applewebkit(?:.*?(?:version/" + version + "[\\.\\w\\d]*?(?:\\s+mobile\/\\S*)?\\s+safari))?", 336 Chrome: "(?:chrome|crios)(?!frame)" + optSlashOrSpace + optVersion, 337 Mozilla: "mozilla(?:.*rv:" + optVersion + ".*Gecko)?", 338 Netscape: "(?:netscape|navigator)\\d*/?\\s*" + optVersion, 339 Firefox: "firefox" + optSlashOrSpace + optVersion, 340 Opera: "(?:opera|\sopr)" + optSlashOrSpace + optVersion, 341 Opera10: "opera.*\\s*version" + optSlashOrSpace + optVersion, 342 IE: "msie\\s*" + optVersion, 343 Edge: "edge" + optSlashOrSpace + optVersion 344 }; 345 var browserType; 346 var version = -1; 347 for(var i = 0; i < browserTypesOrderedList.length; i++) { 348 var browserTypeCandidate = browserTypesOrderedList[i]; 349 var regExp = new RegExp(patterns[browserTypeCandidate], "i"); 350 if(regExp.compile) 351 regExp.compile(patterns[browserTypeCandidate], "i"); 352 var matches = regExp.exec(userAgent); 353 if(matches && matches.index >= 0) { 354 if(browserType == "IE" && version >= 11 && browserTypeCandidate == "Safari") 355 continue; 356 browserType = browserTypeCandidate; 357 if(browserType == "Opera10") 358 browserType = "Opera"; 359 var tridentPattern = "trident" + optSlashOrSpace + optVersion; 360 version = Browser.GetBrowserVersion(userAgent, matches, tridentPattern, getIECompatibleVersionString()); 361 if(browserType == "Mozilla" && version >= 11) 362 browserType = "IE"; 363 } 364 } 365 if(!browserType) 366 browserType = defaultBrowserType; 367 var browserVersionDetected = version != -1; 368 if(!browserVersionDetected) 369 version = defaultVersions[browserType]; 370 var platform; 371 var minOccurenceIndex = Number.MAX_VALUE;
372 for(var identStr in platformIdentStrings) { 373 if(!platformIdentStrings.hasOwnProperty(identStr)) continue; 374 var importantIdent = identStr.substr(0,1) == "!"; 375 var occurenceIndex = userAgent.indexOf((importantIdent ? identStr.substr(1) : identStr).toLowerCase()); 376 if(occurenceIndex >= 0 && (occurenceIndex < minOccurenceIndex || importantIdent)) { 377 minOccurenceIndex = importantIdent ? 0 : occurenceIndex; 378 platform = platformIdentStrings[identStr]; 379 } 380 } 381 var samsungPattern = "SM-[A-Z]"; 382 var matches = userAgent.toUpperCase().match(samsungPattern); 383 var isSamsungAndroidDevice = matches && matches.length > 0; 384 if(platform == "WinPhone" && version < 9) 385 version = Math.floor(getVersionFromTrident(userAgent, "trident" + optSlashOrSpace + optVersion)); 386 if(!ignoreDocumentMode && browserType == "IE" && version > 7 && document.documentMode < version) 387 version = document.documentMode; 388 if(platform == "WinPhone") 389 version = Math.max(9, version); 390 if(!platform) 391 platform = defaultPlatform; 392 if(platform == platformIdentStrings["cpu os"] && !browserVersionDetected) 393 version = 4; 394 fillUserAgentInfo(browserTypesOrderedList, browserType, version, platform, isSamsungAndroidDevice); 395 } catch(e) { 396 fillUserAgentInfo(browserTypesOrderedList, defaultBrowserType, defaultVersions[defaultBrowserType], defaultPlatform); 397 } 398}; 399function getVersionFromMatches(matches) { 400 var result = -1; 401 var versionStr = ""; 402 if(matches[1]) { 403 versionStr += matches[1]; 404 if(matches[2]) 405 versionStr += "." + matches[2]; 406 } 407 if(versionStr != "") { 408 result = parseFloat(versionStr); 409 if(isNaN(result)) 410 result = -1; 411 } 412 return result; 413} 414function getVersionFromTrident(userAgent, tridentPattern) { 415 var tridentDiffFromVersion = 4; 416 var matches = new RegExp(tridentPattern, "i").exec(userAgent); 417 return getVersionFromMatches(matches) + tridentDiffFromVersion; 418} 419Browser.GetBrowserVersion = function(userAgent, matches, tridentPattern, ieCompatibleVersionString) { 420 var version = getVersionFromMatches(matches); 421 if(ieCompatibleVersionString) { 422 var versionFromTrident = getVersionFromTrident(userAgent, tridentPattern); 423 if(ieCompatibleVersionString === "edge" || parseInt(ieCompatibleVersionString) === versionFromTrident) 424 return versionFromTrident; 425 } 426 return version; 427}; 428function fillUserAgentInfo(browserTypesOrderedList, browserType, version, platform, isSamsungAndroidDevice) { 429 for(var i = 0; i < browserTypesOrderedList.length; i++) { 430 var type = browserTypesOrderedList[i]; 431 Browser[type] = type == browserType; 432 } 433 Browser.Version = Math.floor(10.0 * version) / 10.0; 434 Browser.MajorVersion = Math.floor(Browser.Version); 435 Browser.WindowsPlatform = platform == "Win" || platform == "WinPhone"; 436 Browser.MacOSPlatform = platform == "Mac"; 437 var isMacWithTouchSupport = platform == "Mac" && (!!window.ontouchstart || window.navigator.maxTouchPoints > 0); 438 Browser.MacOSMobilePlatform = platform == "MacMobile" || isMacWithTouchSupport; 439 if(Browser.MacOSMobilePlatform) 440 Browser.MacOSPlatform = false; 441 Browser.AndroidMobilePlatform = platform == "Android"; 442 Browser.WindowsPhonePlatform = platform == "WinPhone"; 443 Browser.WebKitFamily = Browser.Safari || Browser.Chrome || Browser.Opera && Browser.MajorVersion >= 15; 444 Browser.NetscapeFamily = Browser.Netscape || Browser.Mozilla || Browser.Firefox; 445 Browser.HardwareAcceleration = (Browser.IE && Browser.MajorVersion >= 9) || (Browser.Firefox && Browser.MajorVersion >= 4) || 446 (Browser.AndroidMobilePlatform && Browser.Chrome) || (Browser.Chrome && Browser.MajorVersion >= 37) || 447 (Browser.Safari && !Browser.WindowsPlatform) || Browser.Edge || (Browser.Opera && Browser.MajorVersion >= 46); 448 Browser.WebKitTouchUI = Browser.MacOSMobilePlatform || Browser.AndroidMobilePlatform; 449 var isIETouchUI = Browser.IE && Browser.MajorVersion > 9 && Browser.WindowsPlatform && Browser.UserAgent.toLowerCase().indexOf("touch") >= 0; 450 Browser.MSTouchUI = isIETouchUI || (Browser.Edge && !!window.navigator.maxTouchPoints); 451 Browser.TouchUI = Browser.WebKitTouchUI || Browser.MSTouchUI; 452 Browser.MobileUI = Browser.WebKitTouchUI || Browser.WindowsPhonePlatform; 453 Browser.AndroidDefaultBrowser = Browser.AndroidMobilePlatform && !Browser.Chrome; 454 Browser.AndroidChromeBrowser = Browser.AndroidMobilePlatform && Browser.Chrome; 455 if(isSamsungAndroidDevice) 456 Browser.SamsungAndroidDevice = isSamsungAndroidDevice; 457 if(Browser.MSTouchUI) { 458 var isARMArchitecture = Browser.UserAgent.toLowerCase().indexOf("arm;") > -1; 459 Browser.VirtualKeyboardSupported = isARMArchitecture || Browser.WindowsPhonePlatform; 460 } else { 461 Browser.VirtualKeyboardSupported = Browser.MobileUI || (Browser.Chrome && !!window.navigator.maxTouchPoints); 462 } 463 fillDocumentElementBrowserTypeClassNames(browserTypesOrderedList); 464} 465function fillDocumentElementBrowserTypeClassNames(browserTypesOrderedList) { 466 var documentElementClassName = ""; 467 var browserTypeslist = browserTypesOrderedList.concat(["WindowsPlatform", "MacOSPlatform", "MacOSMobilePlatform", "AndroidMobilePlatform", 468 "WindowsPhonePlatform", "WebKitFamily", "WebKitTouchUI", "MSTouchUI", "TouchUI", "AndroidDefaultBrowser", "MobileUI"]);
469 for(var i = 0; i < browserTypeslist.length; i++) { 470 var type = browserTypeslist[i]; 471 if(Browser[type]) 472 documentElementClassName += "dx" + type + " "; 473 } 474 documentElementClassName += "dxBrowserVersion-" + Browser.MajorVersion; 475 if(document && document.documentElement) { 476 if(document.documentElement.className != "") 477 documentElementClassName = " " + documentElementClassName; 478 document.documentElement.className += documentElementClassName; 479 Browser.Info = documentElementClassName; 480 } 481} 482Browser.SupportsStickyPositioning = function() { 483 return this.Chrome && this.MajorVersion >= 56 484 || this.Firefox && this.MajorVersion >= 32 485 || this.Safari && this.MajorVersion >= 6 && this.Version !== "6" 486 || this.Opera && this.MajorVersion >= 42; 487}; 488Browser.IdentUserAgent(Browser.UserAgent); 489ASPx.Browser = Browser; 490ASPx.BlankUrl = Browser.IE ? ASPx.SSLSecureBlankUrl : (Browser.Opera ? "about:blank" : ""); 491var Data = { }; 492Data.ArrayInsert = function(array, element, position){ 493 if(0 <= position && position < array.length){ 494 for(var i = array.length; i > position; i --) 495 array[i] = array[i - 1]; 496 array[position] = element; 497 } 498 else 499 array.push(element); 500}; 501Data.ArrayRemove = function(array, element){ 502 var index = Data.ArrayIndexOf(array, element); 503 if(index > -1) Data.ArrayRemoveAt(array, index); 504}; 505Data.ArrayRemoveAt = function(array, index){ 506 if(index >= 0 && index < array.length){ 507 for(var i = index; i < array.length - 1; i++) 508 array[i] = array[i + 1]; 509 array.pop(); 510 } 511}; 512Data.ArrayClear = function(array){ 513 while(array.length > 0) 514 array.pop(); 515}; 516Data.ArrayIndexOf = function(array, element, comparer) { 517 if(!comparer) { 518 for(var i = 0; i < array.length; i++) { 519 if(array[i] == element) 520 return i; 521 } 522 } else { 523 for(var i = 0; i < array.length; i++) { 524 if(comparer(array[i], element)) 525 return i; 526 } 527 } 528 return -1; 529}; 530Data.ArrayContains = function(array, element) { 531 return Data.ArrayIndexOf(array, element) >= 0; 532}; 533Data.ArrayEqual = function(array1, array2) { 534 var count1 = array1.length; 535 var count2 = array2.length; 536 if(count1 != count2) 537 return false; 538 for(var i = 0; i < count1; i++) 539 if(array1[i] != array2[i]) 540 return false; 541 return true; 542}; 543Data.ArraySame = function(array1, array2) { 544 if(array1.length !== array2.length) 545 return false; 546 return array1.every(function(elem) { return Data.ArrayContains(array2, elem); }); 547}; 548Data.ArrayGetIntegerEdgeValues = function(array) { 549 var arrayToSort = Data.CollectionToArray(array); 550 Data.ArrayIntegerAscendingSort(arrayToSort); 551 return { 552 start: arrayToSort[0], 553 end: arrayToSort[arrayToSort.length - 1] 554 }; 555}; 556Data.ArrayIntegerAscendingSort = function(array){ 557 Data.ArrayIntegerSort(array); 558}; 559Data.ArrayIntegerSort = function(array, desc) { 560 array.sort(function(i1, i2) { 561 var res = 0; 562 if(i1 > i2) 563 res = 1; 564 else if(i1 < i2) 565 res = -1; 566 if(desc) 567 res *= -1; 568 return res; 569 }); 570}; 571Data.CollectionsUnionToArray = function(firstCollection, secondCollection) { 572 var result = []; 573 var firstCollectionLength = firstCollection.length; 574 var secondCollectionLength = secondCollection.length; 575 for(var i = 0; i < firstCollectionLength + secondCollectionLength; i++) { 576 if(i < firstCollectionLength) 577 result.push(firstCollection[i]); 578 else 579 result.push(secondCollection[i - firstCollectionLength]); 580 } 581 return result; 582}; 583Data.CollectionToArray = function(collection) { 584 var array = []; 585 for(var i = 0; i < collection.length; i++) 586 array.push(collection[i]); 587 return array; 588}; 589Data.CreateHashTableFromArray = function(array) { 590 var hash = []; 591 for(var i = 0; i < array.length; i++) 592 hash[array[i]] = 1; 593 return hash; 594}; 595Data.CreateIndexHashTableFromArray = function(array) { 596 var hash = []; 597 for(var i = 0; i < array.length; i++) 598 hash[array[i]] = i; 599 return hash; 600}; 601Data.ArrayToHash = function(array, getKeyFunc, getValueFunc) { 602 if(!(array instanceof Array)) 603 return { }; 604 return array.reduce(function(map, element, index) { 605 var key = getKeyFunc(element, index); 606 var value = getValueFunc(element, index); 607 map[key] = value; 608 return map; 609 }, { }); 610}; 611Data.Sum = function(array, getValueFunc) { 612 if(!(array instanceof Array)) 613 return 0; 614 return array.reduce(function(prevValue, item) { 615 var value = getValueFunc ? getValueFunc(item) : item; 616 if(!ASPx.IsNumber(value)) 617 value = 0; 618 return prevValue + value; 619 }, 0); 620}; 621Data.Min = function(array, getValueFunc) { return CalculateArrayMinMax(array, getValueFunc, false); }; 622Data.Max = function(array, getValueFunc) { return CalculateArrayMinMax(array, getValueFunc, true); }; 623var CalculateArrayMinMax = function(array, getValueFunc, isMax) { 624 if(!(array instanceof Array)) 625 return 0; 626 var startValue = isMax ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY; 627 return array.reduce(function(prevValue, item) { 628 var value = getValueFunc ? getValueFunc(item) : item; 629 if(!ASPx.IsNumber(value)) 630 value = startValue; 631 var func = isMax ? Math.max : Math.min; 632 return func(value, prevValue); 633 }, startValue); 634}; 635var defaultBinarySearchComparer = function(array, index, value) { 636 var arrayElement = array[index]; 637 if(arrayElement == value) 638 return 0; 639 else
640 return arrayElement < value ? -1 : 1; 641}; 642Data.NearestLeftBinarySearchComparer = function(array, index, value) { 643 var arrayElement = array[index]; 644 var leftPoint = arrayElement < value; 645 var lastLeftPoint = leftPoint && index == array.length - 1; 646 var nearestLeftPoint = lastLeftPoint || (leftPoint && array[index + 1] >= value); 647 if(nearestLeftPoint) 648 return 0; 649 else 650 return arrayElement < value ? -1 : 1; 651}; 652Data.ArrayBinarySearch = function(array, value, binarySearchComparer, startIndex, length) { 653 if(!binarySearchComparer) 654 binarySearchComparer = defaultBinarySearchComparer; 655 if(!ASPx.IsExists(startIndex)) 656 startIndex = 0; 657 if(!ASPx.IsExists(length)) 658 length = array.length - startIndex; 659 var endIndex = (startIndex + length) - 1; 660 while(startIndex <= endIndex) { 661 var middle = (startIndex + ((endIndex - startIndex) >> 1)); 662 var compareResult = binarySearchComparer(array, middle, value); 663 if(compareResult == 0) 664 return middle; 665 if(compareResult < 0) 666 startIndex = middle + 1; 667 else 668 endIndex = middle - 1; 669 } 670 return -(startIndex + 1); 671}; 672Data.ArrayFlatten = function(arrayOfArrays) { 673 return [].concat.apply([], arrayOfArrays); 674}; 675Data.GetDistinctArray = function(array) { 676 var resultArray = []; 677 for(var i = 0; i < array.length; i++) { 678 var currentEntry = array[i]; 679 if(Data.ArrayIndexOf(resultArray, currentEntry) == -1) { 680 resultArray.push(currentEntry); 681 } 682 } 683 return resultArray; 684}; 685Data.ForEach = function(arr, callback) { 686 if(Array.prototype.forEach) { 687 Array.prototype.forEach.call(arr, callback); 688 } else { 689 for(var i = 0, len = arr.length; i < len; i++) { 690 callback(arr[i], i, arr); 691 } 692 } 693}; 694Data.MergeHashTables = function(target, object) { 695 if(!object || typeof (object) == "string") 696 return target; 697 if(!target) 698 target = {}; 699 for(var key in object) 700 if(key && !(key in target)) 701 target[key] = object[key]; 702 return target; 703}; 704Data.Range = function(count, start) { 705 count = parseInt(count) || 0; 706 start = parseInt(start) || 0; 707 if(count < 0) count = 0; 708 if(start < 0) start = 0; 709 return Array.apply(null, Array(count)).map(function(val, i) { return start + i; }); 710}; 711ASPx.Data = Data; 712var Cookie = { }; 713Cookie.DelCookie = function(name){ 714 setCookieInternal(name, "", new Date(1970, 1, 1)); 715}; 716Cookie.GetCookie = function(name) { 717 name = escape(name); 718 var cookies = document.cookie.split(';'); 719 for(var i = 0; i < cookies.length; i++) { 720 var cookie = Str.Trim(cookies[i]); 721 if(cookie.indexOf(name + "=") == 0) 722 return unescape(cookie.substring(name.length + 1, cookie.length)); 723 else if(cookie.indexOf(name + ";") == 0 || cookie === name) 724 return ""; 725 } 726 return null; 727}; 728Cookie.SetCookie = function(name, value, expirationDate){ 729 if(!ASPx.IsExists(value)) { 730 Cookie.DelCookie(name); 731 return; 732 } 733 if(!ASPx.Ident.IsDate(expirationDate)) { 734 expirationDate = new Date(); 735 expirationDate.setFullYear(expirationDate.getFullYear() + 1); 736 } 737 setCookieInternal(name, value, expirationDate); 738}; 739function setCookieInternal(name, value, date){ 740 document.cookie = escape(name) + "=" + escape(value.toString()) + "; expires=" + date.toGMTString() + "; path=/"; 741} 742ASPx.Cookie = Cookie;
743ASPx.ImageUtils = { 744 GetImageSrc: function (image){ 745 return image.src; 746 }, 747 SetImageSrc: function(image, src){ 748 if(isSourceResetRequired()) 749 image.src = ""; 750 image.src = src; 751 }, 752 SetSize: function(image, width, height){ 753 image.style.width = width + "px"; 754 image.style.height = height + "px"; 755 }, 756 GetSize: function(image, isWidth) { 757 return (isWidth ? ASPx.GetElementOffsetWidth(image) : ASPx.GetElementOffsetHeight(image)); 758 } 759}; 760var Str = { }; 761Str.ApplyReplacement = function(text, replecementTable) { 762 if(typeof(text) != "string") 763 text = text.toString(); 764 for(var i = 0; i < replecementTable.length; i++) { 765 var replacement = replecementTable[i]; 766 text = text.replace(replacement[0], replacement[1]); 767 } 768 return text; 769}; 770Str.CompleteReplace = function(text, regexp, newSubStr) { 771 if(typeof(text) != "string") 772 text = text.toString(); 773 var textPrev; 774 do { 775 textPrev = text; 776 text = text.replace(regexp, newSubStr); 777 } while(text != textPrev); 778 return text; 779}; 780Str.EncodeHtml = function(html) { 781 return Str.ApplyReplacement(html, [ 782 [ /&/g, '&x;' ], [ /&/g, '&' ], 783 [ /"/g, '"x;' ], [ /"/g, '"' ], 784 [ /</g, '<x;' ], [ /</g, '<' ], 785 [ />/g, '>x;' ], [ />/g, '>' ] 786 ]); 787}; 788Str.DecodeHtml = function(html) { 789 return Str.ApplyReplacement(html, [ 790 [ />/g, '>' ], [ />x;/g, '>' ], 791 [ /</g, '<' ], [ /<x;/g, '<' ], 792 [ /"/g, '"' ], [ /"x;/g,'"' ], 793 [ /&/g, '&' ], [ /&x;/g, '&' ] 794 ]); 795}; 796Str.DecodeHtmlViaTextArea = function(html) { 797 var textArea = document.createElement("TEXTAREA"); 798 setInnerHtmlInternal(textArea, html); 799 return textArea.value; 800}; 801Str.TrimStart = function(str) { 802 return trimInternal(str, true); 803}; 804Str.TrimEnd = function(str) { 805 return trimInternal(str, false, true); 806}; 807Str.Trim = function(str) { 808 return trimInternal(str, true, true); 809}; 810Str.EscapeForRegEx = function(str) { 811 return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); 812};
813var whiteSpaces = { 814 0x0009: 1, 0x000a: 1, 0x000b: 1, 0x000c: 1, 0x000d: 1, 0x0020: 1, 0x0085: 1, 815 0x00a0: 1, 0x1680: 1, 0x180e: 1, 0x2000: 1, 0x2001: 1, 0x2002: 1, 0x2003: 1, 816 0x2004: 1, 0x2005: 1, 0x2006: 1, 0x2007: 1, 0x2008: 1, 0x2009: 1, 0x200a: 1, 817 0x200b: 1, 0x2028: 1, 0x2029: 1, 0x202f: 1, 0x205f: 1, 0x3000: 1 818}; 819var caretWidth = 1; 820function trimInternal(source, trimStart, trimEnd) { 821 var len = source.length; 822 if(!len) 823 return source; 824 var result = ""; 825 if(len < 0xBABA1) 826 result = trimSource(source, trimStart, trimEnd); 827 else 828 result = trimLargeSource(source, len, trimStart, trimEnd); 829 return Str.ClearString(result); 830} 831function trimSource(source, trimStart, trimEnd) { 832 var result = source; 833 if(trimStart) 834 result = result.replace(/^\s+/, ""); 835 if(trimEnd) 836 result = result.replace(/\s+$/, ""); 837 return result; 838} 839function trimLargeSource(source, len, trimStart, trimEnd) { 840 var start = 0; 841 if(trimEnd) { 842 while(len > 0 && whiteSpaces[source.charCodeAt(len - 1)]) { 843 len--; 844 } 845 } 846 if(trimStart && len > 0) { 847 while(start < len && whiteSpaces[source.charCodeAt(start)]) { 848 start++; 849 } 850 } 851 return source.substring(start, len); 852} 853var inlineStringLength = 12; 854Str.ClearString = function(str) { 855 if(!ASPx.Browser.Chrome) 856 return str; 857 return str.length < inlineStringLength ? str : JSON.parse(JSON.stringify(str)); 858}; 859Str.Insert = function(str, subStr, index) { 860 var leftText = str.slice(0, index); 861 var rightText = str.slice(index); 862 return leftText + subStr + rightText; 863}; 864Str.InsertEx = function(str, subStr, startIndex, endIndex) { 865 var leftText = str.slice(0, startIndex); 866 var rightText = str.slice(endIndex); 867 return leftText + subStr + rightText; 868}; 869var greekSLFSigmaChar = String.fromCharCode(962); 870var greekSLSigmaChar = String.fromCharCode(963); 871Str.PrepareStringForFilter = function(s){ 872 s = s.toLowerCase(); 873 if(ASPx.Browser.WebKitFamily) { 874 return s.replace(new RegExp(greekSLFSigmaChar, "g"), greekSLSigmaChar); 875 } 876 return s; 877}; 878Str.GetCoincideCharCount = function(text, filter, textMatchingDelegate) { 879 var coincideText = ASPx.Str.PrepareStringForFilter(filter); 880 var originText = ASPx.Str.PrepareStringForFilter(text); 881 while(coincideText != "" && !textMatchingDelegate(originText, coincideText)) { 882 coincideText = coincideText.slice(0, -1); 883 } 884 return coincideText.length; 885}; 886ASPx.Str = Str; 887var Xml = { }; 888Xml.Parse = function(xmlStr) { 889 if(window.DOMParser) { 890 var parser = new DOMParser(); 891 return parser.parseFromString(xmlStr, "text/xml"); 892 } 893 else if(window.ActiveXObject) { 894 var xmlDoc = new window.ActiveXObject("Microsoft.XMLDOM"); 895 if(xmlDoc) { 896 xmlDoc.async = false; 897 xmlDoc.loadXML(xmlStr); 898 return xmlDoc; 899 } 900 } 901 return null; 902}; 903ASPx.Xml = Xml; 904ASPx.Key = { 905 F1 : 112, 906 F2 : 113, 907 F3 : 114, 908 F4 : 115, 909 F5 : 116, 910 F6 : 117, 911 F7 : 118, 912 F8 : 119,
913 F9 : 120, 914 F10 : 121, 915 F11 : 122, 916 F12 : 123, 917 Ctrl : 17, 918 Shift : 16, 919 Alt : 18, 920 Enter : 13, 921 Home : 36, 922 End : 35, 923 Left : 37, 924 Right : 39, 925 Up : 38, 926 Down : 40, 927 PageUp : 33, 928 PageDown : 34, 929 Esc : 27, 930 Space : 32, 931 Tab : 9, 932 Backspace : 8, 933 Delete : 46, 934 Insert : 45, 935 ContextMenu : 93, 936 Windows : 91, 937 Decimal : 110 938}; 939ASPx.ModifierKey = { 940 None: 0, 941 Ctrl: 1 << (0 + 16), 942 Shift: 1 << (2 + 16), 943 Alt: 1 << (4 + 16), 944 Meta: 1 << (8 + 16) 945}; 946ASPx.KeyCode = { 947 Backspace : 8, 948 Tab : 9, 949 Enter : 13, 950 Pause : 19, 951 CapsLock : 20, 952 Esc : 27, 953 Space : 32, 954 PageUp : 33, 955 PageDown : 34, 956 End : 35, 957 Home : 36, 958 Left : 37, 959 Up : 38, 960 Right : 39, 961 Down : 40, 962 Insert : 45, 963 Delete : 46, 964 Key_0 : 48, 965 Key_1 : 49, 966 Key_2 : 50, 967 Key_3 : 51, 968 Key_4 : 52, 969 Key_5 : 53, 970 Key_6 : 54, 971 Key_7 : 55, 972 Key_8 : 56, 973 Key_9 : 57, 974 Key_a : 65, 975 Key_b : 66, 976 Key_c : 67, 977 Key_d : 68, 978 Key_e : 69, 979 Key_f : 70, 980 Key_g : 71, 981 Key_h : 72, 982 Key_i : 73, 983 Key_j : 74, 984 Key_k : 75, 985 Key_l : 76, 986 Key_m : 77, 987 Key_n : 78, 988 Key_o : 79, 989 Key_p : 80, 990 Key_q : 81, 991 Key_r : 82, 992 Key_s : 83, 993 Key_t : 84, 994 Key_u : 85, 995 Key_v : 86, 996 Key_w : 87, 997 Key_x : 88, 998 Key_y : 89, 999 Key_z : 90, 1000 Windows : 91, 1001 ContextMenu : 93, 1002 Numpad_0 : 96, 1003 Numpad_1 : 97, 1004 Numpad_2 : 98, 1005 Numpad_3 : 99, 1006 Numpad_4 : 100, 1007 Numpad_5 : 101, 1008 Numpad_6 : 102, 1009 Numpad_7 : 103, 1010 Numpad_8 : 104, 1011 Numpad_9 : 105, 1012 Multiply : 106, 1013 Add : 107, 1014 Subtract : 109, 1015 Decimal : 110, 1016 Divide : 111, 1017 F1 : 112, 1018 F2 : 113, 1019 F3 : 114, 1020 F4 : 115, 1021 F5 : 116, 1022 F6 : 117, 1023 F7 : 118, 1024 F8 : 119,
1025 F9 : 120, 1026 F10 : 121, 1027 F11 : 122, 1028 F12 : 123, 1029 NumLock : 144, 1030 ScrollLock : 145, 1031 Semicolon : 186, 1032 Equals : 187, 1033 Comma : 188, 1034 Dash : 189, 1035 Period : 190, 1036 ForwardSlash : 191, 1037 GraveAccent : 192, 1038 OpenBracket : 219, 1039 BackSlash : 220, 1040 CloseBracket : 221, 1041 SingleQuote : 222 1042}; 1043ASPx.ScrollBarMode = { Hidden: 0, Visible: 1, Auto: 2 }; 1044ASPx.ColumnResizeMode = { None: 0, Control: 1, NextColumn: 2 }; 1045var Selection = { }; 1046Selection.Set = function(input, startPos, endPos, scrollToSelection, isApi) { 1047 if(!ASPx.IsExistsElement(input)) 1048 return; 1049 var isInputFocused = ASPx.GetActiveElement() === input; 1050 var isInputNativeFocusLocked = ASPx.VirtualKeyboardUI.getInputNativeFocusLocked(); 1051 if(!isApi && Browser.VirtualKeyboardSupported && (!isInputFocused || isInputNativeFocusLocked)) 1052 return; 1053 var textLen = input.value.length; 1054 startPos = ASPx.GetDefinedValue(startPos, 0); 1055 endPos = ASPx.GetDefinedValue(endPos, textLen); 1056 if(startPos < 0) 1057 startPos = 0; 1058 if(endPos < 0 || endPos > textLen) 1059 endPos = textLen; 1060 if(startPos > endPos) 1061 startPos = endPos; 1062 var makeReadOnly = false; 1063 if(Browser.WebKitFamily && input.readOnly) { 1064 input.readOnly = false; 1065 makeReadOnly = true; 1066 } 1067 try { 1068 if(Browser.Firefox && Browser.Version >= 8) 1069 input.setSelectionRange(startPos, endPos, "backward"); 1070 else if(Browser.IE && input.createTextRange) { 1071 var range = input.createTextRange(); 1072 range.collapse(true); 1073 range.moveStart("character", startPos); 1074 range.moveEnd("character", endPos - startPos); 1075 range.select(); 1076 } else { 1077 forceScrollToSelectionRange(input, startPos, endPos); 1078 input.setSelectionRange(startPos, endPos); 1079 } 1080 if(Browser.Opera || Browser.Firefox || Browser.Chrome || Browser.Edge) 1081 input.focus(); 1082 } catch(e) { } 1083 if(scrollToSelection && input.tagName == 'TEXTAREA') { 1084 var scrollHeight = input.scrollHeight; 1085 var approxCaretPos = startPos; 1086 var scrollTop = Math.max(Math.round(approxCaretPos * scrollHeight / textLen - input.clientHeight / 2), 0); 1087 input.scrollTop = scrollTop; 1088 } 1089 if(makeReadOnly) 1090 input.readOnly = true; 1091}; 1092var getTextWidthBeforePos = function(input, pos) { 1093 return ASPx.GetSizeOfText(input.value.toString().substr(0, pos), ASPx.GetCurrentStyle(input)).width; 1094}; 1095var forceScrollToSelectionRange = function(input, startPos, endPos) { 1096 if(endPos === input.value.length) 1097 input.scrollLeft = input.scrollWidth; 1098 else if(startPos === 0 && endPos === 0) 1099 input.scrollLeft = 0; 1100 else { 1101 var inputRawWidth = ASPx.GetElementOffsetWidth(input) - ASPx.GetLeftRightBordersAndPaddingsSummaryValue(input); 1102 if(inputRawWidth < input.scrollWidth) { 1103 var widthBeforeEndPos = getTextWidthBeforePos(input, endPos) + caretWidth; 1104 if(input.scrollLeft < widthBeforeEndPos - inputRawWidth) 1105 input.scrollLeft = widthBeforeEndPos - inputRawWidth; 1106 else { 1107 var widthBeforeStartPos = getTextWidthBeforePos(input, startPos) - caretWidth; 1108 if(input.scrollLeft > widthBeforeStartPos) 1109 input.scrollLeft = widthBeforeStartPos; 1110 } 1111 } 1112 } 1113}; 1114Selection.GetInfo = function(input) { 1115 var start, end; 1116 if(Browser.IE && Browser.Version < 9) { 1117 var range = document.selection.createRange(); 1118 var rangeCopy = range.duplicate(); 1119 range.move('character', -input.value.length); 1120 range.setEndPoint('EndToStart', rangeCopy); 1121 start = range.text.length; 1122 end = start + rangeCopy.text.length; 1123 } else { 1124 try { 1125 start = input.selectionStart; 1126 end = input.selectionEnd; 1127 } catch (e) { 1128 } 1129 } 1130 return { startPos: start, endPos: end }; 1131}; 1132Selection.GetExtInfo = function(input) { 1133 var start = 0, end = 0, textLen = 0; 1134 if(Browser.IE && Browser.Version < 9) { 1135 var normalizedValue; 1136 var range, textInputRange, textInputEndRange; 1137 range = document.selection.createRange(); 1138 if(range && range.parentElement() == input) { 1139 textLen = input.value.length; 1140 normalizedValue = input.value.replace(/\r\n/g, "\n"); 1141 textInputRange = input.createTextRange(); 1142 textInputRange.moveToBookmark(range.getBookmark()); 1143 textInputEndRange = input.createTextRange(); 1144 textInputEndRange.collapse(false); 1145 if(textInputRange.compareEndPoints("StartToEnd", textInputEndRange) > -1) { 1146 start = textLen; 1147 end = textLen; 1148 } else { 1149 start = normalizedValue.slice(0, start).split("\n").length - textInputRange.moveStart("character", -textLen) -1; 1150 if(textInputRange.compareEndPoints("EndToEnd", textInputEndRange) > -1) 1151 end = textLen; 1152 else 1153 end = normalizedValue.slice(0, end).split("\n").length - textInputRange.moveEnd("character", -textLen) - 1; 1154 } 1155 } 1156 return {startPos: start, endPos: end}; 1157 } 1158 try { 1159 start = input.selectionStart; 1160 end = input.selectionEnd; 1161 } catch (e) { 1162 } 1163 return {startPos: start, endPos: end}; 1164}; 1165Selection.SetCaretPosition = function(input, caretPos) { 1166 if(typeof caretPos === "undefined" || caretPos < 0) 1167 caretPos = input.value.length; 1168 Selection.Set(input, caretPos, caretPos, true); 1169}; 1170Selection.GetCaretPosition = function(element, isDialogMode) { 1171 var pos = 0; 1172 if("selectionStart" in element) { 1173 pos = element.selectionStart; 1174 } else if("selection" in document) { 1175 element.focus(); 1176 var sel = document.selection.createRange(), 1177 selLength = document.selection.createRange().text.length; 1178 sel.moveStart("character", -element.value.length); 1179 pos = sel.text.length - selLength; 1180 } 1181 if(isDialogMode && !pos) { 1182 pos = element.value.length - 1; 1183 } 1184 return pos; 1185}; 1186Selection.Clear = function() { 1187 try { 1188 if(window.getSelection) { 1189 window.getSelection().removeAllRanges(); 1190 } 1191 else if(document.selection) { 1192 if(document.selection.empty) 1193 document.selection.empty(); 1194 else if(document.selection.clear) 1195 document.selection.clear(); 1196 } 1197 } catch(e) { 1198 } 1199}; 1200Selection.ClearOnMouseMove = function(evt) { 1201 if(!Browser.IE || (evt.button != 0)) 1202 Selection.Clear(); 1203}; 1204Selection.SetElementSelectionEnabled = function(element, value) { 1205 var userSelectValue = value ? "" : "none"; 1206 var func = value ? Evt.DetachEventFromElement : Evt.AttachEventToElement; 1207 if(Browser.Firefox) 1208 element.style.MozUserSelect = userSelectValue; 1209 else if(Browser.WebKitFamily) 1210 element.style.webkitUserSelect = userSelectValue; 1211 else if(Browser.IE && Browser.Version > 10 || Browser.Edge) 1212 element.style.msUserSelect = userSelectValue; 1213 else if(Browser.Opera) 1214 func(element, "mousemove", Selection.Clear); 1215 else { 1216 func(element, "selectstart", ASPx.FalseFunction); 1217 func(element, "mousemove", Selection.Clear); 1218 } 1219}; 1220Selection.SetElementAsUnselectable = function(element, isWithChild, recursive) { 1221 if(element && element.nodeType == 1) { 1222 element.unselectable = "on"; 1223 if(Browser.NetscapeFamily) 1224 element.onmousedown = ASPx.FalseFunction; 1225 if((Browser.IE && Browser.Version >= 9) || Browser.WebKitFamily) 1226 Evt.AttachEventToElement(element, "mousedown", Evt.PreventEventAndBubble);
1227 if(isWithChild === true){ 1228 for(var j = 0; j < element.childNodes.length; j ++) 1229 Selection.SetElementAsUnselectable(element.childNodes[j], (!!recursive ? true : false), (!!recursive)); 1230 } 1231 } 1232}; 1233Selection.AreEqual = function(selection1, selection2) { 1234 return selection1.startPos === selection2.startPos && selection1.endPos === selection2.endPos; 1235}; 1236ASPx.Selection = Selection; 1237var MouseScroller = { }; 1238MouseScroller.MinimumOffset = 10; 1239MouseScroller.Create = function(getElement, getScrollXElement, getScrollYElement, needPreventScrolling, vertRecursive, onMouseDown, onMouseMove, onMouseUp, onMouseUpMissed) { 1240 var element = getElement(); 1241 if(!element) 1242 return; 1243 if(!element.dxMouseScroller) 1244 element.dxMouseScroller = new MouseScroller.Extender(getElement, getScrollXElement, getScrollYElement, needPreventScrolling, vertRecursive, onMouseDown, onMouseMove, onMouseUp, onMouseUpMissed); 1245 return element.dxMouseScroller; 1246}; 1247MouseScroller.Extender = function(getElement, getScrollXElement, getScrollYElement, needPreventScrolling, vertRecursive, onMouseDown, onMouseMove, onMouseUp, onMouseUpMissed) { 1248 this.getElement = getElement; 1249 this.getScrollXElement = getScrollXElement; 1250 this.getScrollYElement = getScrollYElement; 1251 this.needPreventScrolling = needPreventScrolling; 1252 this.vertRecursive = !!vertRecursive; 1253 this.createHandlers(onMouseDown || function() { }, onMouseMove || function() { }, onMouseUp || function() { }, onMouseUpMissed || function() { }); 1254 this.update(); 1255}; 1256MouseScroller.Extender.prototype = { 1257 update: function() { 1258 if(this.element) 1259 Evt.DetachEventFromElement(this.element, ASPx.TouchUIHelper.touchMouseDownEventName, this.mouseDownHandler); 1260 this.element = this.getElement(); 1261 Evt.AttachEventToElement(this.element, ASPx.TouchUIHelper.touchMouseDownEventName, this.mouseDownHandler); 1262 Evt.AttachEventToElement(this.element, "click", this.mouseClickHandler); 1263 if(Browser.MSTouchUI && this.element.className.indexOf(ASPx.TouchUIHelper.msTouchDraggableClassName) < 0) 1264 this.element.className += " " + ASPx.TouchUIHelper.msTouchDraggableClassName; 1265 this.scrollXElement = this.getScrollXElement(); 1266 this.scrollYElement = this.getScrollYElement(); 1267 }, 1268 createHandlers: function(onMouseDown, onMouseMove, onMouseUp, onMouseUpMissed) { 1269 var mouseDownCounter = 0; 1270 this.onMouseDown = onMouseDown; 1271 this.onMouseMove = onMouseMove; 1272 this.onMouseUp = onMouseUp; 1273 this.mouseDownHandler = function(e) { 1274 if(mouseDownCounter++ > 0) { 1275 this.finishScrolling(); 1276 onMouseUpMissed(); 1277 } 1278 var eventSource = Evt.GetEventSource(e); 1279 var requirePreventCustonScroll = ASPx.IsExists(ASPx.TouchUIHelper.RequirePreventCustomScroll) && ASPx.TouchUIHelper.RequirePreventCustomScroll(eventSource, this.element); 1280 this.requirePreventScroll = requirePreventCustonScroll || this.needPreventScrolling && this.needPreventScrolling(eventSource); 1281 if(this.requirePreventScroll) 1282 return; 1283 this.scrollableTreeLine = this.GetScrollableElements(); 1284 this.firstX = this.prevX = Evt.GetEventX(e); 1285 this.firstY = this.prevY = Evt.GetEventY(e); 1286 Evt.AttachEventToDocument(ASPx.TouchUIHelper.touchMouseMoveEventName, this.mouseMoveHandler); 1287 Evt.AttachEventToDocument(ASPx.TouchUIHelper.touchMouseUpEventName, this.mouseUpHandler); 1288 this.onMouseDown(e); 1289 }.aspxBind(this); 1290 this.mouseMoveHandler = function(e) { 1291 if(ASPx.TouchUIHelper.isGesture) 1292 return; 1293 var x = Evt.GetEventX(e); 1294 var y = Evt.GetEventY(e); 1295 var xDiff = this.prevX - x; 1296 var yDiff = this.prevY - y; 1297 if(this.vertRecursive) { 1298 var isTopDirection = yDiff < 0; 1299 this.scrollYElement = this.GetElementForVertScrolling(isTopDirection, this.prevIsTopDirection, this.scrollYElement); 1300 this.prevIsTopDirection = isTopDirection; 1301 } 1302 if(this.scrollXElement && xDiff != 0) 1303 this.scrollXElement.scrollLeft += xDiff; 1304 if(this.scrollYElement && yDiff != 0) { 1305 this.scrollYElement.scrollTop += yDiff; 1306 var isOuterScrollableElement = this.scrollableTreeLine[this.scrollableTreeLine.length - 1] == this.scrollYElement; 1307 if(isOuterScrollableElement) 1308 y += yDiff; 1309 } 1310 this.prevX = x; 1311 this.prevY = y; 1312 Evt.PreventEvent(e); 1313 this.onMouseMove(e); 1314 }.aspxBind(this); 1315 this.mouseUpHandler = function(e) { 1316 this.finishScrolling(); 1317 this.onMouseUp(e); 1318 }.aspxBind(this); 1319 this.mouseClickHandler = function(e){
1320 if(this.requirePreventScroll || (ASPx.IsExists(e.isTrusted) && !e.isTrusted)) 1321 return; 1322 var xDiff = this.firstX - Evt.GetEventX(e); 1323 var yDiff = this.firstY - Evt.GetEventY(e); 1324 if(xDiff > MouseScroller.MinimumOffset || yDiff > MouseScroller.MinimumOffset) 1325 return Evt.PreventEventAndBubble(e); 1326 }.aspxBind(this); 1327 this.finishScrolling = function() { 1328 Evt.DetachEventFromDocument(ASPx.TouchUIHelper.touchMouseMoveEventName, this.mouseMoveHandler); 1329 Evt.DetachEventFromDocument(ASPx.TouchUIHelper.touchMouseUpEventName, this.mouseUpHandler); 1330 this.scrollableTreeLine = []; 1331 this.prevIsTopDirection = null; 1332 mouseDownCounter--; 1333 }; 1334 }, 1335 GetScrollableElements: function() { 1336 if(!this.vertRecursive) return [ ]; 1337 var isHtmlScrollableElement = !ASPx.Browser.IsQuirksMode && !ASPx.Browser.Safari; 1338 var outerScrollableElementTag = isHtmlScrollableElement ? "HTML" : "BODY"; 1339 return ASPx.GetElementTreeLine(this.element, null, function(el) { return el == document; }) 1340 .filter(function(el) { 1341 var tagName = el.tagName; 1342 if(isHtmlScrollableElement && tagName == "BODY") 1343 return false; 1344 return ASPx.IsScrollableElement(el, false, true) || tagName == outerScrollableElementTag || el.dxScrollable; 1345 }.bind(this)); 1346 }, 1347 GetElementForVertScrolling: function(currentIsTop, prevIsTop, prevElement) { 1348 if(prevElement && currentIsTop === prevIsTop && this.GetVertScrollExcess(prevElement, currentIsTop) > 0) 1349 return prevElement; 1350 for(var i = 0; i < this.scrollableTreeLine.length; i++) { 1351 var element = this.scrollableTreeLine[i]; 1352 var excess = this.GetVertScrollExcess(element, currentIsTop); 1353 if(excess > 0) 1354 return element; 1355 } 1356 return null; 1357 }, 1358 GetVertScrollExcess: function(element, isTop) { 1359 if(isTop) 1360 return element.scrollTop; 1361 var isDocument = element.tagName == "HTML" || ASPx.Browser.Safari && !ASPx.Browser.IsQuirksMode && element.tagName == "BODY"; 1362 var clientHeight = isDocument ? ASPx.GetDocumentClientHeight() : element.clientHeight; 1363 return element.scrollHeight - clientHeight - element.scrollTop; 1364 } 1365}; 1366ASPx.MouseScroller = MouseScroller; 1367var Evt = { }; 1368Evt.GetEvent = function(evt){ 1369 return (typeof(event) != "undefined" && event != null && Browser.IE) ? event : evt; 1370}; 1371Evt.IsEventPrevented = function(evt) { 1372 return evt.defaultPrevented || evt.returnValue === false; 1373}; 1374Evt.PreventEvent = function(evt){ 1375 if(evt.preventDefault) { 1376 if(evt.cancelable) 1377 evt.preventDefault(); 1378 } 1379 else 1380 evt.returnValue = false; 1381 return false; 1382}; 1383Evt.PreventEventAndBubble = function(evt){ 1384 Evt.PreventEvent(evt); 1385 if(evt.stopPropagation) 1386 evt.stopPropagation(); 1387 evt.cancelBubble = true; 1388 return false; 1389}; 1390Evt.CancelBubble = function(evt){ 1391 evt.stopPropagation(); 1392 return false; 1393}; 1394Evt.PreventImageDragging = function(image) { 1395 if(image) 1396 image.ondragstart = function() { return false; }; 1397}; 1398Evt.PreventDragStart = function(evt) { 1399 evt = Evt.GetEvent(evt); 1400 var element = Evt.GetEventSource(evt); 1401 if(element.releaseCapture) 1402 element.releaseCapture(); 1403 return false; 1404}; 1405Evt.PreventElementDrag = function(element) { 1406 if(Browser.IE) 1407 Evt.AttachEventToElement(element, "dragstart", Evt.PreventEvent); 1408 else 1409 Evt.AttachEventToElement(element, "mousedown", Evt.PreventEvent); 1410}; 1411Evt.PreventElementDragAndSelect = function(element, skipMouseMove, skipIESelect){ 1412 if(Browser.WebKitFamily) 1413 Evt.AttachEventToElement(element, "selectstart", Evt.PreventEventAndBubble); 1414 if(Browser.IE){ 1415 if(!skipIESelect) 1416 Evt.AttachEventToElement(element, "selectstart", ASPx.FalseFunction); 1417 if(!skipMouseMove) 1418 Evt.AttachEventToElement(element, "mousemove", Selection.ClearOnMouseMove); 1419 Evt.AttachEventToElement(element, "dragstart", Evt.PreventDragStart); 1420 } 1421}; 1422Evt.GetEventSource = function(evt){ 1423 if(!ASPx.IsExists(evt)) return null; 1424 return evt.srcElement ? evt.srcElement : evt.target; 1425}; 1426Evt.GetKeyCode = function(srcEvt) { 1427 return Browser.NetscapeFamily || Browser.Opera ? srcEvt.which : srcEvt.keyCode; 1428}; 1429function clientEventRequiresDocScrollCorrection() { 1430 var isSafariVerLess3 = Browser.Safari && Browser.Version < 3, 1431 isMacOSMobileVerLess51 = Browser.MacOSMobilePlatform && Browser.Version < 5.1; 1432 return Browser.AndroidDefaultBrowser || Browser.AndroidChromeBrowser || !(isSafariVerLess3 || isMacOSMobileVerLess51); 1433} 1434Evt.GetEventX = function(evt){ 1435 if(ASPx.TouchUIHelper.isTouchEvent(evt)) 1436 return ASPx.TouchUIHelper.getEventX(evt); 1437 return evt.clientX + (clientEventRequiresDocScrollCorrection() ? ASPx.GetDocumentScrollLeft() : 0); 1438}; 1439Evt.GetEventY = function(evt){ 1440 if(ASPx.TouchUIHelper.isTouchEvent(evt)) 1441 return ASPx.TouchUIHelper.getEventY(evt); 1442 return evt.clientY + (clientEventRequiresDocScrollCorrection() ? ASPx.GetDocumentScrollTop() : 0 ); 1443};
1444Evt.IsLeftButtonPressed = function(evt) { 1445 if(ASPx.TouchUIHelper.isTouchEvent(evt)) 1446 return true; 1447 evt = Evt.GetEvent(evt); 1448 if(!evt) return false; 1449 if(Browser.IE && Browser.Version < 11) { 1450 if(Browser.MSTouchUI) 1451 return true; 1452 return evt.button % 2 == 1; 1453 } else if(Browser.WebKitFamily) { 1454 if(evt.type === "pointermove") 1455 return evt.buttons === 1; 1456 return evt.which == 1; 1457 } else if(Browser.NetscapeFamily || Browser.Edge || (Browser.IE && Browser.Version >= 11)) { 1458 if(evt.type === ASPx.TouchUIHelper.touchMouseMoveEventName) 1459 return evt.buttons === 1; 1460 return evt.which == 1; 1461 } else if(Browser.Opera) 1462 return evt.button == 0; 1463 return true; 1464}; 1465Evt.IsRightButtonPressed = function(evt){ 1466 evt = Evt.GetEvent(evt); 1467 if(!ASPx.IsExists(evt)) return false; 1468 if(Browser.IE || Browser.Edge) { 1469 if(evt.type === "pointermove") 1470 return evt.buttons === 2; 1471 return evt.button == 2; 1472 } 1473 else if(Browser.NetscapeFamily || Browser.WebKitFamily) 1474 return evt.which == 3; 1475 else if (Browser.Opera) 1476 return evt.button == 1; 1477 return true; 1478}; 1479Evt.GetWheelDelta = function(evt) { 1480 var ret; 1481 if(Browser.NetscapeFamily && Browser.MajorVersion < 17) 1482 ret = -evt.detail; 1483 else if(Browser.Safari) 1484 ret = evt.wheelDelta; 1485 else 1486 ret = -evt.deltaY; 1487 if(Browser.Opera && Browser.Version < 9) 1488 ret = -ret; 1489 return ret; 1490}; 1491Evt.IsWheelEventWithDirection = function(evt) { 1492 return ASPx.Data.ArrayContains(["wheel", "mousewheel"], evt.type); 1493}; 1494Evt.GetWheelDeltaX = function(evt) { 1495 if(evt.type === "wheel") 1496 return -evt.deltaX; 1497 if(evt.type === "mousewheel") 1498 return evt.wheelDeltaX; 1499}; 1500Evt.GetWheelDeltaY = function(evt) { 1501 if(evt.type === "wheel") 1502 return -evt.deltaY; 1503 if(evt.type === "mousewheel") 1504 return evt.wheelDeltaY; 1505}; 1506Evt.IsPassiveListenersSupported = function() { 1507 if(Browser.Chrome && Browser.MajorVersion > 69 || Browser.Edge && Browser.MajorVersion > 15 || Browser.Firefox && Browser.MajorVersion > 62) 1508 return true; 1509 if(Evt.isPassiveListenersSupported === undefined) { 1510 Evt.isPassiveListenersSupported = false; 1511 try { 1512 var options = Object.defineProperty({}, "passive", { get: function() { Evt.isPassiveListenersSupported = true; } }); 1513 window.addEventListener("test", options, options); 1514 window.removeEventListener("test", options, options); 1515 } 1516 catch(err) { Evt.isPassiveListenersSupported = false; } 1517 } 1518 return !!Evt.isPassiveListenersSupported; 1519}; 1520Evt.AttachEventToElement = function(element, eventName, func, onlyBubbling, passive) { 1521 if(element.addEventListener) 1522 element.addEventListener(eventName, func, Evt.IsPassiveListenersSupported() ? { capture: !onlyBubbling, passive: !!passive } : !onlyBubbling); 1523 else 1524 element.attachEvent("on" + eventName, func); 1525}; 1526Evt.DetachEventFromElement = function(element, eventName, func, onlyBubbling) { 1527 if(element.removeEventListener) 1528 element.removeEventListener(eventName, func, Evt.IsPassiveListenersSupported() ? { capture: !onlyBubbling } : !onlyBubbling); 1529 else 1530 element.detachEvent("on" + eventName, func); 1531}; 1532Evt.AttachEventToDocument = function(eventName, func) { 1533 var attachingAllowed = ASPx.TouchUIHelper.onEventAttachingToDocument(eventName, func); 1534 if(attachingAllowed) 1535 Evt.AttachEventToDocumentCore(eventName, func); 1536}; 1537Evt.AttachEventToDocumentCore = function(eventName, func) { 1538 Evt.AttachEventToElement(document, eventName, func); 1539}; 1540Evt.DetachEventFromDocument = function(eventName, func) { 1541 Evt.DetachEventFromDocumentCore(eventName, func); 1542 ASPx.TouchUIHelper.onEventDettachedFromDocument(eventName, func); 1543}; 1544Evt.DetachEventFromDocumentCore = function(eventName, func){ 1545 Evt.DetachEventFromElement(document, eventName, func); 1546}; 1547Evt.GetMouseWheelEventName = function() { 1548 if(Browser.Safari) 1549 return "mousewheel"; 1550 if(Browser.NetscapeFamily && Browser.MajorVersion < 17) 1551 return "DOMMouseScroll"; 1552 return "wheel"; 1553}; 1554Evt.AttachMouseEnterToElement = function (element, onMouseOverHandler, onMouseOutHandler) { 1555 Evt.AttachEventToElement(element, ASPx.TouchUIHelper.pointerEnabled ? ASPx.TouchUIHelper.pointerOverEventName : "mouseover", function (evt) { mouseEnterHandler(evt, element, onMouseOverHandler, onMouseOutHandler); }); 1556 Evt.AttachEventToElement(element, ASPx.TouchUIHelper.pointerEnabled ? ASPx.TouchUIHelper.pointerOutEventName : "mouseout", function (evt) { mouseEnterHandler(evt, element, onMouseOverHandler, onMouseOutHandler); }); 1557}; 1558Evt.GetEventRelatedTarget = function(evt, isMouseOverEvent) { 1559 return evt.relatedTarget || (isMouseOverEvent ? evt.srcElement : evt.toElement); 1560}; 1561function mouseEnterHandler(evt, element, onMouseOverHandler, onMouseOutHandler) { 1562 var isMouseOverExecuted = !!element.dxMouseOverExecuted; 1563 var isMouseOverEvent = (evt.type == "mouseover" || evt.type == ASPx.TouchUIHelper.pointerOverEventName); 1564 if(isMouseOverEvent && isMouseOverExecuted || !isMouseOverEvent && !isMouseOverExecuted) 1565 return; 1566 var source = Evt.GetEventRelatedTarget(evt, isMouseOverEvent); 1567 if(!ASPx.GetIsParent(element, source)) { 1568 element.dxMouseOverExecuted = isMouseOverEvent; 1569 if(isMouseOverEvent) 1570 onMouseOverHandler(element); 1571 else 1572 onMouseOutHandler(element); 1573 } 1574 else if(isMouseOverEvent && !isMouseOverExecuted) { 1575 element.dxMouseOverExecuted = true; 1576 onMouseOverHandler(element); 1577 } 1578} 1579Evt.DispatchEvent = function(target, eventName, canBubble, cancellable) { 1580 var event; 1581 if(Browser.IE && Browser.Version < 9) { 1582 eventName = "on" + eventName; 1583 if(eventName in target) { 1584 event = document.createEventObject(); 1585 target.fireEvent("on" + eventName, event); 1586 } 1587 } else { 1588 event = document.createEvent("Event"); 1589 event.initEvent(eventName, canBubble || false, cancellable || false); 1590 target.dispatchEvent(event); 1591 } 1592}; 1593Evt.EmulateDocumentOnMouseDown = function(evt) { 1594 Evt.EmulateOnMouseDown(document, evt); 1595};
1596Evt.EmulateOnMouseDown = function(element, evt) { 1597 if(Browser.IE && Browser.Version < 9) 1598 element.fireEvent("onmousedown", evt); 1599 else if(!Browser.WebKitFamily){ 1600 var emulatedEvt = document.createEvent("MouseEvents"); 1601 emulatedEvt.initMouseEvent("mousedown", true, true, window, 0, evt.screenX, evt.screenY, 1602 evt.clientX, evt.clientY, evt.ctrlKey, evt.altKey, evt.shiftKey, false, 0, null); 1603 element.dispatchEvent(emulatedEvt); 1604 } 1605}; 1606Evt.EmulateOnMouseEvent = function (type, element, evt) { 1607 evt.type = type; 1608 var emulatedEvt = document.createEvent("MouseEvents"); 1609 emulatedEvt.initMouseEvent(type, true, true, window, 0, evt.screenX, evt.screenY, 1610 evt.clientX, evt.clientY, evt.ctrlKey, evt.altKey, evt.shiftKey, false, 0, null); 1611 emulatedEvt.target = element; 1612 element.dispatchEvent(emulatedEvt); 1613}; 1614Evt.EmulateMouseClick = function (element, evt) { 1615 var x = ASPx.GetElementOffsetWidth(element) / 2; 1616 var y = ASPx.GetElementOffsetHeight(element) / 2; 1617 if (!evt) 1618 evt = { 1619 bubbles: true, 1620 cancelable: true, 1621 view: window, 1622 detail: 1, 1623 screenX: 0, 1624 screenY: 0, 1625 clientX: x, 1626 clientY: y, 1627 ctrlKey: false, 1628 altKey: false, 1629 shiftKey: false, 1630 metaKey: false, 1631 button: 0, 1632 relatedTarget: null 1633 }; 1634 Evt.EmulateOnMouseEvent("mousedown", element, evt); 1635 Evt.EmulateOnMouseEvent("mouseup", element, evt); 1636 Evt.EmulateOnMouseEvent("click", element, evt); 1637}; 1638Evt.DoElementClick = function(element) { 1639 try{ 1640 element.click(); 1641 } 1642 catch(e){ 1643 } 1644}; 1645Evt.IsActionKeyPressed = function(evt) { 1646 return evt.keyCode === ASPx.Key.Space || 1647 evt.keyCode === ASPx.Key.Enter || 1648 (evt.keyCode === ASPx.Key.Down && evt.altKey); 1649}; 1650Evt.InvokeMouseClickByKeyDown = function(evt, handler) { 1651 if(Evt.IsActionKeyPressed(evt)) { 1652 ASPx.Evt.PreventEvent(evt); 1653 if(!handler) 1654 ASPx.Evt.GetEventSource(evt).onclick(); 1655 else 1656 handler(evt); 1657 } 1658}; 1659Evt.AttachContextMenuToElement = function (element, handler, onlyBubbling) { 1660 if (ASPx.TouchUIHelper.useLongTapHelper()) 1661 element.detachContextMenuEventHandler = ASPx.TouchUIHelper.attachLongTapHandler(element, handler, onlyBubbling); 1662 else 1663 Evt.AttachEventToElement(element, "contextmenu", handler, onlyBubbling); 1664}; 1665Evt.DetachContextMenuFromElement = function (element, handler) { 1666 if (element.detachContextMenuEventHandler) 1667 element.detachContextMenuEventHandler(); 1668 else 1669 Evt.DetachEventFromElement(element, "contextmenu", handler); 1670}; 1671Evt.PreventContextMenuOnElement = function(element) { 1672 Evt.AttachContextMenuToElement(element, function(evt) { 1673 Evt.PreventEvent(evt); 1674 }); 1675}; 1676ASPx.Evt = Evt; 1677var Attr = { }; 1678Attr.GetAttribute = function(obj, attrName){ 1679 if(obj.getAttribute) 1680 return obj.getAttribute(attrName); 1681 else if(obj.getPropertyValue) { 1682 if(Browser.Firefox) { 1683 try { 1684 return obj.getPropertyValue(attrName); 1685 } catch(e) { 1686 return obj[attrName]; 1687 } 1688 } 1689 return obj.getPropertyValue(attrName); 1690 } 1691 return null; 1692}; 1693Attr.SetAttribute = function(obj, attrName, value){ 1694 if(obj.setAttribute) { 1695 if(isSourceResetRequired() && attrName.toLowerCase() === "src") 1696 obj.setAttribute(attrName, ""); 1697 obj.setAttribute(attrName, value); 1698 } else if(obj.setProperty) 1699 obj.setProperty(attrName, value, ""); 1700}; 1701Attr.ToggleAttribute = function(obj, attrName, value, condition) { 1702 if(condition) 1703 Attr.SetAttribute(obj, attrName, value); 1704 else 1705 Attr.RemoveAttribute(obj, attrName); 1706}; 1707Attr.RemoveAttribute = function(obj, attrName){ 1708 if(obj.removeAttribute) 1709 obj.removeAttribute(attrName); 1710 else if(obj.removeProperty) 1711 obj.removeProperty(attrName); 1712}; 1713Attr.IsExistsAttribute = function(obj, attrName){ 1714 var value = Attr.GetAttribute(obj, attrName); 1715 return (value != null) && (value !== ""); 1716}; 1717Attr.SetOrRemoveAttribute = function(obj, attrName, value) { 1718 if(!value) 1719 Attr.RemoveAttribute(obj, attrName); 1720 else 1721 Attr.SetAttribute(obj, attrName, value); 1722}; 1723Attr.SaveAttribute = function(obj, attrName, savedObj, savedAttrName){ 1724 if(!Attr.IsExistsAttribute(savedObj, savedAttrName)){ 1725 var oldValue = Attr.IsExistsAttribute(obj, attrName) ? Attr.GetAttribute(obj, attrName) : ASPx.EmptyObject; 1726 Attr.SetAttribute(savedObj, savedAttrName, oldValue); 1727 } 1728}; 1729Attr.SaveStyleAttribute = function(obj, attrName){ 1730 Attr.SaveAttribute(obj.style, attrName, obj, "saved" + attrName); 1731}; 1732Attr.ChangeAttributeExtended = function(obj, attrName, savedObj, savedAttrName, newValue){ 1733 Attr.SaveAttribute(obj, attrName, savedObj, savedAttrName); 1734 Attr.SetAttribute(obj, attrName, newValue); 1735}; 1736Attr.ChangeAttribute = function(obj, attrName, newValue){ 1737 Attr.ChangeAttributeExtended(obj, attrName, obj, "saved" + attrName, newValue); 1738}; 1739Attr.ChangeStyleAttribute = function(obj, attrName, newValue){ 1740 Attr.ChangeAttributeExtended(obj.style, attrName, obj, "saved" + attrName, newValue); 1741}; 1742Attr.ResetAttributeExtended = function(obj, attrName, savedObj, savedAttrName){ 1743 Attr.SaveAttribute(obj, attrName, savedObj, savedAttrName); 1744 Attr.SetAttribute(obj, attrName, ""); 1745 Attr.RemoveAttribute(obj, attrName); 1746}; 1747Attr.ResetAttribute = function(obj, attrName){ 1748 Attr.ResetAttributeExtended(obj, attrName, obj, "saved" + attrName); 1749}; 1750Attr.ResetStyleAttribute = function(obj, attrName){ 1751 Attr.ResetAttributeExtended(obj.style, attrName, obj, "saved" + attrName); 1752}; 1753Attr.RestoreAttributeExtended = function(obj, attrName, savedObj, savedAttrName){ 1754 if(Attr.IsExistsAttribute(savedObj, savedAttrName)){ 1755 var oldValue = Attr.GetAttribute(savedObj, savedAttrName); 1756 if(oldValue != ASPx.EmptyObject) 1757 Attr.SetAttribute(obj, attrName, oldValue); 1758 else 1759 Attr.RemoveAttribute(obj, attrName); 1760 Attr.RemoveAttribute(savedObj, savedAttrName); 1761 return true; 1762 } 1763 return false; 1764}; 1765Attr.RestoreAttribute = function(obj, attrName){ 1766 return Attr.RestoreAttributeExtended(obj, attrName, obj, "saved" + attrName); 1767}; 1768Attr.RestoreStyleAttribute = function(obj, attrName){ 1769 return Attr.RestoreAttributeExtended(obj.style, attrName, obj, "saved" + attrName); 1770}; 1771Attr.CopyAllAttributes = function(sourceElem, destElement) { 1772 var attrs = sourceElem.attributes; 1773 for(var n = 0; n < attrs.length; n++) { 1774 var attr = attrs[n]; 1775 if(attr.specified) { 1776 var attrName = attr.nodeName; 1777 var attrValue = sourceElem.getAttribute(attrName, 2); 1778 if(attrValue == null) 1779 attrValue = attr.nodeValue; 1780 destElement.setAttribute(attrName, attrValue, 0); 1781 } 1782 } 1783 if(sourceElem.style.cssText !== '') 1784 destElement.style.cssText = sourceElem.style.cssText; 1785}; 1786Attr.RemoveAllAttributes = function(element, excludedAttributes) { 1787 var excludedAttributesHashTable = {}; 1788 if(excludedAttributes) 1789 excludedAttributesHashTable = Data.CreateHashTableFromArray(excludedAttributes); 1790 if(element.attributes) { 1791 var attrArray = element.attributes; 1792 for(var i = 0; i < attrArray.length; i++) { 1793 var attrName = attrArray[i].name; 1794 if(!ASPx.IsExists(excludedAttributesHashTable[attrName.toLowerCase()])) { 1795 try { 1796 attrArray.removeNamedItem(attrName); 1797 } catch (e) { } 1798 } 1799 } 1800 } 1801}; 1802Attr.RemoveStyleAttribute = function(element, attrName) { 1803 if(element.style) { 1804 if(Browser.Firefox && element.style[attrName]) 1805 element.style[attrName] = ""; 1806 if(element.style.removeAttribute && element.style.removeAttribute != "") 1807 element.style.removeAttribute(attrName); 1808 else if(element.style.removeProperty && element.style.removeProperty != "") 1809 element.style.removeProperty(attrName); 1810 } 1811}; 1812Attr.RemoveAllStyles = function(element) { 1813 if(element.style) { 1814 for(var key in element.style) 1815 Attr.RemoveStyleAttribute(element, key); 1816 Attr.RemoveAttribute(element, "style"); 1817 } 1818}; 1819Attr.GetTabIndexAttributeName = function(){ 1820 return Browser.IE ? "tabIndex" : "tabindex"; 1821}; 1822Attr.ChangeTabIndexAttribute = function(element){ 1823 var attribute = Attr.GetTabIndexAttributeName(); 1824 if(Attr.GetAttribute(element, attribute) != -1) 1825 Attr.ChangeAttribute(element, attribute, -1); 1826}; 1827Attr.SaveTabIndexAttributeAndReset = function(element) { 1828 var attribute = Attr.GetTabIndexAttributeName(); 1829 Attr.SaveAttribute(element, attribute, element, "saved" + attribute); 1830 Attr.SetAttribute(element, attribute, -1); 1831}; 1832Attr.RestoreTabIndexAttribute = function(element){ 1833 var attribute = Attr.GetTabIndexAttributeName(); 1834 if(Attr.IsExistsAttribute(element, attribute)) { 1835 if(Attr.GetAttribute(element, attribute) == -1) { 1836 if(Attr.IsExistsAttribute(element, "saved" + attribute)){ 1837 var oldValue = Attr.GetAttribute(element, "saved" + attribute); 1838 if(oldValue != ASPx.EmptyObject) 1839 Attr.SetAttribute(element, attribute, oldValue); 1840 else { 1841 if(Browser.WebKitFamily) 1842 Attr.SetAttribute(element, attribute, 0); 1843 Attr.RemoveAttribute(element, attribute); 1844 } 1845 Attr.RemoveAttribute(element, "saved" + attribute); 1846 } 1847 } 1848 } 1849}; 1850Attr.ChangeAttributesMethod = function(enabled){ 1851 return enabled ? Attr.RestoreAttribute : Attr.ResetAttribute; 1852}; 1853Attr.InitiallyChangeAttributesMethod = function(enabled){ 1854 return enabled ? Attr.ChangeAttribute : Attr.ResetAttribute; 1855}; 1856Attr.ChangeStyleAttributesMethod = function(enabled){ 1857 return enabled ? Attr.RestoreStyleAttribute : Attr.ResetStyleAttribute; 1858}; 1859Attr.InitiallyChangeStyleAttributesMethod = function(enabled){ 1860 return enabled ? Attr.ChangeStyleAttribute : Attr.ResetStyleAttribute; 1861}; 1862Attr.ChangeEventsMethod = function(enabled){ 1863 return enabled ? Evt.AttachEventToElement : Evt.DetachEventFromElement; 1864}; 1865Attr.ChangeDocumentEventsMethod = function(enabled){ 1866 return enabled ? Evt.AttachEventToDocument : Evt.DetachEventFromDocument; 1867}; 1868Attr.ChangeCellSpanCount = function(cell, value, isColumnSpan) { 1869 if(!cell) return; 1870 var propertyKey = isColumnSpan ? "colSpan" : "rowSpan"; 1871 var prevValue = cell[propertyKey]; 1872 if(value > 1) 1873 cell[propertyKey] = value; 1874 else if(prevValue !== 1) 1875 Attr.RemoveAttribute(cell, propertyKey); 1876}; 1877function isSourceResetRequired() { 1878 return Browser.IE && Browser.MajorVersion >= 11; 1879} 1880Attr.AppendScriptType = function(script) { 1881 if(!isHtml5Mode()) 1882 script.type = "text/javascript"; 1883}; 1884Attr.AppendStyleType = function(style) { 1885 if(!isHtml5Mode()) 1886 style.type = "text/css"; 1887}; 1888function isHtml5Mode() { 1889 return ASPx.DoctypeMode === "Html5"; 1890} 1891ASPx.Attr = Attr; 1892var Aria = { 1893 atomic: "aria-atomic", 1894 checked: "aria-checked", 1895 descendant: "aria-activedescendant", 1896 described: "aria-describedby", 1897 disabled: "aria-disabled", 1898 expanded: "aria-expanded", 1899 haspopup: "aria-haspopup", 1900 invalid: "aria-invalid", 1901 label: "aria-label", 1902 labelled: "aria-labelledby", 1903 level: "aria-level", 1904 owns: "aria-owns", 1905 posinset: "aria-posinset", 1906 role: "role", 1907 selected: "aria-selected", 1908 setsize: "aria-setsize", 1909 valuemax: "aria-valuemax", 1910 valuemin: "aria-valuemin", 1911 valuenow: "aria-valuenow" 1912}; 1913Aria.SetOrRemoveDescendant = function(obj, value) { 1914 ASPx.Attr.SetOrRemoveAttribute(obj, Aria.descendant, value); 1915}; 1916Aria.SetOrRemoveLabel = function(obj, value) { 1917 ASPx.Attr.SetOrRemoveAttribute(obj, Aria.label, value); 1918}; 1919Aria.SetOrRemoveDisabled = function(obj, value) { 1920 ASPx.Attr.SetOrRemoveAttribute(obj, Aria.disabled, value); 1921}; 1922Aria.AppendLabel = function(obj, value, checkExists) { 1923 var currentValue = ASPx.Attr.GetAttribute(obj, Aria.label) || ""; 1924 var resultParts = [ ]; 1925 if(currentValue) 1926 resultParts.push(currentValue); 1927 var needAppendValue = value && (!checkExists || currentValue.indexOf(value) == -1); 1928 if(needAppendValue) 1929 resultParts.push(value); 1930 ASPx.Attr.SetAttribute(obj, Aria.label, resultParts.join(" ")); 1931}; 1932Aria.SetOrRemoveLabelled = function(obj, value) { 1933 ASPx.Attr.SetOrRemoveAttribute(obj, Aria.labelled, value); 1934}; 1935Aria.SetApplicationRole = function(obj) { 1936 ASPx.Attr.SetAttribute(obj, Aria.role, "application"); 1937}; 1938Aria.SetSilence = function(obj) { 1939 ASPx.Attr.SetAttribute(obj, Aria.label, ";"); 1940};
1941Aria.SetExpanded = function(obj, expanded) { 1942 if(!obj || !ASPx.Attr.GetAttribute(obj, Aria.expanded)) return; 1943 Aria.SetBoolAttribute(obj, Aria.expanded, expanded); 1944}; 1945Aria.SetAtomic = function(obj, value) { 1946 Aria.SetBoolAttribute(obj, Aria.atomic, value); 1947}; 1948Aria.SetBoolAttribute = function(obj, attribute, value) { 1949 if(value) 1950 ASPx.Attr.SetAttribute(obj, attribute, true); 1951 else 1952 ASPx.Attr.SetAttribute(obj, attribute, false); 1953}; 1954ASPx.Attr.Aria = Aria; 1955var Color = { }; 1956function _aspxToHex(d) { 1957 return (d < 16) ? ("0" + d.toString(16)) : d.toString(16); 1958} 1959Color.RGBRegexp = /rgb\s*\(\s*([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\s*\)/; 1960Color.RGBARegexp = /rgba?\s*\(\s*([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\s*,?\s*([0-9]*\.?[0-9]*)\s*\)/; 1961Color.ColorToHexadecimal = function(colorValue, isRGBA) { 1962 if(typeof(colorValue) == "number") { 1963 var r = colorValue & 0xFF; 1964 var g = (colorValue >> 8) & 0xFF; 1965 var b = (colorValue >> 16) & 0xFF; 1966 return "#" + _aspxToHex(r) + _aspxToHex(g) + _aspxToHex(b); 1967 } 1968 if(colorValue && (colorValue.substr(0, 3).toLowerCase() == "rgb")) { 1969 var regResult = colorValue.toLowerCase().match(isRGBA ? Color.RGBARegexp : Color.RGBRegexp); 1970 if(regResult) { 1971 var r = parseInt(regResult[1]); 1972 var g = parseInt(regResult[2]); 1973 var b = parseInt(regResult[3]); 1974 if (isRGBA) 1975 return { r: r, g: g, b: b, a: regResult[4] !== undefined ? parseFloat(regResult[4]) : 1 }; 1976 return "#" + _aspxToHex(r) + _aspxToHex(g) + _aspxToHex(b); 1977 } 1978 return null; 1979 } 1980 if(colorValue && (colorValue.charAt(0) == "#")) 1981 return colorValue; 1982 return null; 1983}; 1984Color.Names = { 1985 AddColorNames: function(stringResourcesObj) { 1986 if(stringResourcesObj) { 1987 for(var key in stringResourcesObj) 1988 if(stringResourcesObj.hasOwnProperty(key)) 1989 this[key] = stringResourcesObj[key]; 1990 } 1991 } 1992}; 1993ASPx.Color = Color; 1994var Url = { }; 1995Url.Navigate = function(url, target) { 1996 var javascriptPrefix = "javascript:"; 1997 if(!url || url === "") 1998 return; 1999 else if(url.indexOf(javascriptPrefix) != -1) 2000 eval(url.substr(javascriptPrefix.length)); 2001 else { 2002 try{ 2003 if(target != "") 2004 navigateTo(url, target); 2005 else 2006 location.href = url; 2007 } 2008 catch(e){ 2009 } 2010 } 2011}; 2012Url.NavigateByLink = function(linkElement) { 2013 Url.Navigate(Attr.GetAttribute(linkElement, "href"), linkElement.target); 2014}; 2015Url.GetAbsoluteUrl = function(url) { 2016 if(url) 2017 url = Url.getURLObject(url).href; 2018 return url; 2019}; 2020Url.Redirect = function(url) { 2021 if(!ASPx.Browser.IE) 2022 window.location.href = url; 2023 else { 2024 var fakeLink = document.createElement("a"); 2025 fakeLink.href = url; 2026 document.body.appendChild(fakeLink); 2027 try { fakeLink.click(); } catch(e) { } 2028 } 2029}; 2030var absolutePathPrefixes = 2031 [ "about:", "file:///", "ftp://", "gopher://", "http://", "https://", "javascript:", "mailto:", "news:", "res://", "telnet://", "view-source:" ]; 2032Url.isAbsoluteUrl = function(url) { 2033 if (url) { 2034 for (var i = 0; i < absolutePathPrefixes.length; i++) { 2035 if(url.indexOf(absolutePathPrefixes[i]) == 0) 2036 return true; 2037 } 2038 } 2039 return false; 2040}; 2041Url.getURLObject = function(url) { 2042 var link = document.createElement('A'); 2043 link.href = url || ""; 2044 return { 2045 href: link.href, 2046 protocol: link.protocol, 2047 host: link.host, 2048 port: link.port, 2049 pathname: link.pathname, 2050 search: link.search, 2051 hash: link.hash 2052 }; 2053}; 2054Url.getRootRelativeUrl = function(url) { 2055 return getRelativeUrl(url, !Url.isRootRelativeUrl(url), true); 2056}; 2057Url.getPathRelativeUrl = function(url) { 2058 return getRelativeUrl(url, !Url.isPathRelativeUrl(url), false); 2059}; 2060function getRelativeUrl(url, isValid, isRootRelative) { 2061 if(url && !(/data:([^;]+\/?[^;]*)(;charset=[^;]*)?(;base64,)/.test(url)) && isValid) { 2062 var urlObject = Url.getURLObject(url); 2063 var baseUrlObject = Url.getURLObject(); 2064 if(!Url.isAbsoluteUrl(url) || urlObject.host === baseUrlObject.host && urlObject.protocol === baseUrlObject.protocol) { 2065 url = urlObject.pathname; 2066 if(!isRootRelative) 2067 url = getPathRelativeUrl(baseUrlObject.pathname, url); 2068 url = url + urlObject.search + urlObject.hash; 2069 } 2070 } 2071 return url; 2072} 2073function getPathRelativeUrl(baseUrl, url) { 2074 var requestSegments = getSegments(baseUrl, false); 2075 var urlSegments = getSegments(url, true); 2076 return buildPathRelativeUrl(requestSegments, urlSegments, 0, 0, ""); 2077} 2078function getSegments(url, addTail) { 2079 var segments = []; 2080 var startIndex = 0; 2081 var endIndex = -1; 2082 while ((endIndex = url.indexOf("/", startIndex)) != -1) { 2083 segments.push(url.substring(startIndex, ++endIndex)); 2084 startIndex = endIndex; 2085 } 2086 if(addTail && startIndex < url.length) 2087 segments.push(url.substring(startIndex, url.length)); 2088 return segments; 2089} 2090function buildPathRelativeUrl(requestSegments, urlSegments, reqIndex, urlIndex, buffer) { 2091 if(urlIndex >= urlSegments.length) 2092 return buffer; 2093 if(reqIndex >= requestSegments.length) 2094 return buildPathRelativeUrl(requestSegments, urlSegments, reqIndex, urlIndex + 1, buffer + urlSegments[urlIndex]); 2095 if(requestSegments[reqIndex] === urlSegments[urlIndex] && urlIndex === reqIndex) 2096 return buildPathRelativeUrl(requestSegments, urlSegments, reqIndex + 1, urlIndex + 1, buffer); 2097 return buildPathRelativeUrl(requestSegments, urlSegments, reqIndex + 1, urlIndex, buffer + "../"); 2098} 2099Url.isPathRelativeUrl = function(url) { 2100 return !!url && !Url.isAbsoluteUrl(url) && url.indexOf("/") != 0; 2101}; 2102Url.isRootRelativeUrl = function(url) { 2103 return !!url && !Url.isAbsoluteUrl(url) && url.indexOf("/") == 0 && url.indexOf("//") != 0; 2104}; 2105function navigateTo(url, target) { 2106 var lowerCaseTarget = target.toLowerCase(); 2107 if("_top" == lowerCaseTarget) 2108 top.location.href = url; 2109 else if("_self" == lowerCaseTarget) 2110 location.href = url; 2111 else if("_search" == lowerCaseTarget) 2112 openInNewWindow(url); 2113 else if("_media" == lowerCaseTarget) 2114 openInNewWindow(url); 2115 else if("_parent" == lowerCaseTarget) 2116 window.parent.location.href = url; 2117 else if("_blank" == lowerCaseTarget) 2118 openInNewWindow(url); 2119 else { 2120 var frame = getFrame(top.frames, target); 2121 if(frame != null) 2122 frame.location.href = url; 2123 else 2124 openInNewWindow(url); 2125 } 2126} 2127function openInNewWindow(url) { 2128 if(ASPx.Browser.Safari) 2129 openInNewWindowViaIframe(url); 2130 else { 2131 var newWindow = window.open(); 2132 newWindow.opener = null; 2133 newWindow.location = url; 2134 } 2135} 2136function openInNewWindowViaIframe(url) { 2137 var iframe = document.createElement('iframe');
2138 iframe.style.display = 'none'; 2139 document.body.appendChild(iframe); 2140 var iframeDoc = iframe.contentDocument || iframe.contentWindow.document; 2141 var openArgs = '"' + url + '"'; 2142 var script = iframeDoc.createElement('script'); 2143 script.type = 'text/javascript'; 2144 script.text = 'window.parent = null; ' + 2145 'window.top = null;' + 2146 'window.frameElement = null;' + 2147 'var child = window.open(' + openArgs + ');' + 2148 'child.opener = null'; 2149 iframeDoc.body.appendChild(script); 2150 document.body.removeChild(iframe); 2151} 2152ASPx.Url = Url; 2153var Json = { }; 2154function isValid(JsonString) { 2155 return !(/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test(JsonString.replace(/"(\\.|[^"\\])*"/g, ''))); 2156} 2157Json.Eval = function(jsonString, controlName) { 2158 if(isValid(jsonString)) 2159 return eval("(" + jsonString + ")"); 2160 else 2161 throw new Error(controlName + " received incorrect JSON-data: " + jsonString); 2162}; 2163Json.ToJson = function(param, skipEncodeHtml){ 2164 var paramType = typeof(param); 2165 if((paramType == "undefined") || (param == null)) 2166 return null; 2167 if((paramType == "object") && (typeof(param.__toJson) == "function")) 2168 return param.__toJson(); 2169 if((paramType == "number") || (paramType == "boolean")) 2170 return param; 2171 if(param.constructor == Date) 2172 return dateToJson(param); 2173 if(paramType == "string") { 2174 var result = param.replace(/\\/g, "\\\\"); 2175 result = result.replace(/"/g, "\\\""); 2176 result = result.replace(/\n/g, "\\n"); 2177 result = result.replace(/\r/g, "\\r"); 2178 if(!skipEncodeHtml) { 2179 result = result.replace(/</g, "\\u003c"); 2180 result = result.replace(/>/g, "\\u003e"); 2181 } 2182 return "\"" + result + "\""; 2183 } 2184 if(param.constructor == Array){ 2185 var values = []; 2186 for(var i = 0; i < param.length; i++) { 2187 var jsonValue = Json.ToJson(param[i], skipEncodeHtml); 2188 if(jsonValue === null) 2189 jsonValue = "null"; 2190 values.push(jsonValue); 2191 } 2192 return "[" + values.join(",") + "]"; 2193 } 2194 var exceptKeys = {}; 2195 if(ASPx.Ident.IsArray(param.__toJsonExceptKeys)) 2196 exceptKeys = Data.CreateHashTableFromArray(param.__toJsonExceptKeys); 2197 exceptKeys["__toJsonExceptKeys"] = 1; 2198 var values = []; 2199 for(var key in param) { 2200 if(param.hasOwnProperty(key)) { 2201 if(ASPx.IsFunction(param[key])) 2202 continue; 2203 if(exceptKeys[key] == 1) 2204 continue; 2205 values.push(Json.ToJson(key) + ":" + Json.ToJson(param[key], skipEncodeHtml)); 2206 } 2207 } 2208 return "{" + values.join(",") + "}"; 2209}; 2210function dateToJson(date) { 2211 var result = [ 2212 date.getFullYear(), 2213 date.getMonth(), 2214 date.getDate() 2215 ]; 2216 var time = { 2217 h: date.getHours(), 2218 m: date.getMinutes(), 2219 s: date.getSeconds(), 2220 ms: date.getMilliseconds() 2221 }; 2222 if(time.h || time.m || time.s || time.ms) 2223 result.push(time.h); 2224 if(time.m || time.s || time.ms) 2225 result.push(time.m); 2226 if(time.s || time.ms) 2227 result.push(time.s); 2228 if(time.ms) 2229 result.push(time.ms); 2230 return "new Date(" + result.join() + ")"; 2231} 2232ASPx.Json = Json; 2233ASPx.CreateClass = function(parentClass, properties) { 2234 if(arguments.length == 1) { 2235 properties = parentClass; 2236 parentClass = null; 2237 } 2238 var ret = function() { 2239 if(ret.preparing) 2240 return delete(ret.preparing); 2241 if(ret.constr) { 2242 this.constructor = ret; 2243 ret.constr.apply(this, arguments); 2244 } 2245 }; 2246 ret.prototype = {}; 2247 if(parentClass) { 2248 parentClass.preparing = true; 2249 for(var name in parentClass) { 2250 if(parentClass.hasOwnProperty(name) && name != 'constr' && ASPx.IsFunction(parentClass[name]) && !ret[name]) 2251 ret[name] = parentClass[name].aspxBind(parentClass); 2252 } 2253 ret.prototype = new parentClass; 2254 ret.prototype.constructor = parentClass; 2255 ret.constr = parentClass; 2256 } 2257 if(properties) { 2258 var constructorName = "constructor"; 2259 for(var name in properties) { 2260 if(!properties.hasOwnProperty(name)) 2261 continue; 2262 var getter = Object.getOwnPropertyDescriptor(properties, name).get; 2263 var setter = Object.getOwnPropertyDescriptor(properties, name).set; 2264 if(getter || setter) 2265 Object.defineProperty(ret.prototype, name, { 2266 set: setter, 2267 get: getter, 2268 enumerable: true, 2269 configurable: true 2270 });
2271 if(name != constructorName && !getter && !setter) 2272 ret.prototype[name] = properties[name]; 2273 } 2274 if(properties[constructorName] && properties[constructorName] != Object) 2275 ret.constr = properties[constructorName]; 2276 } 2277 return ret; 2278}; 2279var registeredMixins = {}; 2280ASPx.GetMixin = function (name, baseClass) { 2281 var mixinCache = baseClass._mixins || (baseClass._mixins = {}); 2282 var resultClass = mixinCache[name]; 2283 if (!resultClass) { 2284 var mixinCodeBuilder = registeredMixins[name]; 2285 if (!mixinCodeBuilder) 2286 throw new Error("mixin with the '" + name + "' is not registered"); 2287 var mixinCode = mixinCodeBuilder(baseClass); 2288 mixinCode.mixinName = name; 2289 resultClass = ASPx.CreateClass(baseClass, mixinCode); 2290 mixinCache[name] = resultClass; 2291 } 2292 return resultClass; 2293}; 2294ASPx.RegisterMixin = function() { 2295 var name = arguments.length == 1 ? "mixin_" + ASPx.CreateGuid() : arguments[0]; 2296 var mixinCodeBuilder = arguments[arguments.length - 1]; 2297 if (registeredMixins[name]) 2298 throw new Error("mixin with the '" + name + "' name is already defined"); 2299 registeredMixins[name] = mixinCodeBuilder; 2300 return function(baseClass) { return ASPx.GetMixin(name, baseClass); }; 2301}; 2302ASPx.FormatCallbackArg = function(prefix, arg) { 2303 if(prefix == null && arg == null) 2304 return ""; 2305 if(prefix == null) prefix = ""; 2306 if(arg == null) arg = ""; 2307 if(arg != null && !ASPx.IsExists(arg.length) && ASPx.IsExists(arg.value)) 2308 arg = arg.value; 2309 arg = arg.toString(); 2310 return [prefix, '|', arg.length, '|' , arg].join(''); 2311}; 2312ASPx.FormatCallbackArgs = function(callbackData) { 2313 var sb = [ ]; 2314 for(var i = 0; i < callbackData.length; i++) 2315 sb.push(ASPx.FormatCallbackArg(callbackData[i][0], callbackData[i][1])); 2316 return sb.join(""); 2317}; 2318ASPx.ParseShortcutString = function(shortcutString) { 2319 if(!shortcutString) 2320 return 0; 2321 var isCtrlKey = false; 2322 var isShiftKey = false; 2323 var isAltKey = false; 2324 var isMetaKey = false; 2325 var keyCode = null; 2326 var shcKeys = shortcutString.toString().split("+"); 2327 if(shcKeys.length > 0) { 2328 for(var i = 0; i < shcKeys.length; i++) { 2329 var key = Str.Trim(shcKeys[i].toUpperCase()); 2330 switch (key) { 2331 case "CONTROL": 2332 case "CONTROLKEY": 2333 case "CTRL": 2334 isCtrlKey = true; 2335 break; 2336 case "SHIFT": 2337 case "SHIFTKEY": 2338 isShiftKey = true; 2339 break; 2340 case "ALT": 2341 isAltKey = true; 2342 break; 2343 case "CMD": 2344 isMetaKey = true; 2345 break; 2346 case "F1": keyCode = ASPx.Key.F1; break; 2347 case "F2": keyCode = ASPx.Key.F2; break; 2348 case "F3": keyCode = ASPx.Key.F3; break; 2349 case "F4": keyCode = ASPx.Key.F4; break; 2350 case "F5": keyCode = ASPx.Key.F5; break; 2351 case "F6": keyCode = ASPx.Key.F6; break; 2352 case "F7": keyCode = ASPx.Key.F7; break; 2353 case "F8": keyCode = ASPx.Key.F8; break; 2354 case "F9": keyCode = ASPx.Key.F9; break; 2355 case "F10": keyCode = ASPx.Key.F10; break; 2356 case "F11": keyCode = ASPx.Key.F11; break; 2357 case "F12": keyCode = ASPx.Key.F12; break; 2358 case "RETURN": 2359 case "ENTER": keyCode = ASPx.Key.Enter; break; 2360 case "HOME": keyCode = ASPx.Key.Home; break; 2361 case "END": keyCode = ASPx.Key.End; break; 2362 case "LEFT": keyCode = ASPx.Key.Left; break; 2363 case "RIGHT": keyCode = ASPx.Key.Right; break; 2364 case "UP": keyCode = ASPx.Key.Up; break; 2365 case "DOWN": keyCode = ASPx.Key.Down; break; 2366 case "PAGEUP": keyCode = ASPx.Key.PageUp; break; 2367 case "PAGEDOWN": keyCode = ASPx.Key.PageDown; break; 2368 case "SPACE": keyCode = ASPx.Key.Space; break; 2369 case "TAB": keyCode = ASPx.Key.Tab; break; 2370 case "BACKSPACE": 2371 case "BACK": keyCode = ASPx.Key.Backspace; break; 2372 case "CONTEXT": keyCode = ASPx.Key.ContextMenu; break; 2373 case "ESCAPE": 2374 case "ESC": 2375 keyCode = ASPx.Key.Esc; 2376 break; 2377 case "DELETE": 2378 case "DEL": 2379 keyCode = ASPx.Key.Delete; 2380 break; 2381 case "INSERT": 2382 case "INS": 2383 keyCode = ASPx.Key.Insert; 2384 break; 2385 case "PLUS": 2386 keyCode = "+".charCodeAt(0); 2387 break; 2388 default: 2389 keyCode = key.charCodeAt(0); 2390 break; 2391 } 2392 } 2393 } else 2394 ASPx.ShowErrorAlert("Invalid shortcut"); 2395 return ASPx.GetShortcutCode(keyCode, isCtrlKey, isShiftKey, isAltKey, isMetaKey); 2396}; 2397ASPx.GetShortcutCode = function(keyCode, isCtrlKey, isShiftKey, isAltKey, isMetaKey) { 2398 var value = keyCode; 2399 value |= isCtrlKey ? ASPx.ModifierKey.Ctrl : 0; 2400 value |= isShiftKey ? ASPx.ModifierKey.Shift : 0; 2401 value |= isAltKey ? ASPx.ModifierKey.Alt : 0; 2402 value |= isMetaKey ? ASPx.ModifierKey.Meta : 0; 2403 return value; 2404}; 2405ASPx.GetShortcutCodeByEvent = function(evt) { 2406 return ASPx.GetShortcutCode(Evt.GetKeyCode(evt), evt.ctrlKey, evt.shiftKey, evt.altKey, ASPx.Browser.MacOSPlatform ? evt.metaKey : false); 2407};
2408ASPx.IsPasteShortcut = function(evt) { 2409 if(evt.type === "paste") 2410 return true; 2411 var keyCode = Evt.GetKeyCode(evt); 2412 if(Browser.NetscapeFamily && evt.which == 0) 2413 keyCode = evt.keyCode; 2414 return (evt.ctrlKey && (keyCode == 118 || (keyCode == 86))) || 2415 (evt.shiftKey && !evt.ctrlKey && !evt.altKey && 2416 (keyCode == ASPx.Key.Insert)) ; 2417}; 2418var NotPrintableKeyCodes = null; 2419ASPx.IsPrintableKey = function(keyCode) { 2420 if (!NotPrintableKeyCodes) 2421 NotPrintableKeyCodes = Object.keys(ASPx.Key).map(function(key) { return ASPx.Key[key]; }); 2422 return !ASPx.Data.ArrayContains(NotPrintableKeyCodes, keyCode); 2423}; 2424ASPx.SetFocus = function(element, selectAction) { 2425 function focusCore(element, selectAction){ 2426 try { 2427 element.focus(); 2428 if(Browser.IE && document.activeElement != element) 2429 element.focus(); 2430 if(selectAction) { 2431 var currentSelection = Selection.GetInfo(element); 2432 if(currentSelection.startPos == currentSelection.endPos) { 2433 switch(selectAction) { 2434 case "start": 2435 Selection.SetCaretPosition(element, 0); 2436 break; 2437 case "all": 2438 Selection.Set(element); 2439 break; 2440 } 2441 } 2442 } 2443 } catch (e) { 2444 } 2445 } 2446 if(ASPxClientUtils.iOSPlatform) 2447 focusCore(element, selectAction); 2448 else { 2449 window.setTimeout(function() { 2450 focusCore(element, selectAction); 2451 }, 100); 2452 } 2453}; 2454ASPx.IsFocusableCore = function(element, skipContainerVisibilityCheck) { 2455 var current = element; 2456 while(current && current.nodeType == 1) { 2457 if(current == element || !skipContainerVisibilityCheck(current)) { 2458 var tagName = current.tagName.toUpperCase(); 2459 if(tagName == "BODY") 2460 return true; 2461 var disabledElementTags = ["INPUT", "BUTTON", "TEXTAREA", "SELECT", "OPTION"]; 2462 if(disabledElementTags.indexOf(tagName) !== -1 && current.disabled || !ASPx.GetElementDisplay(current) || !ASPx.GetElementVisibility(current)) 2463 return false; 2464 } 2465 current = current.parentNode; 2466 } 2467 return true; 2468}; 2469ASPx.IsFocusable = function(element) { 2470 return ASPx.IsFocusableCore(element, ASPx.FalseFunction); 2471}; 2472var ActionElementsCache = ASPx.CreateClass(null, { 2473 constructor: function() { 2474 this.usageCounter = 0; 2475 this.elements = [ ]; 2476 this.values = [ ]; 2477 }, 2478 IsActive: function() { return this.usageCounter > 0; }, 2479 BeginUsage: function() { 2480 this.usageCounter++; 2481 }, 2482 EndUsage: function() { 2483 this.usageCounter--; 2484 if(this.usageCounter === 0) 2485 this.Clear(); 2486 }, 2487 Add: function(element, value) { 2488 var index = this.elements.length; 2489 this.elements[index] = element; 2490 this.values[index] = value; 2491 }, 2492 Get: function(element) { 2493 var index = this.elements.indexOf(element); 2494 var hasValue = index > -1; 2495 var value = hasValue ? this.values[index] : undefined; 2496 return { hasValue: hasValue, value: value }; 2497 }, 2498 Clear: function() { 2499 this.elements = [ ]; 2500 this.values = [ ]; 2501 } 2502}); 2503ASPx.ActionElementsCache = new ActionElementsCache(); 2504ASPx.IsActionElement = function(element) { 2505 if(!ASPx.IsExistsElement(element)) 2506 return false; 2507 var useCache = ASPx.ActionElementsCache.IsActive(); 2508 if(useCache) { 2509 var cacheValue = ASPx.ActionElementsCache.Get(element); 2510 if(cacheValue.hasValue) 2511 return cacheValue.value; 2512 } 2513 var isActionElement = ASPx.IsActionElementCore(element); 2514 if(useCache) 2515 ASPx.ActionElementsCache.Add(element, isActionElement); 2516 return isActionElement; 2517}; 2518ASPx.IsActionElementCore = function(element) { 2519 var tabIndex = parseInt(ASPx.Attr.GetAttribute(element, ASPx.Attr.GetTabIndexAttributeName())); 2520 var hasTabIndex = !isNaN(tabIndex); 2521 var hasNonNegativeTabIndex = hasTabIndex && tabIndex > -1; 2522 var hasNegativeTabIndex = hasTabIndex && tabIndex < 0; 2523 var tagName = element.tagName; 2524 var focusableElementTags = ["BUTTON", "SELECT", "TEXTAREA", "OPTION", "IFRAME"]; 2525 var isFocusableCore = ASPx.IsFocusable(element); 2526 var isFocusableTag = focusableElementTags.indexOf(tagName) !== -1; 2527 var isFocusableLink = tagName === "A" && (!!element.href || hasNonNegativeTabIndex); 2528 var isFocusableInput = tagName === "INPUT" && element.type.toLowerCase() !== "hidden"; 2529 var isFocusableByTabIndex = tagName !== "INPUT" && hasNonNegativeTabIndex; 2530 var isEditableDiv = tagName == "DIV" && element.contentEditable === "true"; 2531 return isFocusableCore && !hasNegativeTabIndex && (isFocusableTag || isFocusableLink || isFocusableInput || isFocusableByTabIndex || isEditableDiv); 2532};
2533ASPx.GetCanBeActiveElementsInContainer = function(container) { 2534 var canBeActiveTags = ["INPUT", "A", "UL", "BUTTON", "TEXTAREA", "SELECT", "IFRAME"], 2535 canBeActiveElements = []; 2536 Data.ForEach(canBeActiveTags, function(tag) { 2537 var elements = container.getElementsByTagName(tag); 2538 canBeActiveElements = canBeActiveElements.concat([].slice.call(elements)); 2539 }); 2540 return canBeActiveElements; 2541}; 2542function isActionElementAllowedByPredicate(element, predicate) { 2543 var allowedByPredicate = !predicate || predicate(element); 2544 return allowedByPredicate && ASPx.IsActionElement(element); 2545} 2546ASPx.FindChildActionElements = function(container, predicate) { 2547 return ASPx.GetNodes(container, function(el) { 2548 return isActionElementAllowedByPredicate(el, predicate); 2549 }); 2550}; 2551ASPx.FindAllSortedActionElements = function(container, predicate) { 2552 var result = [ ]; 2553 if(!container || !container.getElementsByTagName) return result; 2554 var actionElements = ASPx.FindChildActionElements(container, predicate); 2555 var getTabOrderValue = function(el) { 2556 var tabIndex = parseInt(ASPx.Attr.GetAttribute(el, ASPx.Attr.GetTabIndexAttributeName())); 2557 return isNaN(tabIndex) ? 0 : tabIndex; 2558 }; 2559 var positiveTabIndexElements = actionElements.filter(function(x) { return getTabOrderValue(x) > 0; }); 2560 var nonPositiveTabIndexElements = actionElements.filter(function(x) { return getTabOrderValue(x) === 0; }); 2561 var sortedTabIndexElements = positiveTabIndexElements.sort(function(x, y) { return getTabOrderValue(x) - getTabOrderValue(y); }); 2562 result = sortedTabIndexElements.concat(nonPositiveTabIndexElements); 2563 return result; 2564}; 2565ASPx.FindFirstChildActionElement = function(container, predicate) { 2566 if(!container || isActionElementAllowedByPredicate(container, predicate)) 2567 return !container ? null : container; 2568 var sortedActionElements = ASPx.FindAllSortedActionElements(container, predicate); 2569 return sortedActionElements[0]; 2570}; 2571ASPx.FindLastChildActionElement = function(container, predicate) { 2572 if(!container) 2573 return null; 2574 var sortedActionElements = ASPx.FindAllSortedActionElements(container, predicate); 2575 var actionElement = sortedActionElements[sortedActionElements.length - 1]; 2576 if(!actionElement && isActionElementAllowedByPredicate(container, predicate)) 2577 actionElement = container; 2578 return actionElement; 2579}; 2580ASPx.GetParentClientControls = function(name) { 2581 var nameParts = name.split("_"); 2582 var result = [ ]; 2583 var controlCollection = ASPx.GetControlCollection(); 2584 for(var i = 1; i <= nameParts.length; i++) { 2585 var controlName = nameParts.slice(0, i).join("_"); 2586 var control = controlCollection.Get(controlName); 2587 if(control) 2588 result.push(control); 2589 } 2590 return result; 2591}; 2592ASPx.GetRootClientControl = function(childControlName) { 2593 var parentControls = ASPx.GetParentClientControls(childControlName); 2594 return parentControls[0]; 2595}; 2596ASPx.GetClientControlByElementID = function(elementID) { 2597 var parentControls = ASPx.GetParentClientControls(elementID); 2598 return parentControls[parentControls.length - 1]; 2599}; 2600ASPx.IsExists = function(obj){ 2601 return (typeof(obj) != "undefined") && (obj != null); 2602}; 2603ASPx.IsFunction = function(obj){ 2604 return typeof(obj) == "function"; 2605}; 2606ASPx.IsNumber = function(str) { 2607 return !isNaN(parseFloat(str)) && isFinite(str); 2608}; 2609ASPx.GetDefinedValue = function(value, defaultValue){ 2610 return (typeof(value) != "undefined") ? value : defaultValue; 2611}; 2612ASPx.CorrectJSFloatNumber = function(number) { 2613 var ret = 21; 2614 var numString = number.toPrecision(21); 2615 numString = numString.replace("-", ""); 2616 var integerDigitsCount = numString.indexOf(ASPx.PossibleNumberDecimalSeparators[0]); 2617 if(integerDigitsCount < 0) 2618 integerDigitsCount = numString.indexOf(ASPx.PossibleNumberDecimalSeparators[1]); 2619 var floatDigitsCount = numString.length - integerDigitsCount - 1; 2620 if(floatDigitsCount < 10) 2621 return number; 2622 if(integerDigitsCount > 0) { 2623 ret = integerDigitsCount + 12; 2624 } 2625 var toPrecisionNumber = Math.min(ret, 21); 2626 var newValueString = number.toPrecision(toPrecisionNumber); 2627 return parseFloat(newValueString, 10); 2628}; 2629ASPx.CorrectRounding = function(number, step) { 2630 var regex = /[,|.](.*)/, 2631 isFloatValue = regex.test(number), 2632 isFloatStep = regex.test(step); 2633 if(isFloatValue || isFloatStep) { 2634 var valueAccuracy = (isFloatValue) ? regex.exec(number)[0].length - 1 : 0, 2635 stepAccuracy = (isFloatStep) ? regex.exec(step)[0].length - 1 : 0, 2636 accuracy = Math.max(valueAccuracy, stepAccuracy); 2637 var multiplier = Math.pow(10, accuracy); 2638 number = Math.round((number + step) * multiplier) / multiplier; 2639 return number; 2640 } 2641 return number + step; 2642};
2643ASPx.GetActiveElement = function() { 2644 try{ return document.activeElement; } catch(e) { return null; } 2645}; 2646var verticalScrollBarWidth; 2647ASPx.GetVerticalScrollBarWidth = function() { 2648 if(typeof(verticalScrollBarWidth) == "undefined") { 2649 var container = document.createElement("DIV"); 2650 container.style.cssText = "position: absolute; top: 0px; left: 0px; visibility: hidden; width: 200px; height: 150px; overflow: hidden; box-sizing: content-box"; 2651 document.body.appendChild(container); 2652 var child = document.createElement("P"); 2653 container.appendChild(child); 2654 child.style.cssText = "width: 100%; height: 200px;"; 2655 var widthWithoutScrollBar = child.offsetWidth; 2656 container.style.overflow = "scroll"; 2657 var widthWithScrollBar = child.offsetWidth; 2658 if(widthWithoutScrollBar == widthWithScrollBar) 2659 widthWithScrollBar = container.clientWidth; 2660 verticalScrollBarWidth = widthWithoutScrollBar - widthWithScrollBar; 2661 document.body.removeChild(container); 2662 } 2663 return verticalScrollBarWidth; 2664}; 2665function hideScrollBarCore(element, scrollName) { 2666 if(element.tagName == "IFRAME") { 2667 if((element.scrolling == "yes") || (element.scrolling == "auto")) { 2668 Attr.ChangeAttribute(element, "scrolling", "no"); 2669 return true; 2670 } 2671 } 2672 else if(element.tagName == "DIV") { 2673 if((element.style[scrollName] == "scroll") || (element.style[scrollName] == "auto")) { 2674 Attr.ChangeStyleAttribute(element, scrollName, "hidden"); 2675 return true; 2676 } 2677 } 2678 return false; 2679} 2680function restoreScrollBarCore(element, scrollName) { 2681 if(element.tagName == "IFRAME") 2682 return Attr.RestoreAttribute(element, "scrolling"); 2683 else if(element.tagName == "DIV") 2684 return Attr.RestoreStyleAttribute(element, scrollName); 2685 return false; 2686} 2687ASPx.SetScrollBarVisibilityCore = function(element, scrollName, isVisible) { 2688 return isVisible ? restoreScrollBarCore(element, scrollName) : hideScrollBarCore(element, scrollName); 2689}; 2690ASPx.SetScrollBarVisibility = function(element, isVisible) { 2691 if(ASPx.SetScrollBarVisibilityCore(element, "overflow", isVisible)) 2692 return true; 2693 var result = ASPx.SetScrollBarVisibilityCore(element, "overflowX", isVisible) 2694 || ASPx.SetScrollBarVisibilityCore(element, "overflowY", isVisible); 2695 return result; 2696}; 2697ASPx.SetInnerHtml = function(element, html) { 2698 if(Browser.IE) { 2699 setInnerHtmlInternal(element, "<em> </em>" + html); 2700 element.removeChild(element.firstChild); 2701 } else 2702 setInnerHtmlInternal(element, html); 2703}; 2704ASPx.GetInnerText = function(container) { 2705 if(Browser.Safari && Browser.MajorVersion <= 5) { 2706 var filter = getHtml2PlainTextFilter(); 2707 setInnerHtmlInternal(filter, container.innerHTML); 2708 ASPx.SetElementDisplay(filter, true); 2709 var innerText = filter.innerText; 2710 ASPx.SetElementDisplay(filter, false); 2711 return innerText; 2712 } else if(Browser.NetscapeFamily || Browser.WebKitFamily || (Browser.IE && Browser.Version >= 9) || Browser.Edge) { 2713 return container.textContent; 2714 } else 2715 return container.innerText; 2716}; 2717ASPx.RemoveComment = function(text) { 2718 var result = text; 2719 var commentStart = "<!--"; 2720 var commentEnd = "//-->"; 2721 var positionStart = result.indexOf(commentStart); 2722 while(positionStart > -1) { 2723 var positionEnd = result.indexOf(commentEnd); 2724 var startStr = result.substring(0, positionStart); 2725 var endStr = result.substring(positionEnd + commentEnd.length); 2726 result = startStr + endStr; 2727 positionStart = result.indexOf(commentStart); 2728 } 2729 return result; 2730}; 2731var html2PlainTextFilter = null; 2732function getHtml2PlainTextFilter() { 2733 if(html2PlainTextFilter == null) { 2734 html2PlainTextFilter = document.createElement("DIV"); 2735 html2PlainTextFilter.style.width = "0"; 2736 html2PlainTextFilter.style.height = "0"; 2737 html2PlainTextFilter.style.overflow = "visible"; 2738 ASPx.SetElementDisplay(html2PlainTextFilter, false); 2739 document.body.appendChild(html2PlainTextFilter); 2740 } 2741 return html2PlainTextFilter; 2742} 2743ASPx.CreateHiddenField = function(name, id, parent) { 2744 var input = document.createElement("INPUT"); 2745 input.setAttribute("type", "hidden"); 2746 if(name) 2747 input.setAttribute("name", name); 2748 if(id) 2749 input.setAttribute("id", id); 2750 if(parent) 2751 parent.appendChild(input); 2752 return input; 2753}; 2754ASPx.CloneObject = function(srcObject) { 2755 if(typeof(srcObject) != 'object' || srcObject == null) 2756 return srcObject; 2757 var newObject = {}; 2758 for(var i in srcObject) 2759 newObject[i] = srcObject[i]; 2760 return newObject; 2761}; 2762ASPx.InsertRowsBefore = function(table, rowsHtml, index) { 2763 var row = null; 2764 if(index >= 0 && index < table.rows.length) 2765 row = table.rows[index]; 2766 var func = ASPx.Browser.IE && ASPx.Browser.Version < 10 ? insertRowsBefore_IE9 : insertRowsBefore; 2767 func(table, rowsHtml, row); 2768}; 2769var insertRowsBefore = function(table, rowsHtml, row) { 2770 if(!row && table.tBodies.length > 0) { 2771 row = document.createElement("TR"); 2772 table.tBodies[0].appendChild(row);
2773 row.shouldRemove = true; 2774 } 2775 if(row) { 2776 row.insertAdjacentHTML("beforeBegin", rowsHtml); 2777 if(row.shouldRemove) 2778 ASPx.RemoveElement(row); 2779 } 2780}; 2781var insertRowsBefore_IE9 = function(table, rowsHtml, nextRow) { 2782 var row = document.createElement("TR"); 2783 var cell = document.createElement("TD"); 2784 setInnerHtmlInternal(cell, "<table><tbody>" + rowsHtml + "</tbody></table>"); 2785 var tbody = table.tBodies[0]; 2786 tbody.appendChild(row); 2787 row.appendChild(cell); 2788 var newTable = ASPx.GetNodeByTagName(cell, "TABLE", 0); 2789 var rowCount = newTable.rows.length; 2790 for(var i = rowCount - 1; i >= 0; i--) { 2791 var newRow = newTable.rows[i]; 2792 if(nextRow == null) 2793 tbody.appendChild(newRow); 2794 else 2795 tbody.insertBefore(newRow, nextRow); 2796 nextRow = newRow; 2797 } 2798 ASPx.RemoveElement(row); 2799}; 2800ASPx.IsPercentageSize = function(size) { 2801 return size && size.indexOf('%') != -1; 2802}; 2803ASPx.GetElementById = function(id) { 2804 if(document.getElementById) 2805 return document.getElementById(id); 2806 else 2807 return document.all[id]; 2808}; 2809ASPx.GetInputElementById = function(id) { 2810 var elem = ASPx.GetElementById(id); 2811 if(!Browser.IE) 2812 return elem; 2813 if(elem) { 2814 if(elem.id == id) 2815 return elem; 2816 else { 2817 for(var i = 1; i < document.all[id].length; i++) { 2818 if(document.all[id][i].id == id) 2819 return document.all[id][i]; 2820 } 2821 } 2822 } 2823 return null; 2824}; 2825ASPx.GetElementByIdInDocument = function(documentObj, id) { 2826 if(documentObj.getElementById) 2827 return documentObj.getElementById(id); 2828 else 2829 return documentObj.all[id]; 2830}; 2831ASPx.GetIsParent = function(parentElement, element) { 2832 if(!parentElement || !element) 2833 return false; 2834 while(element){ 2835 if(element === parentElement) 2836 return true; 2837 if(element.tagName === "BODY") 2838 return false; 2839 element = element.parentNode; 2840 } 2841 return false; 2842}; 2843ASPx.GetParentById = function(element, id) { 2844 element = element.parentNode; 2845 while(element){ 2846 if(element.id === id) 2847 return element; 2848 element = element.parentNode; 2849 } 2850 return null; 2851}; 2852ASPx.GetParentByPartialId = function(element, idPart){ 2853 while(element && element.tagName != "BODY") { 2854 if(element.id && element.id.match(idPart)) 2855 return element; 2856 element = element.parentNode; 2857 } 2858 return null; 2859}; 2860ASPx.GetParentByTagName = function(element, tagName) { 2861 tagName = tagName.toUpperCase(); 2862 while(element) { 2863 if(element.tagName === "BODY") 2864 return null; 2865 if(element.tagName === tagName) 2866 return element; 2867 element = element.parentNode; 2868 } 2869 return null; 2870}; 2871function getParentByCondition(element, conditionArg, condition) { 2872 while(element != null) { 2873 if(element.tagName == "BODY" || element.nodeName == "#document") 2874 return null; 2875 if (condition(element, conditionArg)) 2876 return element; 2877 element = element.parentNode; 2878 } 2879 return null; 2880} 2881ASPx.GetParentByPartialClassName = function(element, className) { 2882 return getParentByCondition(element, className, ASPx.ElementContainsCssClass); 2883}; 2884ASPx.GetParentByClassName = function(element, className) { 2885 return getParentByCondition(element, className, ASPx.ElementHasCssClass); 2886}; 2887ASPx.GetParentBySelector = function (element, selector) { 2888 return getParentByCondition(element, selector, ASPx.ElementMatchesSelector); 2889}; 2890ASPx.GetParentByTagNameAndAttributeValue = function(element, tagName, attrName, attrValue) { 2891 tagName = tagName.toUpperCase(); 2892 while(element != null) { 2893 if(element.tagName == "BODY") 2894 return null; 2895 if(element.tagName == tagName && element[attrName] == attrValue) 2896 return element; 2897 element = element.parentNode; 2898 } 2899 return null; 2900}; 2901ASPx.GetParent = function(element, testFunc){ 2902 if (!ASPx.IsExists(testFunc)) return null; 2903 while(element != null && element.tagName != "BODY"){ 2904 if(testFunc(element)) 2905 return element; 2906 element = element.parentNode; 2907 } 2908 return null; 2909}; 2910ASPx.GetElementTreeLine = function(element, stopTagName, stopFunc) { 2911 var result = []; 2912 stopTagName = stopTagName || "BODY"; 2913 while(element != null) { 2914 if(!stopFunc && element.tagName == stopTagName) 2915 break; 2916 if(stopFunc && stopFunc(element)) 2917 break; 2918 result.push(element); 2919 element = element.parentNode; 2920 } 2921 return result; 2922}; 2923ASPx.IsScrollableElement = function(element, isHorzScrollable, isVertScrollable) { 2924 isHorzScrollable = ASPx.IsExists(isHorzScrollable) ? isHorzScrollable : true; 2925 isVertScrollable = ASPx.IsExists(isVertScrollable) ? isVertScrollable : true; 2926 var style = ASPx.GetCurrentStyle(element); 2927 var overflowStyleNames = ["overflow"]; 2928 if(isHorzScrollable) 2929 overflowStyleNames.push("overflowX"); 2930 if(isVertScrollable) 2931 overflowStyleNames.push("overflowY"); 2932 for(var i = 0; i < overflowStyleNames.length; i++) 2933 if(style[overflowStyleNames[i]] == "scroll" || style[overflowStyleNames[i]] == "auto") 2934 return true; 2935 return false; 2936}; 2937ASPx.GetPreviousSibling = function(el) { 2938 if(el.previousElementSibling) { 2939 return el.previousElementSibling; 2940 } else { 2941 while(el = el.previousSibling) { 2942 if(el.nodeType === 1) 2943 return el; 2944 } 2945 } 2946}; 2947ASPx.ElementMatchesSelector = (function (e) { 2948 return (function (matches) { 2949 return function (el, selector) { return !!el && !!selector && matches.call(el, selector); }; 2950 })(e.matches || e.matchesSelector || e.webkitMatchesSelector || e.mozMatchesSelector || e.msMatchesSelector || e.oMatchesSelector); 2951})(Element.prototype); 2952ASPx.ElementHasCssClass = function(element, className) { 2953 try { 2954 var elementClasses; 2955 var classList = ASPx.GetClassNameList(element); 2956 if(!classList) { 2957 var elementClassName = ASPx.GetClassName(element); 2958 if(!elementClassName) { 2959 return false; 2960 } 2961 elementClasses = elementClassName.split(" "); 2962 } 2963 var classNames = className.split(" "); 2964 for(var i = classNames.length - 1; i >= 0; i--) { 2965 if(classList) { 2966 if(classList.indexOf(classNames[i]) === -1) 2967 return false; 2968 continue; 2969 } 2970 if(Data.ArrayIndexOf(elementClasses, classNames[i]) < 0) 2971 return false; 2972 } 2973 return true; 2974 } catch(e) { 2975 return false; 2976 } 2977}; 2978ASPx.ElementContainsCssClass = function(element, className) { 2979 try { 2980 var elementClassName = ASPx.GetClassName(element); 2981 if(!elementClassName) { 2982 return false; 2983 } 2984 return elementClassName.indexOf(className) != -1; 2985 } catch(e) { 2986 return false; 2987 } 2988}; 2989ASPx.AddClassNameToElement = function (element, className) { 2990 if(!element || typeof(className) !== "string" ) return; 2991 className = className.trim(); 2992 if(!ASPx.ElementHasCssClass(element, className) && className !== "") { 2993 var oldClassName = ASPx.GetClassName(element); 2994 ASPx.SetClassName(element, (oldClassName === "") ? className : oldClassName + " " + className); 2995 } 2996}; 2997ASPx.RemoveClassNameFromElement = function(element, className) { 2998 if(!element) return; 2999 var elementClassName = ASPx.GetClassName(element); 3000 var updClassName = " " + elementClassName + " "; 3001 var newClassName = updClassName.replace(" " + className + " ", " "); 3002 if(updClassName.length != newClassName.length) 3003 ASPx.SetClassName(element, Str.Trim(newClassName)); 3004}; 3005ASPx.RemoveClassNamesFromElement = function(element, classNames) { 3006 if(!element) return; 3007 for(var i = 0; i < classNames.length; i++) { 3008 var className = classNames[i]; 3009 if(ASPx.Browser.IE && ASPx.Browser.Version < 10) 3010 ASPx.RemoveClassNameFromElement(element, className); 3011 else 3012 element.classList.remove(className); 3013 } 3014}; 3015ASPx.ToggleClassNameToElement = function(element, className, toggleState) { 3016 if(!toggleState) 3017 ASPx.RemoveClassNameFromElement(element, className); 3018 if(toggleState && !ASPx.ElementHasCssClass(element, className)) 3019 ASPx.AddClassNameToElement(element, className); 3020}; 3021ASPx.GetClassNameList = function(element) { 3022 var result = []; 3023 if(element) { 3024 if(element.tagName === "svg") { 3025 result = ASPx.GetClassName(element).replace(/^\s+|\s+$/g, '').split(/\s+/); 3026 } 3027 else { 3028 result = element.classList ? [].slice.call(element.classList) : ASPx.GetClassName(element).replace(/^\s+|\s+$/g, '').split(/\s+/); 3029 } 3030 } 3031 return result; 3032}; 3033ASPx.GetClassName = function(element) { 3034 var result = ""; 3035 if(element) { 3036 if(element.tagName === "svg") { 3037 result = element.className.baseVal; 3038 } 3039 else { 3040 result = element.className ? element.className : ""; 3041 } 3042 } 3043 return result; 3044}; 3045ASPx.SetClassName = function(element, className) { 3046 if(element.tagName === "svg") { 3047 element.className.baseVal = Str.Trim(className); 3048 } 3049 else { 3050 element.className = Str.Trim(className); 3051 } 3052}; 3053ASPx.GetElementOffsetWidth = function(element) { 3054 if(element.tagName === "svg") { 3055 return element.getBoundingClientRect().width; 3056 } 3057 else { 3058 return element.offsetWidth; 3059 } 3060}; 3061ASPx.GetElementOffsetHeight = function(element) { 3062 if(element.tagName === "svg") { 3063 return element.getBoundingClientRect().height; 3064 } 3065 else { 3066 return element.offsetHeight; 3067 } 3068}; 3069function nodeListToArray(nodeList, filter) { 3070 var result = []; 3071 for(var i = 0, element; element = nodeList[i]; i++) { 3072 if(filter && !filter(element)) 3073 continue; 3074 result.push(element); 3075 } 3076 return result; 3077} 3078ASPx.NodeListToArray = nodeListToArray; 3079function getItemByIndex(collection, index) { 3080 if(!index) index = 0; 3081 if(collection != null && collection.length > index) 3082 return collection[index]; 3083 return null; 3084} 3085ASPx.GetChildNodesByQuerySelector = function (parent, selector) { 3086 return nodeListToArray(parent.querySelectorAll(selector), function (el) { return el.parentNode === parent; });
3087}; 3088ASPx.GetChildNodesByClassName = function(parent, className) { 3089 if(!parent) return []; 3090 if(parent.querySelectorAll) { 3091 var children = parent.querySelectorAll('.' + className); 3092 return nodeListToArray(children, function(element) { 3093 return element.parentNode === parent; 3094 }); 3095 } 3096 return ASPx.GetChildNodes(parent, function(elem) { return elem.className && ASPx.ElementHasCssClass(elem, className); }); 3097}; 3098ASPx.GetChildNodesByPartialClassName = function(element, className) { 3099 return ASPx.GetChildElementNodesByPredicate(element, 3100 function(child) { 3101 return ASPx.ElementContainsCssClass(child, className); 3102 }); 3103}; 3104ASPx.GetChildByPartialClassName = function(element, className, index) { 3105 if(element != null){ 3106 var collection = ASPx.GetChildNodesByPartialClassName(element, className); 3107 return getItemByIndex(collection, index); 3108 } 3109 return null; 3110}; 3111ASPx.GetChildByClassName = function(element, className, index) { 3112 if(element != null){ 3113 var collection = ASPx.GetChildNodesByClassName(element, className); 3114 return getItemByIndex(collection, index); 3115 } 3116 return null; 3117}; 3118ASPx.GetNodesByPartialClassName = function(element, className) { 3119 if(element.querySelectorAll) { 3120 var list = element.querySelectorAll('*[class*=' + className + ']'); 3121 return nodeListToArray(list); 3122 } 3123 var collection = element.all || element.getElementsByTagName('*'); 3124 var ret = [ ]; 3125 if(collection != null) { 3126 for(var i = 0; i < collection.length; i ++) { 3127 if(ASPx.ElementContainsCssClass(collection[i], className)) 3128 ret.push(collection[i]); 3129 } 3130 } 3131 return ret; 3132}; 3133ASPx.GetNodesByClassName = function(parent, className) { 3134 if(parent.querySelectorAll) { 3135 var children = parent.querySelectorAll('.' + className); 3136 return nodeListToArray(children); 3137 } 3138 return ASPx.GetNodes(parent, function(elem) { return elem.className && ASPx.ElementHasCssClass(elem, className); }); 3139}; 3140ASPx.GetNodeByClassName = function(element, className, index) { 3141 if(element != null){ 3142 var collection = ASPx.GetNodesByClassName(element, className); 3143 return getItemByIndex(collection, index); 3144 } 3145 return null; 3146}; 3147ASPx.GetChildById = function(element, id) { 3148 if(element.all) { 3149 var child = element.all[id]; 3150 if(!child) { 3151 child = element.all(id); 3152 if(!child) 3153 return Browser.IE ? document.getElementById(id) : null; 3154 } 3155 if(!ASPx.IsExists(child.length)) 3156 return child; 3157 else 3158 return ASPx.GetElementById(id); 3159 } 3160 else 3161 return ASPx.GetElementById(id); 3162}; 3163ASPx.GetNodesByPartialId = function(element, partialName, list) { 3164 if(element.id && element.id.indexOf(partialName) > -1) 3165 list.push(element); 3166 if(element.childNodes) { 3167 for(var i = 0; i < element.childNodes.length; i ++) 3168 ASPx.GetNodesByPartialId(element.childNodes[i], partialName, list); 3169 } 3170}; 3171ASPx.GetNodesByTagName = function(element, tagName) { 3172 var tagNameToUpper = tagName.toUpperCase(); 3173 var result = null; 3174 if(element) { 3175 if(element.getElementsByTagName) { 3176 result = element.getElementsByTagName(tagNameToUpper); 3177 if(result.length === 0) { 3178 result = element.getElementsByTagName(tagName); 3179 } 3180 } 3181 else if(element.all && element.all.tags !== undefined) 3182 result = Browser.Netscape ? element.all.tags[tagNameToUpper] : element.all.tags(tagNameToUpper); 3183 } 3184 return result; 3185}; 3186ASPx.GetNodeByTagName = function(element, tagName, index) { 3187 if(element != null){ 3188 var collection = ASPx.GetNodesByTagName(element, tagName); 3189 return getItemByIndex(collection, index); 3190 } 3191 return null; 3192}; 3193ASPx.GetChildNodesByTagName = function(parent, tagName) { 3194 return ASPx.GetChildNodes(parent, function (child) { return child.tagName === tagName; }); 3195}; 3196ASPx.GetChildByTagName = function(element, tagName, index) { 3197 if(element != null){ 3198 var collection = ASPx.GetChildNodesByTagName(element, tagName); 3199 return getItemByIndex(collection, index); 3200 } 3201 return null; 3202}; 3203ASPx.RetrieveByPredicate = function(scourceCollection, predicate) { 3204 var result = []; 3205 for(var i = 0; i < scourceCollection.length; i++) { 3206 var element = scourceCollection[i]; 3207 if(!predicate || predicate(element)) 3208 result.push(element); 3209 } 3210 return result; 3211}; 3212ASPx.GetChildNodes = function(parent, predicate) { 3213 return ASPx.RetrieveByPredicate(parent.childNodes, predicate); 3214}; 3215ASPx.GetNodes = function(parent, predicate) { 3216 var c = parent.all || parent.getElementsByTagName('*'); 3217 return ASPx.RetrieveByPredicate(c, predicate); 3218}; 3219ASPx.GetChildElementNodes = function(parent) { 3220 if(!parent) return null;
3221 return ASPx.GetChildNodes(parent, function(e) { return e.nodeType == 1; }); 3222}; 3223ASPx.GetChildElementNodesByPredicate = function(parent, predicate) { 3224 if(!parent) return null; 3225 if(!predicate) return ASPx.GetChildElementNodes(parent); 3226 return ASPx.GetChildNodes(parent, function(e) { return e.nodeType == 1 && predicate(e); }); 3227}; 3228ASPx.GetTextNode = function(element, index) { 3229 if(element != null){ 3230 var collection = [ ]; 3231 ASPx.GetTextNodes(element, collection); 3232 return getItemByIndex(collection, index); 3233 } 3234 return null; 3235}; 3236ASPx.GetTextNodes = function(element, collection) { 3237 if(element.tagName === "svg") 3238 return; 3239 for(var i = 0; i < element.childNodes.length; i ++){ 3240 var childNode = element.childNodes[i]; 3241 if(ASPx.IsExists(childNode.nodeValue)) 3242 collection.push(childNode); 3243 ASPx.GetTextNodes(childNode, collection); 3244 } 3245}; 3246ASPx.GetNormalizedTextNode = function(element, index) { 3247 var textNode = ASPx.GetTextNode(element, index); 3248 if(textNode != null) 3249 ASPx.MergeAdjacentTextNodes(textNode); 3250 return textNode; 3251}; 3252ASPx.MergeAdjacentTextNodes = function(firstTextNode) { 3253 if(!ASPx.IsExists(firstTextNode.nodeValue)) 3254 return; 3255 var textNode = firstTextNode; 3256 while(textNode.nextSibling && ASPx.IsExists(textNode.nextSibling.nodeValue)) { 3257 textNode.nodeValue += textNode.nextSibling.nodeValue; 3258 textNode.parentNode.removeChild(textNode.nextSibling); 3259 } 3260}; 3261ASPx.GetElementDocument = function(element) { 3262 return element.document || element.ownerDocument; 3263}; 3264ASPx.RemoveElement = function(element) { 3265 if(element && element.parentNode) 3266 element.parentNode.removeChild(element); 3267}; 3268ASPx.ReplaceTagName = function(element, newTagName, cloneChilds) { 3269 if(element.nodeType != 1) 3270 return null; 3271 if(element.nodeName == newTagName) 3272 return element; 3273 cloneChilds = cloneChilds !== undefined ? cloneChilds : true; 3274 var doc = element.ownerDocument; 3275 var newElem = doc.createElement(newTagName); 3276 Attr.CopyAllAttributes(element, newElem); 3277 if(cloneChilds) { 3278 for(var i = 0; i < element.childNodes.length; i++) 3279 newElem.appendChild(element.childNodes[i].cloneNode(true)); 3280 } 3281 else { 3282 for(var child; child = element.firstChild; ) 3283 newElem.appendChild(child); 3284 } 3285 element.parentNode.replaceChild(newElem, element); 3286 return newElem; 3287}; 3288ASPx.RemoveOuterTags = function(element) { 3289 if(ASPx.Browser.IE) { 3290 element.insertAdjacentHTML( 'beforeBegin', element.innerHTML ) ; 3291 ASPx.RemoveElement(element); 3292 } else { 3293 var docFragment = element.ownerDocument.createDocumentFragment(); 3294 for(var i = 0; i < element.childNodes.length; i++) 3295 docFragment.appendChild(element.childNodes[i].cloneNode(true)); 3296 element.parentNode.replaceChild(docFragment, element); 3297 } 3298}; 3299ASPx.WrapElementInNewElement = function(element, newElementTagName) { 3300 var wrapElement = null; 3301 if(Browser.IE) { 3302 var wrapElement = element.ownerDocument.createElement(newElementTagName); 3303 wrapElement.appendChild(element.cloneNode(true)); 3304 element.parentNode.insertBefore(wrapElement, element); 3305 element.parentNode.removeChild(element); 3306 } else { 3307 var docFragment = element.ownerDocument.createDocumentFragment(); 3308 wrapElement = element.ownerDocument.createElement(newElementTagName); 3309 docFragment.appendChild(wrapElement); 3310 wrapElement.appendChild(element.cloneNode(true)); 3311 element.parentNode.replaceChild(docFragment, element); 3312 } 3313 return wrapElement; 3314}; 3315ASPx.InsertElementAfter = function(newElement, targetElement) { 3316 var parentElem = targetElement.parentNode; 3317 if(parentElem.childNodes[parentElem.childNodes.length - 1] == targetElement) 3318 parentElem.appendChild(newElement); 3319 else if(newElement !== targetElement.nextSibling) 3320 parentElem.insertBefore(newElement, targetElement.nextSibling); 3321}; 3322ASPx.SetElementOpacity = function(element, value) { 3323 var useOpacityStyle = !Browser.IE || Browser.Version > 8; 3324 if(useOpacityStyle){ 3325 element.style.opacity = value; 3326 } else { 3327 if(typeof(element.filters) === "object" && element.filters["DXImageTransform.Microsoft.Alpha"]) 3328 element.filters.item("DXImageTransform.Microsoft.Alpha").Opacity = value*100; 3329 else 3330 element.style.filter = "alpha(opacity=" + (value * 100) + ")"; 3331 } 3332}; 3333ASPx.GetElementOpacity = function(element) { 3334 var useOpacityStyle = !Browser.IE || Browser.Version > 8; 3335 if(useOpacityStyle) 3336 return parseFloat(ASPx.GetCurrentStyle(element).opacity); 3337 else { 3338 if(typeof(element.filters) === "object" && element.filters["DXImageTransform.Microsoft.Alpha"]){ 3339 return element.filters.item("DXImageTransform.Microsoft.Alpha").Opacity / 100; 3340 } else { 3341 var alphaValue = ASPx.GetCurrentStyle(element).filter; 3342 var value = alphaValue.replace("alpha(opacity=", ""); 3343 value = value.replace(")", ""); 3344 return parseInt(value) / 100; 3345 } 3346 return 100; 3347 } 3348}; 3349ASPx.HiddenChangable = "dx-hc"; 3350ASPx.DefaultDisplayNoneSelectors = [ "dxmodalSys" ]; 3351ASPx.DefaultDisplaySelectors = ["show"]; 3352function getIsDefaultDisplayNone(element) { 3353 for(var i = 0; i < ASPx.DefaultDisplayNoneSelectors.length; i++) { 3354 if(ASPx.ElementHasCssClass(element, ASPx.DefaultDisplayNoneSelectors[i])) 3355 return true; 3356 } 3357 return false; 3358} 3359ASPx.GetElementDisplay = function(element, isCurrentStyle) { 3360 if(isCurrentStyle) 3361 return ASPx.GetCurrentStyle(element).display != "none"; 3362 if(getIsDefaultDisplayNone(element)) 3363 return element.style.display != "none" && element.style.display != "" || ASPx.DefaultDisplaySelectors.some(function(s) { return ASPx.ElementHasCssClass(element, s); }); 3364 return element.style.display != "none" && !ASPx.ElementHasCssClass(element, ASPx.HiddenChangable); 3365}; 3366ASPx.SetElementDisplay = function(element, value) { 3367 if(!element) return; 3368 if(ASPx.ElementHasCssClass(element, ASPx.HiddenChangable)) 3369 ASPx.RemoveClassNameFromElement(element, ASPx.HiddenChangable); 3370 if(typeof(value) === "string") 3371 element.style.display = value; 3372 else if(getIsDefaultDisplayNone(element)) 3373 element.style.display = value ? (element.tagName === "TABLE" ? "table" : "block") : ""; 3374 else if(!value) 3375 element.style.display = "none"; 3376 else
3377 element.style.display = ""; 3378}; 3379ASPx.GetElementVisibility = function(element, isCurrentStyle) { 3380 if(isCurrentStyle) 3381 return ASPx.GetCurrentStyle(element).visibility != "hidden"; 3382 return element.style.visibility != "hidden"; 3383}; 3384ASPx.SetElementVisibility = function(element, value) { 3385 if(!element) return; 3386 if(typeof(value) === "string") 3387 element.style.visibility = value; 3388 else 3389 element.style.visibility = value ? "visible" : "hidden"; 3390}; 3391ASPx.IsElementVisible = function(element, isCurrentStyle) { 3392 while(element && element.tagName != "BODY") { 3393 if(!ASPx.GetElementDisplay(element, isCurrentStyle) || (!ASPx.GetElementVisibility(element, isCurrentStyle) && !Attr.IsExistsAttribute(element, "errorFrame"))) 3394 return false; 3395 element = element.parentNode; 3396 } 3397 return true; 3398}; 3399ASPx.IsElementDisplayed = function(element) { 3400 while(element && element.tagName != "BODY") { 3401 if(!ASPx.GetElementDisplay(element)) 3402 return false; 3403 element = element.parentNode; 3404 } 3405 return true; 3406}; 3407ASPx.GetElementInitializedFlag = function(element) { 3408 return element["dxinit"]; 3409}; 3410ASPx.SetElementInitializedFlag = function(element) { 3411 element["dxinit"] = true; 3412}; 3413ASPx.AddStyleSheetLinkToDocument = function(doc, linkUrl) { 3414 var newLink = createStyleLink(doc, linkUrl); 3415 var head = ASPx.GetHeadElementOrCreateIfNotExist(doc); 3416 head.appendChild(newLink); 3417 return newLink; 3418}; 3419ASPx.GetHeadElementOrCreateIfNotExist = function(doc) { 3420 var elements = ASPx.GetNodesByTagName(doc, "head"); 3421 var head = null; 3422 if(elements.length == 0) { 3423 head = doc.createElement("head"); 3424 head.visibility = "hidden"; 3425 doc.insertBefore(head, doc.body); 3426 } else 3427 head = elements[0]; 3428 return head; 3429}; 3430function createStyleLink(doc, url) { 3431 var newLink = doc.createElement("link"); 3432 Attr.SetAttribute(newLink, "href", url); 3433 Attr.SetAttribute(newLink, "rel", "stylesheet"); 3434 Attr.AppendStyleType(newLink); 3435 return newLink; 3436} 3437ASPx.GetCurrentStyle = function(element) { 3438 if(document.defaultView && document.defaultView.getComputedStyle) { 3439 var result = document.defaultView.getComputedStyle(element, null); 3440 if(!result && Browser.Firefox && window.frameElement) { 3441 var changes = []; 3442 var curElement = window.frameElement; 3443 while(!(result = document.defaultView.getComputedStyle(element, null))) { 3444 changes.push([curElement, curElement.style.display]); 3445 ASPx.SetStylesCore(curElement, "display", "block", true); 3446 curElement = curElement.tagName == "BODY" ? curElement.ownerDocument.defaultView.frameElement : curElement.parentNode; 3447 } 3448 result = ASPx.CloneObject(result); 3449 for(var ch, i = 0; ch = changes[i]; i++) 3450 ASPx.SetStylesCore(ch[0], "display", ch[1]); 3451 var dummy = document.body.offsetWidth; 3452 } 3453 if(Browser.Firefox && Browser.MajorVersion >= 62 && window.frameElement && result.length === 0) { 3454 result = ASPx.CloneObject(result); 3455 result.display = element.style.display; 3456 } 3457 return result; 3458 } 3459 return window.getComputedStyle(element, null); 3460}; 3461ASPx.CreateStyleSheetInDocument = function(doc) { 3462 if(doc.createStyleSheet) { 3463 try { 3464 return doc.createStyleSheet(); 3465 } 3466 catch(e) { 3467 var message = "The CSS link limit (31) has been exceeded. Please enable CSS merging or reduce the number of CSS files on the page. For details, see http://www.devexpress.com/Support/Center/p/K18487.aspx."; 3468 throw new Error(message); 3469 } 3470 } 3471 else { 3472 var styleSheet = doc.createElement("STYLE"); 3473 ASPx.GetNodeByTagName(doc, "HEAD", 0).appendChild(styleSheet); 3474 return styleSheet.sheet; 3475 } 3476}; 3477ASPx.currentStyleSheet = null; 3478ASPx.GetCurrentStyleSheet = function() { 3479 if(!ASPx.currentStyleSheet) 3480 ASPx.currentStyleSheet = ASPx.CreateStyleSheetInDocument(document); 3481 return ASPx.currentStyleSheet; 3482}; 3483function getStyleSheetRules(styleSheet){ 3484 try { 3485 if (styleSheet.href && styleSheet.href.indexOf("file:///") === 0) 3486 return null; 3487 return Browser.IE && Browser.Version == 8 ? styleSheet.rules : styleSheet.cssRules; 3488 } 3489 catch(e) { 3490 return null; 3491 } 3492} 3493ASPx.cachedCssRules = { }; 3494ASPx.GetStyleSheetRules = function (className, stylesStorageDocument) { 3495 if(ASPx.cachedCssRules[className]) { 3496 if(ASPx.cachedCssRules[className] != ASPx.EmptyObject) 3497 return ASPx.cachedCssRules[className]; 3498 return null; 3499 } 3500 var result = iterateStyleSheetRules(stylesStorageDocument, function(rule) { 3501 if(rule.selectorText == "." + className){ 3502 ASPx.cachedCssRules[className] = rule; 3503 return rule; 3504 } 3505 }); 3506 if(ASPx.IsExists(result)) 3507 return result; 3508 ASPx.cachedCssRules[className] = ASPx.EmptyObject; 3509 return null; 3510}; 3511function iterateStyleSheetRules(stylesStorageDocument, callback) { 3512 var doc = stylesStorageDocument || document; 3513 for(var i = 0; i < doc.styleSheets.length; i ++){ 3514 var styleSheet = doc.styleSheets[i];
3515 var rules = getStyleSheetRules(styleSheet); 3516 if(rules != null){ 3517 for(var j = 0; j < rules.length; j ++) { 3518 var result = callback(rules[j]); 3519 if(result !== undefined) 3520 return result; 3521 } 3522 } 3523 } 3524} 3525ASPx.ProcessStyleSheetRules = function(prefix, callback) { 3526 iterateStyleSheetRules(null, function(rule) { 3527 if(!!rule.selectorText && rule.selectorText.indexOf(prefix) === 0) { 3528 var name = rule.selectorText.substring(prefix.length); 3529 var result = callback(name, rule.style, rule); 3530 if(result !== undefined) 3531 return result; 3532 } 3533 }); 3534}; 3535ASPx.ClearCachedCssRules = function(){ 3536 ASPx.cachedCssRules = { }; 3537}; 3538var styleCount = 0; 3539var styleNameCache = { }; 3540ASPx.CreateImportantStyleRule = function(styleSheet, cssText, postfix, prefix) { 3541 styleSheet = styleSheet || ASPx.GetCurrentStyleSheet(); 3542 var cacheKey = (postfix ? postfix + "||" : "") + cssText + (prefix ? "||" + prefix : ""); 3543 if(styleNameCache[cacheKey]) 3544 return styleNameCache[cacheKey]; 3545 prefix = prefix ? prefix + " " : ""; 3546 var className = "dxh" + styleCount + (postfix ? postfix : ""); 3547 ASPx.AddStyleSheetRule(styleSheet, prefix + "." + className, ASPx.CreateImportantCssText(cssText)); 3548 styleCount++; 3549 styleNameCache[cacheKey] = className; 3550 return className; 3551}; 3552ASPx.CreateImportantCssText = function(cssText) { 3553 var newText = ""; 3554 var hasEncodedSemicolon = cssText.indexOf(ASPx.StyleValueEncodedSemicolon) > -1; 3555 var attributes = cssText.split(";"); 3556 for(var i = 0; i < attributes.length; i++) { 3557 var rule = attributes[i]; 3558 if(rule != "") 3559 newText += ASPx.CreateImportantCssRule(rule, hasEncodedSemicolon); 3560 } 3561 return newText; 3562}; 3563ASPx.CreateImportantCssRule = function(rule, hasEncodedSemicolon) { 3564 var result = rule; 3565 if(hasEncodedSemicolon) { 3566 var regex = new RegExp(ASPx.StyleValueEncodedSemicolon, "g"); 3567 result = result.replace(regex, ";"); 3568 } 3569 result = result + " !important;"; 3570 return result; 3571}; 3572ASPx.AddStyleSheetRule = function(styleSheet, selector, cssText){ 3573 if(!cssText) return; 3574 var index = styleSheet.cssRules.length; 3575 styleSheet.insertRule(selector + " { " + cssText + " }", index); 3576 return styleSheet.cssRules[index]; 3577}; 3578ASPx.GetPointerCursor = function() { 3579 return "pointer"; 3580}; 3581ASPx.SetPointerCursor = function(element) { 3582 if(element.style.cursor == "") 3583 element.style.cursor = ASPx.GetPointerCursor(); 3584}; 3585ASPx.SetElementFloat = function(element, value) { 3586 if(ASPx.IsExists(element.style.cssFloat)) 3587 element.style.cssFloat = value; 3588 else if(ASPx.IsExists(element.style.styleFloat)) 3589 element.style.styleFloat = value; 3590 else 3591 Attr.SetAttribute(element.style, "float", value); 3592}; 3593ASPx.GetElementFloat = function(element) { 3594 var currentStyle = ASPx.GetCurrentStyle(element); 3595 if(ASPx.IsExists(currentStyle.cssFloat)) 3596 return currentStyle.cssFloat; 3597 if(ASPx.IsExists(currentStyle.styleFloat)) 3598 return currentStyle.styleFloat; 3599 return Attr.GetAttribute(currentStyle, "float"); 3600}; 3601function getElementDirection(element) { 3602 return ASPx.GetCurrentStyle(element).direction; 3603} 3604ASPx.IsElementRightToLeft = function(element) { 3605 return getElementDirection(element) == "rtl"; 3606}; 3607ASPx.AdjustVerticalMarginsInContainer = function(container) { 3608 var containerBorderAndPaddings = ASPx.GetTopBottomBordersAndPaddingsSummaryValue(container); 3609 var flowElements = [], floatElements = [], floatTextElements = []; 3610 var maxHeight = 0, maxFlowHeight = 0; 3611 for(var i = 0; i < container.childNodes.length; i++) { 3612 var element = container.childNodes[i]; 3613 if(!element.offsetHeight) continue; 3614 ASPx.ClearVerticalMargins(element); 3615 } 3616 for(var i = 0; i < container.childNodes.length; i++) { 3617 var element = container.childNodes[i]; 3618 if(!element.offsetHeight) continue; 3619 var float = ASPx.GetElementFloat(element); 3620 var isFloat = (float === "left" || float === "right"); 3621 if(isFloat) 3622 floatElements.push(element); 3623 else { 3624 flowElements.push(element); 3625 if(element.tagName !== "IMG"){ 3626 if(!ASPx.IsTextWrapped(element)) 3627 element.style.verticalAlign = 'baseline'; 3628 floatTextElements.push(element); 3629 } 3630 if(element.tagName === "DIV") 3631 Attr.ChangeStyleAttribute(element, "float", "left"); 3632 } 3633 if(element.offsetHeight > maxHeight) 3634 maxHeight = element.offsetHeight; 3635 if(!isFloat && element.offsetHeight > maxFlowHeight) 3636 maxFlowHeight = element.offsetHeight; 3637 } 3638 for(var i = 0; i < flowElements.length; i++) 3639 Attr.RestoreStyleAttribute(flowElements[i], "float"); 3640 var containerBorderAndPaddings = ASPx.GetTopBottomBordersAndPaddingsSummaryValue(container); 3641 var containerHeight = container.offsetHeight - containerBorderAndPaddings; 3642 if(maxHeight == containerHeight) { 3643 var verticalAlign = ASPx.GetCurrentStyle(container).verticalAlign; 3644 for(var i = 0; i < floatTextElements.length; i++) 3645 floatTextElements[i].style.verticalAlign = ''; 3646 containerHeight = container.offsetHeight - containerBorderAndPaddings; 3647 for(var i = 0; i < floatElements.length; i++) 3648 adjustVerticalMarginsCore(floatElements[i], containerHeight, verticalAlign, true); 3649 for(var i = 0; i < flowElements.length; i++) { 3650 if(maxFlowHeight != maxHeight) 3651 adjustVerticalMarginsCore(flowElements[i], containerHeight, verticalAlign); 3652 } 3653 } 3654}; 3655ASPx.AdjustVerticalMargins = function(element) { 3656 ASPx.ClearVerticalMargins(element); 3657 var parentElement = element.parentNode; 3658 var parentHeight = parentElement.getBoundingClientRect().height - ASPx.GetTopBottomBordersAndPaddingsSummaryValue(parentElement); 3659 adjustVerticalMarginsCore(element, parentHeight, ASPx.GetCurrentStyle(parentElement).verticalAlign); 3660}; 3661function adjustVerticalMarginsCore(element, parentHeight, verticalAlign, toBottom) { 3662 var marginTop; 3663 if(verticalAlign == "top") 3664 marginTop = 0; 3665 else if(verticalAlign == "bottom") 3666 marginTop = parentHeight - element.getBoundingClientRect().height; 3667 else
3668 marginTop = (parentHeight - element.getBoundingClientRect().height) / 2; 3669 if(marginTop !== 0){ 3670 element.style.marginTop = marginTop + "px"; 3671 } 3672} 3673ASPx.ClearVerticalMargins = function(element) { 3674 element.style.marginTop = ""; 3675 element.style.marginBottom = ""; 3676}; 3677ASPx.AdjustHeightInContainer = function(container) { 3678 var height = container.offsetHeight - ASPx.GetTopBottomBordersAndPaddingsSummaryValue(container); 3679 for(var i = 0; i < container.childNodes.length; i++) { 3680 var element = container.childNodes[i]; 3681 if(!element.offsetHeight) continue; 3682 ASPx.ClearHeight(element); 3683 } 3684 var elements = []; 3685 var childrenHeight = 0; 3686 for(var i = 0; i < container.childNodes.length; i++) { 3687 var element = container.childNodes[i]; 3688 if(!element.offsetHeight) continue; 3689 childrenHeight += element.offsetHeight + ASPx.GetTopBottomMargins(element); 3690 elements.push(element); 3691 } 3692 if(elements.length > 0 && childrenHeight < height) { 3693 var correctedHeight = 0; 3694 for(var i = 0; i < elements.length; i++) { 3695 var elementHeight = 0; 3696 if(i < elements.length - 1){ 3697 var elementHeight = Math.floor(height / elements.length); 3698 correctedHeight += elementHeight; 3699 } 3700 else{ 3701 var elementHeight = height - correctedHeight; 3702 if(elementHeight < 0) elementHeight = 0; 3703 } 3704 adjustHeightCore(elements[i], elementHeight); 3705 } 3706 } 3707}; 3708ASPx.AdjustHeight = function(element) { 3709 ASPx.ClearHeight(element); 3710 var parentElement = element.parentNode; 3711 var height = parentElement.getBoundingClientRect().height - ASPx.GetTopBottomBordersAndPaddingsSummaryValue(parentElement); 3712 adjustHeightCore(element, height); 3713}; 3714function adjustHeightCore(element, height) { 3715 var height = height - ASPx.GetTopBottomBordersAndPaddingsSummaryValue(element); 3716 if(height < 0) height = 0; 3717 element.style.height = height + "px"; 3718} 3719ASPx.ClearHeight = function(element) { 3720 element.style.height = ""; 3721}; 3722ASPx.ShrinkWrappedTextInContainer = function(container) { 3723 if(!container) return; 3724 for(var i = 0; i < container.childNodes.length; i++){ 3725 var child = container.childNodes[i]; 3726 if(child.style && ASPx.IsTextWrapped(child)) { 3727 Attr.ChangeStyleAttribute(child, "width", "1px"); 3728 child.shrinkedTextContainer = true; 3729 } 3730 } 3731}; 3732ASPx.AdjustWrappedTextInContainer = function(container) { 3733 if(!container) return; 3734 var textContainer, leftWidth = 0, rightWidth = 0; 3735 for(var i = 0; i < container.childNodes.length; i++){ 3736 var child = container.childNodes[i]; 3737 if(child.tagName === "BR") 3738 return; 3739 if(!child.tagName) 3740 continue; 3741 if(child.tagName !== "IMG"){ 3742 textContainer = child; 3743 if(ASPx.IsTextWrapped(textContainer)){ 3744 if(!textContainer.shrinkedTextContainer) 3745 textContainer.style.width = ""; 3746 textContainer.style.marginRight = ""; 3747 } 3748 } 3749 else { 3750 if(ASPx.GetElementOffsetWidth(child)=== 0) 3751 Evt.AttachEventToElement(child, "load", function(evt) { ASPx.AdjustWrappedTextInContainer(container); }); 3752 else { 3753 var width = ASPx.GetElementOffsetWidth(child) + ASPx.GetLeftRightMargins(child); 3754 if(textContainer) 3755 rightWidth += width; 3756 else 3757 leftWidth += width; 3758 } 3759 } 3760 } 3761 if(textContainer && ASPx.IsTextWrapped(textContainer)) { 3762 var containerWidth = ASPx.GetElementOffsetWidth(container) - ASPx.GetLeftRightBordersAndPaddingsSummaryValue(container); 3763 if(textContainer.shrinkedTextContainer) { 3764 Attr.RestoreStyleAttribute(textContainer, "width"); 3765 Attr.ChangeStyleAttribute(container, "width", containerWidth + "px"); 3766 } 3767 if(ASPx.GetElementOffsetWidth(textContainer) + leftWidth + rightWidth >= containerWidth) { 3768 if(rightWidth > 0 && !textContainer.shrinkedTextContainer) 3769 textContainer.style.width = (containerWidth - rightWidth) + "px"; 3770 else if(leftWidth > 0){ 3771 if(ASPx.IsElementRightToLeft(container)) 3772 textContainer.style.marginLeft = leftWidth + "px"; 3773 else 3774 textContainer.style.marginRight = leftWidth + "px"; 3775 } 3776 } 3777 } 3778}; 3779ASPx.IsTextWrapped = function(element) { 3780 return element && ASPx.GetCurrentStyle(element).whiteSpace !== "nowrap"; 3781}; 3782ASPx.IsValidPosition = function(pos){ 3783 return pos != ASPx.InvalidPosition && pos != -ASPx.InvalidPosition; 3784}; 3785ASPx.getSpriteMainElement = function(element) { 3786 var cssClassMarker = "dx-acc"; 3787 if(ASPx.ElementContainsCssClass(element, cssClassMarker)) 3788 return element; 3789 if(element.parentNode && ASPx.ElementContainsCssClass(element.parentNode, cssClassMarker)) 3790 return element.parentNode; 3791 return element; 3792}; 3793ASPx.GetAbsoluteX = function(curEl){ 3794 return ASPx.GetAbsolutePositionX(curEl); 3795};
3796ASPx.GetAbsoluteY = function(curEl){ 3797 return ASPx.GetAbsolutePositionY(curEl); 3798}; 3799ASPx.SetAbsoluteX = function(element, x){ 3800 element.style.left = ASPx.PrepareClientPosForElement(x, element, true) + "px"; 3801}; 3802ASPx.SetAbsoluteY = function(element, y){ 3803 element.style.top = ASPx.PrepareClientPosForElement(y, element, false) + "px"; 3804}; 3805ASPx.GetAbsolutePositionX = function(element){ 3806 if(Browser.IE) 3807 return getAbsolutePositionX_IE(element); 3808 else if(Browser.Firefox && Browser.Version >= 3) 3809 return getAbsolutePositionX_FF3(element); 3810 else if(Browser.Opera) 3811 return getAbsolutePositionX_Opera(element); 3812 else if(Browser.NetscapeFamily && (!Browser.Firefox || Browser.Version < 3)) 3813 return getAbsolutePositionX_NS(element); 3814 else if(Browser.WebKitFamily || Browser.Edge) 3815 return getAbsolutePositionX_FF3(element); 3816 else 3817 return getAbsolutePositionX_Other(element); 3818}; 3819function getAbsolutePositionX_Opera(curEl){ 3820 var isFirstCycle = true; 3821 var pos = getAbsoluteScrollOffset_OperaFF(curEl, true); 3822 while(curEl != null) { 3823 pos += curEl.offsetLeft; 3824 if(!isFirstCycle) 3825 pos -= curEl.scrollLeft; 3826 curEl = curEl.offsetParent; 3827 isFirstCycle = false; 3828 } 3829 pos += document.body.scrollLeft; 3830 return pos; 3831} 3832function getAbsolutePositionX_IE(element){ 3833 if(element == null || Browser.IE && element.parentNode == null) return 0; 3834 return element.getBoundingClientRect().left + ASPx.GetDocumentScrollLeft(); 3835} 3836function getAbsolutePositionX_FF3(element){ 3837 if(element == null) return 0; 3838 var x = element.getBoundingClientRect().left + ASPx.GetDocumentScrollLeft(); 3839 return x; 3840} 3841function getAbsolutePositionX_NS(curEl){ 3842 var pos = getAbsoluteScrollOffset_OperaFF(curEl, true); 3843 var isFirstCycle = true; 3844 while(curEl != null) { 3845 pos += curEl.offsetLeft; 3846 if(!isFirstCycle && curEl.offsetParent != null) 3847 pos -= curEl.scrollLeft; 3848 if(!isFirstCycle && Browser.Firefox){ 3849 var style = ASPx.GetCurrentStyle(curEl); 3850 if(curEl.tagName == "DIV" && style.overflow != "visible") 3851 pos += ASPx.PxToInt(style.borderLeftWidth); 3852 } 3853 isFirstCycle = false; 3854 curEl = curEl.offsetParent; 3855 } 3856 return pos; 3857} 3858function getAbsolutePositionX_Other(curEl){ 3859 var pos = 0; 3860 var isFirstCycle = true; 3861 while(curEl != null) { 3862 pos += curEl.offsetLeft; 3863 if(!isFirstCycle && curEl.offsetParent != null) 3864 pos -= curEl.scrollLeft; 3865 isFirstCycle = false; 3866 curEl = curEl.offsetParent; 3867 } 3868 return pos; 3869} 3870ASPx.GetAbsolutePositionY = function(element){ 3871 if(Browser.IE) 3872 return getAbsolutePositionY_IE(element); 3873 else if(Browser.Firefox && Browser.Version >= 3) 3874 return getAbsolutePositionY_FF3(element); 3875 else if(Browser.Opera) 3876 return getAbsolutePositionY_Opera(element); 3877 else if(Browser.NetscapeFamily && (!Browser.Firefox || Browser.Version < 3)) 3878 return getAbsolutePositionY_NS(element); 3879 else if(Browser.WebKitFamily || Browser.Edge) 3880 return getAbsolutePositionY_FF3(element); 3881 else 3882 return getAbsolutePositionY_Other(element); 3883}; 3884function getAbsolutePositionY_Opera(curEl){ 3885 var isFirstCycle = true; 3886 if(curEl && curEl.tagName == "TR" && curEl.cells.length > 0) 3887 curEl = curEl.cells[0]; 3888 var pos = getAbsoluteScrollOffset_OperaFF(curEl, false); 3889 while(curEl != null) { 3890 pos += curEl.offsetTop; 3891 if(!isFirstCycle) 3892 pos -= curEl.scrollTop; 3893 curEl = curEl.offsetParent; 3894 isFirstCycle = false; 3895 } 3896 pos += document.body.scrollTop; 3897 return pos; 3898} 3899function getAbsolutePositionY_IE(element){ 3900 if(element == null || Browser.IE && element.parentNode == null) return 0; 3901 return element.getBoundingClientRect().top + ASPx.GetDocumentScrollTop(); 3902} 3903function getAbsolutePositionY_FF3(element){ 3904 if(element == null) return 0; 3905 var y = element.getBoundingClientRect().top + ASPx.GetDocumentScrollTop(); 3906 return y; 3907} 3908function getAbsolutePositionY_NS(curEl){ 3909 var pos = getAbsoluteScrollOffset_OperaFF(curEl, false); 3910 var isFirstCycle = true; 3911 while(curEl != null) { 3912 pos += curEl.offsetTop; 3913 if(!isFirstCycle && curEl.offsetParent != null) 3914 pos -= curEl.scrollTop; 3915 if(!isFirstCycle && Browser.Firefox){ 3916 var style = ASPx.GetCurrentStyle(curEl); 3917 if(curEl.tagName == "DIV" && style.overflow != "visible") 3918 pos += ASPx.PxToInt(style.borderTopWidth); 3919 } 3920 isFirstCycle = false; 3921 curEl = curEl.offsetParent; 3922 } 3923 return pos; 3924} 3925function getAbsoluteScrollOffset_OperaFF(curEl, isX) { 3926 var pos = 0; 3927 var isFirstCycle = true; 3928 while(curEl != null) { 3929 if(curEl.tagName == "BODY") 3930 break; 3931 var style = ASPx.GetCurrentStyle(curEl); 3932 if(style.position == "absolute") 3933 break; 3934 if(!isFirstCycle && curEl.tagName == "DIV" && (style.position == "" || style.position == "static")) 3935 pos -= isX ? curEl.scrollLeft : curEl.scrollTop; 3936 curEl = curEl.parentNode; 3937 isFirstCycle = false; 3938 } 3939 return pos; 3940} 3941function getAbsolutePositionY_Other(curEl){ 3942 var pos = 0; 3943 var isFirstCycle = true; 3944 while(curEl != null) { 3945 pos += curEl.offsetTop; 3946 if(!isFirstCycle && curEl.offsetParent != null) 3947 pos -= curEl.scrollTop; 3948 isFirstCycle = false; 3949 curEl = curEl.offsetParent; 3950 } 3951 return pos; 3952} 3953function createElementMock(element) { 3954 var div = document.createElement('DIV'); 3955 div.style.top = "0px";
3956 div.style.left = "0px"; 3957 div.visibility = "hidden"; 3958 div.style.position = ASPx.GetCurrentStyle(element).position; 3959 return div; 3960} 3961ASPx.PrepareClientPosElementForOtherParent = function(pos, element, otherParent, isX) { 3962 if(element.parentNode == otherParent) 3963 return ASPx.PrepareClientPosForElement(pos, element, isX); 3964 var elementMock = createElementMock(element); 3965 otherParent.appendChild(elementMock); 3966 var preparedPos = ASPx.PrepareClientPosForElement(pos, elementMock, isX); 3967 otherParent.removeChild(elementMock); 3968 return preparedPos; 3969}; 3970ASPx.PrepareClientPosForElement = function(pos, element, isX) { 3971 pos -= ASPx.GetPositionElementOffset(element, isX); 3972 return pos; 3973}; 3974function getExperimentalPositionOffset(element, isX) { 3975 var div = createElementMock(element); 3976 if(div.style.position == "static") 3977 div.style.position = "absolute"; 3978 element.parentNode.appendChild(div); 3979 var realPos = isX ? ASPx.GetAbsoluteX(div) : ASPx.GetAbsoluteY(div); 3980 element.parentNode.removeChild(div); 3981 return realPos; 3982} 3983ASPx.GetPositionElementOffset = function(element, isX) { 3984 return getExperimentalPositionOffset(element, isX); 3985}; 3986ASPx.GetSizeOfText = function(text, textCss) { 3987 var testContainer = document.createElement("tester"); 3988 var defaultLineHeight = ASPx.Browser.Firefox ? "1" : ""; 3989 testContainer.style.fontSize = textCss.fontSize; 3990 testContainer.style.fontFamily = textCss.fontFamily; 3991 testContainer.style.fontWeight = textCss.fontWeight; 3992 testContainer.style.letterSpacing = textCss.letterSpacing; 3993 testContainer.style.lineHeight = textCss.lineHeight || defaultLineHeight; 3994 testContainer.style.position = "absolute"; 3995 testContainer.style.top = ASPx.InvalidPosition + "px"; 3996 testContainer.style.left = ASPx.InvalidPosition + "px"; 3997 testContainer.style.width = "auto"; 3998 testContainer.style.whiteSpace = "nowrap"; 3999 testContainer.appendChild(document.createTextNode(text)); 4000 var testElement = document.body.appendChild(testContainer); 4001 var size = { 4002 "width": testElement.offsetWidth, 4003 "height": testElement.offsetHeight 4004 }; 4005 document.body.removeChild(testElement); 4006 return size; 4007}; 4008ASPx.PointToPixel = function(points, addPx) { 4009 var result = 0; 4010 try { 4011 var indexOfPt = points.toLowerCase().indexOf("pt"); 4012 if(indexOfPt > -1) 4013 result = parseInt(points.substr(0, indexOfPt)) * 96 / 72; 4014 else 4015 result = parseInt(points) * 96 / 72; 4016 if(addPx) 4017 result = result + "px"; 4018 } catch(e) {} 4019 return result; 4020}; 4021ASPx.PixelToPoint = function(pixels, addPt) { 4022 var result = 0; 4023 try { 4024 var indexOfPx = pixels.toLowerCase().indexOf("px"); 4025 if(indexOfPx > -1) 4026 result = parseInt(pixels.substr(0, indexOfPx)) * 72 / 96; 4027 else 4028 result = parseInt(pixels) * 72 / 96; 4029 if(addPt) 4030 result = result + "pt"; 4031 } catch(e) {} 4032 return result; 4033}; 4034ASPx.PxToInt = function(px) { 4035 return pxToNumber(px, parseInt); 4036}; 4037ASPx.PxToFloat = function(px) { 4038 return pxToNumber(px, parseFloat); 4039}; 4040function pxToNumber(px, parseFunction) { 4041 var result = 0; 4042 if(px != null && px != "") { 4043 try { 4044 var indexOfPx = px.indexOf("px"); 4045 if(indexOfPx > -1) 4046 result = parseFunction(px.substr(0, indexOfPx)); 4047 } catch(e) { } 4048 } 4049 return result; 4050} 4051ASPx.PercentageToFloat = function(perc) { 4052 var result = 0; 4053 if(perc != null && perc != "") { 4054 try { 4055 var indexOfPerc = perc.indexOf("%"); 4056 if(indexOfPerc > -1) 4057 result = parseFloat(perc.substr(0, indexOfPerc)) / 100; 4058 } catch(e) { } 4059 } 4060 return result; 4061}; 4062ASPx.CreateGuid = function() { 4063 return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { 4064 var r = Math.random()*16|0,v=c=='x'?r:r&0x3|0x8; 4065 return v.toString(16); 4066 }); 4067}; 4068ASPx.GetLeftRightBordersAndPaddingsSummaryValue = function(element, currentStyle) { 4069 return ASPx.GetLeftRightPaddings(element, currentStyle) + ASPx.GetHorizontalBordersWidth(element, currentStyle); 4070}; 4071ASPx.GetTopBottomBordersAndPaddingsSummaryValue = function(element, currentStyle) { 4072 return ASPx.GetTopBottomPaddings(element, currentStyle) + ASPx.GetVerticalBordersWidth(element, currentStyle); 4073}; 4074ASPx.GetVerticalBordersWidth = function(element, style) { 4075 if(!ASPx.IsExists(style)) 4076 style = (Browser.IE && Browser.MajorVersion != 9 && window.getComputedStyle) ? window.getComputedStyle(element) : ASPx.GetCurrentStyle(element); 4077 var res = 0; 4078 if(style.borderTopStyle != "none") { 4079 res += ASPx.PxToFloat(style.borderTopWidth); 4080 if(Browser.IE && Browser.MajorVersion < 9) 4081 res += getIe8BorderWidthFromText(style.borderTopWidth); 4082 } 4083 if(style.borderBottomStyle != "none") { 4084 res += ASPx.PxToFloat(style.borderBottomWidth);
4085 if(Browser.IE && Browser.MajorVersion < 9) 4086 res += getIe8BorderWidthFromText(style.borderBottomWidth); 4087 } 4088 return res; 4089}; 4090ASPx.GetHorizontalBordersWidth = function(element, style) { 4091 if(!ASPx.IsExists(style)) 4092 style = (Browser.IE && window.getComputedStyle) ? window.getComputedStyle(element) : ASPx.GetCurrentStyle(element); 4093 var res = 0; 4094 if(style.borderLeftStyle != "none") { 4095 res += ASPx.PxToFloat(style.borderLeftWidth); 4096 if(Browser.IE && Browser.MajorVersion < 9) 4097 res += getIe8BorderWidthFromText(style.borderLeftWidth); 4098 } 4099 if(style.borderRightStyle != "none") { 4100 res += ASPx.PxToFloat(style.borderRightWidth); 4101 if(Browser.IE && Browser.MajorVersion < 9) 4102 res += getIe8BorderWidthFromText(style.borderRightWidth); 4103 } 4104 return res; 4105}; 4106function getIe8BorderWidthFromText(textWidth) { 4107 var availableWidth = { "thin": 1, "medium" : 3, "thick": 5 }; 4108 var width = availableWidth[textWidth]; 4109 return width ? width : 0; 4110} 4111ASPx.GetTopBottomPaddings = function(element, style) { 4112 var currentStyle = style ? style : ASPx.GetCurrentStyle(element); 4113 return ASPx.PxToInt(currentStyle.paddingTop) + ASPx.PxToInt(currentStyle.paddingBottom); 4114}; 4115ASPx.GetTopPaddings = function(element, style) { 4116 var currentStyle = style ? style : ASPx.GetCurrentStyle(element); 4117 return ASPx.PxToInt(currentStyle.paddingTop); 4118}; 4119ASPx.GetBottomPaddings = function(element, style) { 4120 var currentStyle = style ? style : ASPx.GetCurrentStyle(element); 4121 return ASPx.PxToInt(currentStyle.paddingBottom); 4122}; 4123ASPx.GetLeftRightPaddings = function(element, style) { 4124 var currentStyle = style ? style : ASPx.GetCurrentStyle(element); 4125 return ASPx.PxToInt(currentStyle.paddingLeft) + ASPx.PxToInt(currentStyle.paddingRight); 4126}; 4127ASPx.GetTopBottomMargins = function(element, style) { 4128 var currentStyle = style ? style : ASPx.GetCurrentStyle(element); 4129 return ASPx.PxToInt(currentStyle.marginTop) + ASPx.PxToInt(currentStyle.marginBottom); 4130}; 4131ASPx.GetLeftRightMargins = function(element, style) { 4132 var currentStyle = style ? style : ASPx.GetCurrentStyle(element); 4133 return ASPx.PxToInt(currentStyle.marginLeft) + ASPx.PxToInt(currentStyle.marginRight); 4134}; 4135ASPx.GetClearClientWidth = function(element) { 4136 return ASPx.GetElementOffsetWidth(element)- ASPx.GetLeftRightBordersAndPaddingsSummaryValue(element); 4137}; 4138ASPx.GetClearClientHeight = function(element) { 4139 return ASPx.GetElementOffsetHeight(element) - ASPx.GetTopBottomBordersAndPaddingsSummaryValue(element); 4140}; 4141ASPx.SetOffsetWidth = function(element, widthValue, currentStyle) { 4142 if(!ASPx.IsExists(currentStyle)) 4143 currentStyle = ASPx.GetCurrentStyle(element); 4144 var value = widthValue - ASPx.PxToInt(currentStyle.marginLeft) - ASPx.PxToInt(currentStyle.marginRight); 4145 value -= ASPx.GetLeftRightBordersAndPaddingsSummaryValue(element, currentStyle); 4146 if(value > -1) 4147 element.style.width = value + "px"; 4148}; 4149ASPx.SetOffsetHeight = function(element, heightValue, currentStyle) { 4150 if(!ASPx.IsExists(currentStyle)) 4151 currentStyle = ASPx.GetCurrentStyle(element); 4152 var value = heightValue - ASPx.PxToInt(currentStyle.marginTop) - ASPx.PxToInt(currentStyle.marginBottom); 4153 value -= ASPx.GetTopBottomBordersAndPaddingsSummaryValue(element, currentStyle); 4154 if(value > -1) 4155 element.style.height = value + "px"; 4156}; 4157ASPx.FindOffsetParent = function(element) { 4158 var currentElement = element.parentNode; 4159 while(ASPx.IsExistsElement(currentElement) && currentElement.tagName != "BODY") { 4160 if(ASPx.GetElementOffsetWidth(currentElement) > 0 && ASPx.GetElementOffsetHeight(currentElement) > 0) 4161 return currentElement; 4162 currentElement = currentElement.parentNode; 4163 } 4164 return document.body; 4165}; 4166ASPx.GetDocumentScrollTop = function(){ 4167 var isScrollBodyIE = Browser.IE && ASPx.GetCurrentStyle(document.body).overflow == "hidden" && document.body.scrollTop > 0; 4168 if(Browser.WebKitFamily || Browser.Edge || isScrollBodyIE) { 4169 if(Browser.MacOSMobilePlatform) 4170 return window.pageYOffset; 4171 if(Browser.WebKitFamily) 4172 return document.documentElement.scrollTop || document.body.scrollTop; 4173 return document.body.scrollTop; 4174 } 4175 else 4176 return document.documentElement.scrollTop; 4177}; 4178ASPx.SetDocumentScrollTop = function(scrollTop) { 4179 if(Browser.WebKitFamily && Browser.Version < 60 || Browser.Edge) 4180 document.body.scrollTop = scrollTop; 4181 else
4182 document.documentElement.scrollTop = scrollTop; 4183}; 4184ASPx.GetDocumentScrollLeft = function(){ 4185 var isScrollBodyIE = Browser.IE && ASPx.GetCurrentStyle(document.body).overflow == "hidden" && document.body.scrollLeft > 0; 4186 if(Browser.Edge || isScrollBodyIE) 4187 return document.body ? document.body.scrollLeft : document.documentElement.scrollLeft; 4188 if(Browser.WebKitFamily) 4189 return document.documentElement.scrollLeft || document.body.scrollLeft; 4190 return document.documentElement.scrollLeft; 4191}; 4192ASPx.SetDocumentScrollLeft = function (scrollLeft) { 4193 if(Browser.WebKitFamily && Browser.Version < 60 || Browser.Edge) 4194 document.body.scrollLeft = scrollLeft; 4195 else 4196 document.documentElement.scrollLeft = scrollLeft; 4197}; 4198ASPx.GetDocumentClientWidth = function(){ 4199 if(document.documentElement.clientWidth == 0) 4200 return document.body.clientWidth; 4201 else 4202 return document.documentElement.clientWidth; 4203}; 4204ASPx.GetDocumentClientHeight = function() { 4205 if(Browser.Firefox && window.innerHeight - document.documentElement.clientHeight > ASPx.GetVerticalScrollBarWidth()) { 4206 return window.innerHeight; 4207 } else if(Browser.Opera && Browser.Version < 9.6 || document.documentElement.clientHeight == 0) { 4208 return document.body.clientHeight; 4209 } 4210 return document.documentElement.clientHeight; 4211}; 4212ASPx.GetDocumentWidth = function(){ 4213 var bodyWidth = document.body.offsetWidth; 4214 var docWidth = Browser.IE ? document.documentElement.clientWidth : document.documentElement.offsetWidth; 4215 var bodyScrollWidth = document.body.scrollWidth; 4216 var docScrollWidth = document.documentElement.scrollWidth; 4217 return getMaxDimensionOf(bodyWidth, docWidth, bodyScrollWidth, docScrollWidth); 4218}; 4219ASPx.GetDocumentHeight = function(){ 4220 var bodyHeight = document.body.offsetHeight; 4221 var docHeight = Browser.IE ? document.documentElement.clientHeight : document.documentElement.offsetHeight; 4222 var bodyScrollHeight = document.body.scrollHeight; 4223 var docScrollHeight = document.documentElement.scrollHeight; 4224 var maxHeight = getMaxDimensionOf(bodyHeight, docHeight, bodyScrollHeight, docScrollHeight); 4225 if(Browser.Opera && Browser.Version >= 9.6){ 4226 if(Browser.Version < 10) 4227 maxHeight = getMaxDimensionOf(bodyHeight, docHeight, bodyScrollHeight); 4228 var visibleHeightOfDocument = document.documentElement.clientHeight; 4229 if(maxHeight > visibleHeightOfDocument) 4230 maxHeight = getMaxDimensionOf(window.outerHeight, maxHeight); 4231 else 4232 maxHeight = document.documentElement.clientHeight; 4233 return maxHeight; 4234 } 4235 return maxHeight; 4236}; 4237ASPx.GetDocumentMaxClientWidth = function(){ 4238 var bodyWidth = document.body.offsetWidth; 4239 var docWidth = document.documentElement.offsetWidth; 4240 var docClientWidth = document.documentElement.clientWidth; 4241 return getMaxDimensionOf(bodyWidth, docWidth, docClientWidth); 4242}; 4243ASPx.GetDocumentMaxClientHeight = function(){ 4244 var bodyHeight = document.body.offsetHeight; 4245 var docHeight = document.documentElement.offsetHeight; 4246 var docClientHeight = document.documentElement.clientHeight; 4247 return getMaxDimensionOf(bodyHeight, docHeight, docClientHeight); 4248}; 4249ASPx.verticalScrollIsNotHidden = null; 4250ASPx.horizontalScrollIsNotHidden = null; 4251ASPx.GetVerticalScrollIsNotHidden = function() { 4252 if(!ASPx.IsExists(ASPx.verticalScrollIsNotHidden)) 4253 ASPx.verticalScrollIsNotHidden = ASPx.GetCurrentStyle(document.body).overflowY !== "hidden" 4254 && ASPx.GetCurrentStyle(document.documentElement).overflowY !== "hidden"; 4255 return ASPx.verticalScrollIsNotHidden; 4256}; 4257ASPx.GetHorizontalScrollIsNotHidden = function() { 4258 if(!ASPx.IsExists(ASPx.horizontalScrollIsNotHidden)) 4259 ASPx.horizontalScrollIsNotHidden = ASPx.GetCurrentStyle(document.body).overflowX !== "hidden" 4260 && ASPx.GetCurrentStyle(document.documentElement).overflowX !== "hidden"; 4261 return ASPx.horizontalScrollIsNotHidden; 4262}; 4263ASPx.GetCurrentDocumentWidth = function() { 4264 var result = ASPx.GetDocumentClientWidth(); 4265 if(!ASPx.Browser.Safari && ASPx.GetVerticalScrollIsNotHidden() && ASPx.GetDocumentHeight() > ASPx.GetDocumentClientHeight()) 4266 result += ASPx.GetVerticalScrollBarWidth(); 4267 return result; 4268}; 4269ASPx.GetCurrentDocumentHeight = function() { 4270 var result = ASPx.GetDocumentClientHeight(); 4271 if(!ASPx.Browser.Safari && ASPx.GetHorizontalScrollIsNotHidden() && ASPx.GetDocumentWidth() > ASPx.GetDocumentClientWidth()) 4272 result += ASPx.GetVerticalScrollBarWidth(); 4273 return result; 4274}; 4275function getMaxDimensionOf(){ 4276 var max = ASPx.InvalidDimension; 4277 for(var i = 0; i < arguments.length; i++){ 4278 if(max < arguments[i]) 4279 max = arguments[i]; 4280 } 4281 return max; 4282} 4283ASPx.GetClientLeft = function(element) { 4284 return ASPx.IsExists(element.clientLeft) ? element.clientLeft : (ASPx.GetElementOffsetWidth(element)- element.clientWidth) / 2; 4285}; 4286ASPx.GetClientTop = function(element) { 4287 return ASPx.IsExists(element.clientTop) ? element.clientTop : (ASPx.GetElementOffsetHeight(element) - element.clientHeight) / 2; 4288}; 4289var requestAnimationFrameFunc = window.requestAnimationFrame || function(callback) { callback(); }; 4290var cancelAnimationFrameFunc = window.cancelAnimationFrame || function(id) { }; 4291ASPx.CancelAnimationFrame = function(id) { cancelAnimationFrameFunc(id); }; 4292ASPx.RequestAnimationFrame = function (callback) { return requestAnimationFrameFunc(callback); }; 4293ASPx.SetStyles = function(element, styles, makeImportant) { 4294 if(ASPx.IsExists(styles.cssText)) 4295 element.style.cssText = styles.cssText; 4296 if(ASPx.IsExists(styles.className)) { 4297 ASPx.SetClassName(element, styles.className); 4298 } 4299 for(var property in styles) { 4300 if(!styles.hasOwnProperty(property)) 4301 continue; 4302 var value = styles[property]; 4303 switch (property) { 4304 case "cssText": 4305 case "className": 4306 break; 4307 case "float": 4308 ASPx.SetElementFloat(element, value); 4309 break; 4310 case "opacity": 4311 ASPx.SetElementOpacity(element, value); 4312 break; 4313 case "zIndex": 4314 ASPx.SetStylesCore(element, property, value, makeImportant); 4315 break; 4316 case "fontWeight": 4317 if(ASPx.Browser.IE && ASPx.Browser.Version < 9 && typeof(styles[property]) == "number") 4318 value = styles[property].toString(); 4319 default: 4320 ASPx.SetStylesCore(element, property, value + (typeof (value) == "number" ? "px" : ""), makeImportant); 4321 } 4322 } 4323}; 4324ASPx.SetStylesCore = function(element, property, value, makeImportant) { 4325 if(makeImportant) { 4326 var index = property.search("[A-Z]"); 4327 if(index != -1) 4328 property = property.replace(property.charAt(index), "-" + property.charAt(index).toLowerCase()); 4329 if(element.style.setProperty) 4330 element.style.setProperty(property, value, "important"); 4331 else 4332 element.style.cssText += ";" + property + ":" + value + "!important"; 4333 } 4334 else 4335 element.style[property] = value; 4336}; 4337ASPx.RemoveBordersAndShadows = function(el) { 4338 if(!el || !el.style) 4339 return; 4340 el.style.borderWidth = 0; 4341 if(ASPx.IsExists(el.style.boxShadow)) 4342 el.style.boxShadow = "none"; 4343 else if(ASPx.IsExists(el.style.MozBoxShadow)) 4344 el.style.MozBoxShadow = "none"; 4345 else if(ASPx.IsExists(el.style.webkitBoxShadow)) 4346 el.style.webkitBoxShadow = "none"; 4347}; 4348ASPx.GetCellSpacing = function(element) { 4349 var val = parseInt(element.cellSpacing); 4350 if(!isNaN(val)) return val; 4351 val = parseInt(ASPx.GetCurrentStyle(element).borderSpacing); 4352 if(!isNaN(val)) return val; 4353 return 0; 4354}; 4355ASPx.GetInnerScrollPositions = function(element) { 4356 var scrolls = []; 4357 getInnerScrollPositionsCore(element, scrolls); 4358 return scrolls; 4359}; 4360function getInnerScrollPositionsCore(element, scrolls) { 4361 for(var child = element.firstChild; child; child = child.nextSibling) { 4362 var scrollTop = child.scrollTop, 4363 scrollLeft = child.scrollLeft; 4364 if(scrollTop > 0 || scrollLeft > 0) 4365 scrolls.push([child, scrollTop, scrollLeft]); 4366 getInnerScrollPositionsCore(child, scrolls); 4367 } 4368} 4369ASPx.RestoreInnerScrollPositions = function(scrolls) { 4370 for(var i = 0, scrollArr; scrollArr = scrolls[i]; i++) { 4371 if(scrollArr[1] > 0) 4372 scrollArr[0].scrollTop = scrollArr[1]; 4373 if(scrollArr[2] > 0) 4374 scrollArr[0].scrollLeft = scrollArr[2]; 4375 } 4376}; 4377ASPx.GetOuterScrollPosition = function(element) { 4378 while(element && element.tagName !== "BODY") { 4379 var scrollTop = element.scrollTop, 4380 scrollLeft = element.scrollLeft; 4381 if(scrollTop > 0 || scrollLeft > 0) { 4382 return { 4383 scrollTop: scrollTop, 4384 scrollLeft: scrollLeft, 4385 element: element 4386 }; 4387 } 4388 element = element.parentNode; 4389 } 4390 return { 4391 scrollTop: ASPx.GetDocumentScrollTop(), 4392 scrollLeft: ASPx.GetDocumentScrollLeft() 4393 }; 4394}; 4395ASPx.RestoreOuterScrollPosition = function(scrollInfo) { 4396 if(scrollInfo.element) { 4397 if(scrollInfo.scrollTop > 0) 4398 scrollInfo.element.scrollTop = scrollInfo.scrollTop; 4399 if(scrollInfo.scrollLeft > 0) 4400 scrollInfo.element.scrollLeft = scrollInfo.scrollLeft; 4401 } 4402 else { 4403 if(scrollInfo.scrollTop > 0) 4404 ASPx.SetDocumentScrollTop(scrollInfo.scrollTop); 4405 if(scrollInfo.scrollLeft > 0) 4406 ASPx.SetDocumentScrollLeft(scrollInfo.scrollLeft); 4407 } 4408}; 4409ASPx.ChangeElementContainer = function(element, container, savePreviousContainer) { 4410 if(element.parentNode != container) { 4411 var parentNode = element.parentNode; 4412 parentNode.removeChild(element);
4413 container.appendChild(element); 4414 if(savePreviousContainer) 4415 element.previousContainer = parentNode; 4416 } 4417}; 4418ASPx.RestoreElementContainer = function(element) { 4419 if(element.previousContainer) { 4420 ASPx.ChangeElementContainer(element, element.previousContainer, false); 4421 element.previousContainer = null; 4422 } 4423}; 4424ASPx.MoveChildrenToElement = function(sourceElement, destinationElement){ 4425 while(sourceElement.childNodes.length > 0) 4426 destinationElement.appendChild(sourceElement.childNodes[0]); 4427}; 4428ASPx.GetScriptCode = function(script) { 4429 var useFirstChildElement = Browser.Chrome && Browser.Version < 11 || Browser.Safari && Browser.Version < 5; 4430 var text = useFirstChildElement ? script.firstChild.data : script.text; 4431 var comment = "<!--"; 4432 var pos = text.indexOf(comment); 4433 if(pos > -1) 4434 text = text.substr(pos + comment.length); 4435 return text; 4436}; 4437ASPx.AppendScript = function(script) { 4438 var parent = document.getElementsByTagName("head")[0]; 4439 if(!parent) 4440 parent = document.body; 4441 if(parent) 4442 parent.appendChild(script); 4443}; 4444function getFrame(frames, name) { 4445 if(frames[name]) 4446 return frames[name]; 4447 for(var i = 0; i < frames.length; i++) { 4448 try { 4449 var frame = frames[i]; 4450 if(frame.name == name) 4451 return frame; 4452 frame = getFrame(frame.frames, name); 4453 if(frame != null) 4454 return frame; 4455 } catch(e) { 4456 } 4457 } 4458 return null; 4459} 4460ASPx.IsValidElement = function(element) { 4461 if(!element) 4462 return false; 4463 if(!(Browser.Firefox && Browser.Version < 4)) { 4464 if(element.ownerDocument && element.ownerDocument.body && element.ownerDocument.body.compareDocumentPosition) 4465 return element.ownerDocument.body.compareDocumentPosition(element) % 2 === 0; 4466 } 4467 if(!Browser.Opera && !(Browser.IE && Browser.Version < 9) && element.offsetParent && element.parentNode.tagName) 4468 return true; 4469 while(element != null){ 4470 if(element.tagName == "BODY") 4471 return true; 4472 element = element.parentNode; 4473 } 4474 return false; 4475}; 4476ASPx.IsValidElements = function(elements) { 4477 if(!elements) 4478 return false; 4479 for(var i = 0; i < elements.length; i++) { 4480 if(elements[i] && !ASPx.IsValidElement(elements[i])) 4481 return false; 4482 } 4483 return true; 4484}; 4485ASPx.IsExistsElement = function(element) { 4486 return element && ASPx.IsValidElement(element); 4487}; 4488ASPx.CreateHtmlElementFromString = function(str) { 4489 var dummy = ASPx.CreateHtmlElement(); 4490 setInnerHtmlInternal(dummy, str); 4491 return dummy.firstChild; 4492}; 4493ASPx.CreateHtmlElement = function(tagName, styles) { 4494 var element = document.createElement(tagName || "DIV"); 4495 if(styles) 4496 ASPx.SetStyles(element, styles); 4497 return element; 4498}; 4499ASPx.RestoreElementOriginalWidth = function(element) { 4500 if(!ASPx.IsExistsElement(element)) 4501 return; 4502 element.style.width = element.dxOrigWidth = ASPx.GetElementOriginalWidth(element); 4503}; 4504ASPx.GetElementOriginalWidth = function(element) { 4505 if(!ASPx.IsExistsElement(element)) 4506 return null; 4507 var width; 4508 if(!ASPx.IsExists(element.dxOrigWidth)) { 4509 width = String(element.style.width).length > 0 4510 ? element.style.width 4511 : ASPx.GetElementOffsetWidth(element) + "px"; 4512 } else { 4513 width = element.dxOrigWidth; 4514 } 4515 return width; 4516}; 4517ASPx.DropElementOriginalWidth = function(element) { 4518 if(ASPx.IsExists(element.dxOrigWidth)) 4519 element.dxOrigWidth = null; 4520}; 4521ASPx.GetObjectKeys = function(obj) { 4522 if(!obj) return [ ]; 4523 if(Object.keys) 4524 return Object.keys(obj); 4525 var keys = [ ]; 4526 for(var key in obj) { 4527 if(obj.hasOwnProperty(key)) 4528 keys.push(key); 4529 } 4530 return keys; 4531}; 4532ASPx.ShowErrorAlert = function(message) { 4533 message = ASPx.Str.DecodeHtmlViaTextArea(message); 4534 if(ASPx.IsExists(message) && message !== "") 4535 alert(message); 4536}; 4537ASPx.ShowKBErrorMessage = function(text, kbid) { 4538 ASPx.ShowErrorMessage(text + "https://www.devexpress.com/kbid=" + kbid + "."); 4539}; 4540ASPx.ShowErrorMessage = function(errorMessage) { 4541 var console = window.console; 4542 if(!console || !ASPx.IsFunction(console.error)) 4543 return; 4544 console.error(errorMessage); 4545}; 4546ASPx.IsInteractiveControl = function(element, extremeParent) { 4547 return Data.ArrayIndexOf(["A", "INPUT", "SELECT", "OPTION", "TEXTAREA", "BUTTON", "IFRAME"], element.tagName) > -1; 4548};
4549ASPx.IsUrlContainsClientScript = function(url) { 4550 return url.toLowerCase().indexOf("javascript:") !== -1; 4551}; 4552ASPx.GetMSAjaxRequestManager = function() { 4553 if(window.Sys && Sys.WebForms && Sys.WebForms.PageRequestManager && Sys.WebForms.PageRequestManager.getInstance) 4554 return Sys.WebForms.PageRequestManager.getInstance(); 4555 return null; 4556}; 4557Function.prototype.aspxBind = function(scope) { 4558 var func = this; 4559 return function() { 4560 return func.apply(scope, arguments); 4561 }; 4562}; 4563var FilteringUtils = { }; 4564FilteringUtils.EventKeyCodeChangesTheInput = function(evt) { 4565 if(ASPx.IsPasteShortcut(evt)) 4566 return true; 4567 else if(evt.ctrlKey && !evt.altKey) 4568 return false; 4569 if(ASPx.Browser.AndroidMobilePlatform || ASPx.Browser.MacOSMobilePlatform) return true; 4570 var keyCode = ASPx.Evt.GetKeyCode(evt); 4571 var isSystemKey = ASPx.Key.Windows <= keyCode && keyCode <= ASPx.Key.ContextMenu; 4572 var isFKey = ASPx.Key.F1 <= keyCode && keyCode <= 127; 4573 return ASPx.Key.Delete <= keyCode && !isSystemKey && !isFKey || keyCode == ASPx.Key.Backspace || keyCode == ASPx.Key.Space; 4574}; 4575FilteringUtils.FormatCallbackArg = function(prefix, arg) { 4576 return (ASPx.IsExists(arg) ? prefix + "|" + arg.length + ';' + arg + ';' : ""); 4577}; 4578ASPx.FilteringUtils = FilteringUtils; 4579var FormatStringHelper = { }; 4580FormatStringHelper.PlaceHolderTemplateStruct = function(startIndex, length, index, placeHolderString){ 4581 this.startIndex = startIndex; 4582 this.realStartIndex = 0; 4583 this.length = length; 4584 this.realLength = 0; 4585 this.index = index; 4586 this.placeHolderString = placeHolderString; 4587}; 4588FormatStringHelper.GetPlaceHolderTemplates = function(formatString){ 4589 formatString = this.CollapseDoubleBrackets(formatString); 4590 var templates = this.CreatePlaceHolderTemplates(formatString); 4591 return templates; 4592}; 4593FormatStringHelper.CreatePlaceHolderTemplates = function(formatString){ 4594 var templates = []; 4595 var templateStrings = formatString.match(/{[^}]+}/g); 4596 if(templateStrings != null){ 4597 var pos = 0; 4598 for(var i = 0; i < templateStrings.length; i++){ 4599 var tempString = templateStrings[i]; 4600 var startIndex = formatString.indexOf(tempString, pos); 4601 var length = tempString.length; 4602 var indexString = tempString.slice(1).match(/^[0-9]+/); 4603 var index = parseInt(indexString); 4604 templates.push(new this.PlaceHolderTemplateStruct(startIndex, length, index, tempString)); 4605 pos = startIndex + length; 4606 } 4607 } 4608 return templates; 4609}; 4610FormatStringHelper.CollapseDoubleBrackets = function(formatString){ 4611 formatString = this.CollapseOpenDoubleBrackets(formatString); 4612 formatString = this.CollapseCloseDoubleBrackets(formatString); 4613 return formatString; 4614}; 4615FormatStringHelper.CollapseOpenDoubleBrackets = function(formatString){ 4616 return formatString.replace(/{{/g, "_"); 4617};
4618FormatStringHelper.CollapseCloseDoubleBrackets = function(formatString){ 4619 while(true){ 4620 var index = formatString.lastIndexOf("}}"); 4621 if(index == -1) 4622 break; 4623 else 4624 formatString = formatString.substr(0, index) + "_" + formatString.substr(index + 2); 4625 } 4626 return formatString; 4627}; 4628ASPx.FormatStringHelper = FormatStringHelper; 4629var StartWithFilteringUtils = { }; 4630StartWithFilteringUtils.HighlightSuggestedText = function(input, suggestedText, control, onChangeInput){ 4631 if(this.NeedToLockAndoidKeyEvents(control)) 4632 control.LockAndroidKeyEvents(); 4633 var selInfo = ASPx.Selection.GetInfo(input); 4634 var currentTextLenght = ASPx.Str.GetCoincideCharCount(suggestedText, input.value, 4635 function(text, filter) { 4636 return text.indexOf(filter) == 0; 4637 }); 4638 var suggestedTextLenght = suggestedText.length; 4639 var isSelected = selInfo.startPos == 0 && selInfo.endPos == currentTextLenght && 4640 selInfo.endPos == suggestedTextLenght && input.value == suggestedText; 4641 if(!isSelected) { 4642 input.value = suggestedText; 4643 if(onChangeInput) 4644 onChangeInput(); 4645 if(this.NeedToLockAndoidKeyEvents(control)) { 4646 window.setTimeout(function() { 4647 this.SelectText(input, currentTextLenght, suggestedTextLenght); 4648 control.UnlockAndroidKeyEvents(); 4649 }.aspxBind(this), control.adroidSamsungBugTimeout); 4650 } else 4651 this.SelectText(input, currentTextLenght, suggestedTextLenght); 4652 } 4653}; 4654StartWithFilteringUtils.SelectText = function(input, startPos, stopPos) { 4655 if(startPos < stopPos) 4656 ASPx.Selection.Set(input, startPos, stopPos); 4657}; 4658StartWithFilteringUtils.RollbackOneSuggestedChar = function(input){ 4659 var currentText = input.value; 4660 var cutText = currentText.slice(0, -1); 4661 if(cutText != currentText) 4662 input.value = cutText; 4663}; 4664StartWithFilteringUtils.NeedToLockAndoidKeyEvents = function(control) { 4665 return ASPx.Browser.AndroidMobilePlatform && control && control.LockAndroidKeyEvents; 4666}; 4667ASPx.StartWithFilteringUtils = StartWithFilteringUtils; 4668var ContainsFilteringUtils = { }; 4669ContainsFilteringUtils.ColumnSelectionStruct = function(index, startIndex, length){ 4670 this.index = index; 4671 this.length = length; 4672 this.startIndex = startIndex; 4673}; 4674ContainsFilteringUtils.IsFilterCrossPlaseHolder = function(filterStartIndex, filterEndIndex, template) { 4675 var left = Math.max(filterStartIndex, template.realStartIndex); 4676 var right = Math.min(filterEndIndex, template.realStartIndex + template.realLength); 4677 return left < right; 4678}; 4679ContainsFilteringUtils.GetColumnSelectionsForItem = function(itemValues, formatString, filterString) { 4680 if(formatString == "") 4681 return this.GetSelectionForSingleColumnItem(itemValues, filterString); 4682 var result = []; 4683 var formatedString = ASPx.Formatter.Format(formatString, itemValues); 4684 var filterStartIndex = ASPx.Str.PrepareStringForFilter(formatedString).indexOf(ASPx.Str.PrepareStringForFilter(filterString)); 4685 if(filterStartIndex == -1) return result; 4686 var filterEndIndex = filterStartIndex + filterString.length; 4687 var templates = FormatStringHelper.GetPlaceHolderTemplates(formatString); 4688 this.SupplyTemplatesWithRealValues(itemValues, templates); 4689 for(var i = 0; i < templates.length ; i++) { 4690 if(this.IsFilterCrossPlaseHolder(filterStartIndex, filterEndIndex, templates[i])) 4691 result.push(this.GetColumnSelectionsForItemValue(templates[i], filterStartIndex, filterEndIndex)); 4692 } 4693 return result; 4694}; 4695ContainsFilteringUtils.GetColumnSelectionsForItemValue = function(template, filterStartIndex, filterEndIndex) { 4696 var selectedTextStartIndex = filterStartIndex < template.realStartIndex ? 0 : 4697 filterStartIndex - template.realStartIndex; 4698 var selectedTextEndIndex = filterEndIndex > template.realStartIndex + template.realLength ? template.realLength : 4699 filterEndIndex - template.realStartIndex; 4700 var selectedTextLength = selectedTextEndIndex - selectedTextStartIndex; 4701 return new this.ColumnSelectionStruct(template.index, selectedTextStartIndex, selectedTextLength); 4702}; 4703ContainsFilteringUtils.GetSelectionForSingleColumnItem = function(itemValues, filterString) { 4704 var selectedTextStartIndex = ASPx.Str.PrepareStringForFilter(itemValues[0]).indexOf(ASPx.Str.PrepareStringForFilter(filterString)); 4705 var selectedTextLength = filterString.length; 4706 return [new this.ColumnSelectionStruct(0, selectedTextStartIndex, selectedTextLength)];
4707}; 4708ContainsFilteringUtils.ResetFormatStringIndex = function(formatString, index) { 4709 if(index != 0) 4710 return formatString.replace(index.toString(), "0"); 4711 return formatString; 4712}; 4713ContainsFilteringUtils.SupplyTemplatesWithRealValues = function(itemValues, templates) { 4714 var shift = 0; 4715 for(var i = 0; i < templates.length; i++) { 4716 var formatString = this.ResetFormatStringIndex(templates[i].placeHolderString, templates[i].index); 4717 var currentItemValue = itemValues[templates[i].index]; 4718 templates[i].realLength = ASPx.Formatter.Format(formatString, currentItemValue).length; 4719 templates[i].realStartIndex += templates[i].startIndex + shift; 4720 shift += templates[i].realLength - templates[i].placeHolderString.length; 4721 } 4722}; 4723ContainsFilteringUtils.PrepareElementText = function(itemText) { 4724 return itemText ? itemText.replace(/\&/g, "&").replace(/</g, "<").replace(/>/g, ">") : ''; 4725}; 4726ContainsFilteringUtils.UnselectContainsTextInElement = function(element, selection, highlightTagName) { 4727 var currentText = ASPx.Attr.GetAttribute (element, "DXText"); 4728 if(ASPx.IsExists(currentText)) { 4729 currentText = ContainsFilteringUtils.PrepareElementText(currentText); 4730 ASPx.Security.setInnerHtml(element, currentText === "" ? " " : currentText, ASPx.Security.DataType.Trusted); 4731 } 4732}; 4733ContainsFilteringUtils.ReselectContainsTextInElement = function(element, selection, highlightTagName) { 4734 var currentText = ASPx.GetInnerText(element); 4735 if(!highlightTagName) 4736 highlightTagName = "em"; 4737 highlightTagName = highlightTagName.toLowerCase(); 4738 if(currentText.indexOf("</" + highlightTagName + ">") != -1) 4739 ContainsFilteringUtils.UnselectContainsTextInElement(element, selection, highlightTagName); 4740 return ContainsFilteringUtils.SelectContainsTextInElement(element, selection, highlightTagName); 4741}; 4742ContainsFilteringUtils.SelectContainsTextInElement = function(element, selection, highlightTagName) { 4743 if(selection.startIndex == -1) 4744 return; 4745 var currentText = ASPx.Attr.GetAttribute (element, "DXText"); 4746 if(!ASPx.IsExists(currentText)) ASPx.Attr.SetAttribute (element, "DXText", ASPx.GetInnerText(element)); 4747 if(!highlightTagName) 4748 highlightTagName = "em"; 4749 highlightTagName = highlightTagName.toLowerCase(); 4750 var oldInnerText = ASPx.GetInnerText(element); 4751 var newInnerText = ContainsFilteringUtils.PrepareElementText(oldInnerText.substr(0, selection.startIndex)) + "<" + highlightTagName + ">" + 4752 ContainsFilteringUtils.PrepareElementText(oldInnerText.substr(selection.startIndex, selection.length)) + "</" + highlightTagName + ">" + 4753 ContainsFilteringUtils.PrepareElementText(oldInnerText.substr(selection.startIndex + selection.length)); 4754 ASPx.Security.setInnerHtml(element, newInnerText, ASPx.Security.DataType.Trusted); 4755}; 4756ASPx.ContainsFilteringUtils = ContainsFilteringUtils; 4757ASPx.MakeEqualControlsWidth = function(name1, name2){ 4758 var control1 = ASPx.GetControlCollection().Get(name1); 4759 var control2 = ASPx.GetControlCollection().Get(name2); 4760 if(control1 && control2){ 4761 var width = Math.max(control1.GetWidth(), control2.GetWidth()); 4762 control1.SetWidth(width); 4763 control2.SetWidth(width); 4764 } 4765}; 4766ASPx.HighContrastForeColorHighlightColorMap = { 4767 "#ffff00" : "#008000", 4768 "#00ff00" : "#0000ff", 4769 "#ffffff" : "#00838f", 4770 "#000000" : "#a347ff" 4771}; 4772var BadgeManagerBase = ASPx.CreateClass(null, { 4773 createBadge: function(text, iconCssClass) { 4774 var badge = document.createElement("SPAN"); 4775 ASPx.SetClassName(badge, this.getBadgeClassName()); 4776 if(iconCssClass && iconCssClass.length) 4777 this.setBadgeIconCssClass(badge, iconCssClass); 4778 if(text && text.length) 4779 this.setBadgeText(badge, text); 4780 return badge; 4781 }, 4782 findBadge: function(element) { 4783 if(!element) 4784 return null; 4785 return element.querySelector("." + this.getBadgeClassName()); 4786 }, 4787 setBadgeIconCssClass: function(badge, iconCssClass) { 4788 if(!badge || iconCssClass === undefined) 4789 return; 4790 var iconElement = this.getBadgeIconElement(badge); 4791 if(!iconCssClass) { 4792 if(iconElement) 4793 badge.removeChild(iconElement); 4794 } 4795 else { 4796 if(!iconElement) { 4797 iconElement = document.createElement("SPAN"); 4798 badge.insertBefore(iconElement, badge.childNodes[0]); 4799 } 4800 ASPx.SetClassName(iconElement, iconCssClass + " " + this.getBadgeIconDefaultClassName()); 4801 } 4802 }, 4803 getBadgeIconCssClass: function(element) { 4804 var badge = this.findBadge(element); 4805 if(badge) { 4806 var iconElement = this.getBadgeIconElement(badge); 4807 var regEx = new RegExp("(?:^|\\s)" + this.getBadgeIconDefaultClassName() + "(?!\\S)"); 4808 return iconElement ? ASPx.Str.Trim(ASPx.GetClassName(iconElement).replace(regEx, "")) : ""; 4809 } 4810 return ""; 4811 }, 4812 setBadgeText: function(badge, text) { 4813 if(!badge || text === undefined) 4814 return; 4815 var textElement = this.getBadgeTextElement(badge); 4816 if(!text) { 4817 if(textElement) 4818 badge.removeChild(textElement); 4819 } 4820 else { 4821 if(!textElement) { 4822 textElement = document.createElement("SPAN"); 4823 badge.appendChild(textElement); 4824 } 4825 ASPx.Security.setInnerHtml(textElement, text, ASPx.Security.DataType.Trusted); 4826 } 4827 }, 4828 getBadgeText: function(element) { 4829 var badge = this.findBadge(element); 4830 if(badge) { 4831 var textElement = this.getBadgeTextElement(badge); 4832 return textElement ? ASPx.GetInnerText(textElement) : ""; 4833 } 4834 return ""; 4835 }, 4836 getBadgeClassName: function() { 4837 return ""; 4838 }, 4839 getBadgeIconDefaultClassName: function() { 4840 return ""; 4841 }, 4842 getBadgeIconElement: function(badge) { 4843 return badge.childNodes.length ? badge.querySelector("." + this.getBadgeIconDefaultClassName()) : null; 4844 }, 4845 getBadgeTextElement: function(badge) { 4846 return badge.childNodes.length ? badge.querySelector("span:not(." + this.getBadgeIconDefaultClassName() + ")") : null; 4847 } 4848}); 4849ASPx.BadgeManagerBase = BadgeManagerBase; 4850var BadgeManager = ASPx.CreateClass(BadgeManagerBase, { 4851 getBadgeClassName: function() { 4852 return "dxBadge"; 4853 }, 4854 getBadgeIconDefaultClassName: function() { 4855 return "dxBadgeImage"; 4856 }, 4857 createBadgeForButton: function(button) { 4858 var badge = ASPx.BadgeManager.createBadge(); 4859 var buttonImage = button.GetButtonImage(); 4860 var textContainer = button.GetTextContainer(); 4861 var badgeRightSibling = !!buttonImage ? buttonImage : textContainer; 4862 badgeRightSibling.parentNode.insertBefore(badge, badgeRightSibling); 4863 if(button.IsLink() && buttonImage) 4864 ASPx.SetStyles(badge, { verticalAlign: "middle" }); 4865 return badge; 4866 }, 4867 createBadgeForToolbar: function(toolbarItem) { 4868 var badge = ASPx.BadgeManager.createBadge(); 4869 var itemImage = toolbarItem.GetImage(); 4870 var badgeRightSibling = itemImage; 4871 if(!itemImage) { 4872 var itemContentElement = toolbarItem.menu.GetItemContentElement(toolbarItem.indexPath); 4873 badgeRightSibling = toolbarItem.menu.GetContentTextElement(itemContentElement); 4874 } 4875 badgeRightSibling.parentNode.insertBefore(badge, badgeRightSibling); 4876 return badge; 4877 } 4878}); 4879ASPx.BadgeManager = new BadgeManager(); 4880var AccessibilityUtils = { 4881 isInitialized: false, 4882 highContrastCssClassMarker: "dxHighContrast",
4883 highContrastBackgroundCssClassMarker: "dxHCB", 4884 highContrastDefaultBackgroundColor: "#a347ff", 4885 highContrastThemeActive: false, 4886 accessibleBackgroundCssMarker: ".dx-runtime-background", 4887 createAccessibleBackgrounds: function(control) { 4888 if(!this.highContrastThemeActive || control.accessibleBackgroundsCreated || !control.accessibilityCompliant) 4889 return; 4890 var className = this.accessibleBackgroundCssMarker; 4891 var styleSheetRuleNames = []; 4892 iterateStyleSheetRules(null, function(rule) { 4893 var selectorTxt = rule.selectorText; 4894 if(selectorTxt && selectorTxt.indexOf(className) > -1) 4895 styleSheetRuleNames.push(ASPx.Str.CompleteReplace(selectorTxt, className, "")); 4896 }); 4897 for(var i = 0; i < styleSheetRuleNames.length; i++) { 4898 var name = styleSheetRuleNames[i]; 4899 var rule = ASPx.GetStyleSheetRules(name.substring(1)); 4900 if(rule && rule.style && rule.style.backgroundImage) 4901 this.createAccessibleBackground(control.GetMainElement(), rule.style, name); 4902 } 4903 control.accessibleBackgroundsCreated = true; 4904 }, 4905 createAccessibleBackground: function(container, style, selector) { 4906 if(!container) 4907 return; 4908 var backgroundUrl = style.backgroundImage.substring(5, style.backgroundImage.length - 2); 4909 var elements = container.querySelectorAll(selector); 4910 var accessibleBackgroundClassName = "dx-acc-bi"; 4911 for(var i = 0; i < elements.length; i++) { 4912 var element = elements[i]; 4913 if(ASPx.ElementHasCssClass(element, accessibleBackgroundClassName)) 4914 continue; 4915 var image = null; 4916 if(element.tagName !== "IMG") { 4917 ASPx.AddClassNameToElement(element, accessibleBackgroundClassName); 4918 image = element.ownerDocument.createElement("IMG"); 4919 ASPx.SetStyles(image, { width: "100%", height: "100%" }); 4920 if(element.firstChild) 4921 element.insertBefore(image, element.firstChild); 4922 else 4923 element.appendChild(image); 4924 } else 4925 image = element; 4926 image.src = backgroundUrl; 4927 } 4928 },
4929 createHighContrastBackgroundStyle: function() { 4930 var style = document.createElement('style'); 4931 ASPx.Attr.AppendStyleType(style); 4932 var styleContent = [ 4933 "." + this.highContrastCssClassMarker + " ." + this.highContrastBackgroundCssClassMarker + ":after {", 4934 "border-image: url(" + this.getHighContrastBackgroundUrl() + ") 0 1 0 0 round;", 4935 "}", 4936 ]; 4937 setInnerHtmlInternal(style, styleContent.join('\n')); 4938 document.getElementsByTagName('head')[0].appendChild(style); 4939 }, 4940 getHighContrastBackgroundUrl: function() { 4941 var canvas = document.createElement("canvas"), 4942 ctx = canvas.getContext('2d'); 4943 canvas.width = 1; 4944 canvas.height = 1; 4945 ctx.fillStyle = this.getHighContrastBackgroundColor(); 4946 ctx.fillRect(0, 0, canvas.width, canvas.height); 4947 return canvas.toDataURL(); 4948 }, 4949 getHighContrastBackgroundColor: function() { 4950 var foreColor = ASPx.GetCurrentStyle(document.body).color; 4951 var hexColor = ASPx.Color.ColorToHexadecimal(foreColor); 4952 return ASPx.HighContrastForeColorHighlightColorMap[hexColor] || this.highContrastDefaultBackgroundColor; 4953 }, 4954 initialize: function() { 4955 if(this.isInitialized) 4956 return; 4957 this.isInitialized = true; 4958 this.detectHighContrastTheme(); 4959 if(this.highContrastThemeActive)
4960 this.createHighContrastBackgroundStyle(); 4961 }, 4962 detectHighContrastTheme: function() { 4963 var testElement = document.createElement("DIV"); 4964 ASPx.SetStyles(testElement, { 4965 backgroundImage: "url('" + ASPx.EmptyImageUrl + "')", 4966 display: "none" 4967 }, true); 4968 var docElement = document.documentElement; 4969 docElement.appendChild(testElement); 4970 var actualBackgroundImg = ASPx.GetCurrentStyle(testElement).backgroundImage; 4971 docElement.removeChild(testElement); 4972 if(actualBackgroundImg === "none") { 4973 this.highContrastThemeActive = true; 4974 ASPx.AddClassNameToElement(docElement, this.highContrastCssClassMarker); 4975 } 4976 } 4977}; 4978ASPx.AccessibilityUtils = AccessibilityUtils; 4979ASPx.AccessibilityUtils.SendMessageToAssistiveTechnology = function(message) { 4980 var messageParts = ASPx.Ident.IsArray(message) ? message : [message]; 4981 var args = new ASPxClientControlBeforePronounceEventArgs(messageParts, null); 4982 ASPx.AccessibilityPronouncer.EnsureInitialize(); 4983 ASPx.AccessibilityPronouncer.Pronounce(args, ASPx.AccessibilityPronouncerType.live); 4984}; 4985ASPx.AccessibilityUtils.SetFocusAccessible = function(focusableElement) { 4986 if(!focusableElement) 4987 return; 4988 var elementId = focusableElement.id; 4989 if(!elementId) { 4990 var namedParent = ASPx.GetParent(focusableElement, function(element) { 4991 return !!element.id; 4992 }); 4993 if(ASPx.IsExists(namedParent)) 4994 elementId = namedParent.id; 4995 } 4996 var focusableControl = ASPx.GetClientControlByElementID(elementId); 4997 if(focusableControl && focusableControl.OnAssociatedLabelClick) 4998 focusableControl.OnAssociatedLabelClick(focusableElement); 4999 else 5000 window.setTimeout(function() { 5001 ASPx.AccessibilityUtils.SetFocusAccessibleCore(focusableElement); 5002 }, 0); 5003}; 5004ASPx.AccessibilityUtils.SetFocusAccessibleCore = function(focusableElement) { 5005 if(!ASPx.IsExists(focusableElement)) 5006 return; 5007 var isTabIndexChanged = ASPx.ControlTabIndexManager.getInstance().isElementWithChangedIndex(focusableElement); 5008 if(isTabIndexChanged) 5009 return; 5010 if(!ASPx.IsValidElement(focusableElement) && focusableElement.id) 5011 focusableElement = ASPx.GetElementById(focusableElement.id); 5012 if(!ASPx.IsActionElement(focusableElement)) 5013 focusableElement = ASPx.RestoreFocusHelper.findNeighbourFocusElement(focusableElement, document.body); 5014 if(ASPx.IsExistsElement(focusableElement)) 5015 focusableElement.focus(); 5016}; 5017var Security = { 5018 setInnerHtml: function(el, html, dataType) { 5019 if(!html) { 5020 while(el.firstChild) 5021 ASPx.RemoveElement(el.firstChild); 5022 } else 5023 Security.setData(html, function(d) { ASPx.SetInnerHtml.call(window, el, d); }, dataType); 5024 }, 5025 setText: function(control, text, dataType) { Security.setData(text, control.SetText.aspxBind(control), dataType); }, 5026 safeEncodeHtml: function(html) { return ASPx.Str.EncodeHtml(ASPx.Str.DecodeHtml(html)); }, 5027 setData: function(data, dataSetter, dataType) { 5028 if(dataType === undefined) 5029 throw new Error("Specify the dataType"); 5030 if(dataType == Security.DataType.Untrusted) 5031 data = Security.safeEncodeHtml(data); 5032 dataSetter(data); 5033 } 5034}; 5035Security.DataType = { 5036 Trusted: 0, 5037 Untrusted: 1 5038}; 5039ASPx.EnableCssAnimation = true; 5040var AnimationTransitionBase = ASPx.CreateClass(null, { 5041 constructor: function(element, options) { 5042 if(element) { 5043 AnimationTransitionBase.Cancel(element); 5044 this.element = element; 5045 this.element.aspxTransition = this; 5046 } 5047 this.duration = options.duration || AnimationConstants.Durations.DEFAULT; 5048 this.transition = options.transition || AnimationConstants.Transitions.SINE; 5049 this.property = options.property; 5050 this.unit = options.unit || ""; 5051 this.onComplete = options.onComplete; 5052 this.to = null; 5053 this.from = null; 5054 }, 5055 Start: function(from, to) { 5056 if(to != undefined) { 5057 this.to = to; 5058 this.from = from; 5059 this.SetValue(this.from); 5060 } 5061 else 5062 this.to = from; 5063 }, 5064 Cancel: function() { 5065 if(!this.element) 5066 return; 5067 try { 5068 delete this.element.aspxTransition; 5069 } catch(e) { 5070 this.element.aspxTransition = undefined; 5071 } 5072 }, 5073 GetValue: function() { 5074 return this.getValueInternal(this.element, this.property); 5075 }, 5076 SetValue: function(value) { 5077 this.setValueInternal(this.element, this.property, this.unit, value); 5078 }, 5079 setValueInternal: function(element, property, unit, value) { 5080 if(property == "opacity") 5081 AnimationUtils.setOpacity(element, value); 5082 else 5083 element.style[property] = value + unit; 5084 }, 5085 getValueInternal: function(element, property) { 5086 if(property == "opacity") 5087 return ASPx.GetElementOpacity(element); 5088 var value = parseFloat(element.style[property]); 5089 return isNaN(value) ? 0 : value; 5090 }, 5091 performOnComplete: function() { 5092 if(this.onComplete) 5093 this.onComplete(this.element); 5094 }, 5095 getTransition: function() { 5096 return this.transition; 5097 } 5098}); 5099AnimationTransitionBase.Cancel = function(element) { 5100 if(element.aspxTransition) 5101 element.aspxTransition.Cancel(); 5102}; 5103var AnimationConstants = {}; 5104AnimationConstants.Durations = { 5105 SHORT: 200, 5106 DEFAULT: 400, 5107 LONG: 600 5108}; 5109AnimationConstants.Transitions = { 5110 LINER: { 5111 Css: "cubic-bezier(0.250, 0.250, 0.750, 0.750)", 5112 Js: function(progress) { return progress; } 5113 }, 5114 SINE: { 5115 Css: "cubic-bezier(0.470, 0.000, 0.745, 0.715)", 5116 Js: function(progress) { return Math.sin(progress * 1.57); } 5117 }, 5118 POW: { 5119 Css: "cubic-bezier(0.755, 0.050, 0.855, 0.060)", 5120 Js: function(progress) { return Math.pow(progress, 4); } 5121 }, 5122 POW_EASE_OUT: { 5123 Css: "cubic-bezier(0.165, 0.840, 0.440, 1.000)", 5124 Js: function(progress) { return 1 - AnimationConstants.Transitions.POW.Js(1 - progress); } 5125 }, 5126 RIPPLE: { 5127 Css: "cubic-bezier(0.47, 0.06, 0.23, 0.99)", 5128 Js: function(progress) { 5129 return Math.pow((progress), 3) * 0.47 + 3 * progress * Math.pow((1 - progress), 2) * 0.06 + 3 * Math.pow(progress, 2) * 5130 (1 - progress) * 0.23 + 0.99 * Math.pow(progress, 3); 5131 } 5132 } 5133}; 5134var JsAnimationTransition = ASPx.CreateClass(AnimationTransitionBase, { 5135 constructor: function(element, options) { 5136 this.constructor.prototype.constructor.call(this, element, options); 5137 this.onStep = options.onStep; 5138 this.fps = 60; 5139 this.startTime = null; 5140 }, 5141 Start: function(from, to) { 5142 if(from == to) { 5143 this.from = this.to = from; 5144 setTimeout(this.complete.aspxBind(this), 0); 5145 } 5146 else { 5147 AnimationTransitionBase.prototype.Start.call(this, from, to); 5148 if(to == undefined) 5149 this.from = this.GetValue(); 5150 this.initTimer(); 5151 } 5152 }, 5153 Cancel: function() { 5154 AnimationTransitionBase.prototype.Cancel.call(this); 5155 if(this.timerId) 5156 clearInterval(this.timerId); 5157 }, 5158 initTimer: function() { 5159 this.startTime = new Date(); 5160 this.timerId = window.setInterval(function() { this.onTick(); }.aspxBind(this), 1000 / this.fps);
5161 }, 5162 onTick: function() { 5163 var progress = (new Date() - this.startTime) / this.duration; 5164 if(progress >= 1) 5165 this.complete(); 5166 else { 5167 this.update(progress); 5168 if(this.onStep) 5169 this.onStep(); 5170 } 5171 }, 5172 update: function(progress) { 5173 this.SetValue(this.gatCalculatedValue(this.from, this.to, progress)); 5174 }, 5175 complete: function() { 5176 this.Cancel(); 5177 this.update(1); 5178 this.performOnComplete(); 5179 }, 5180 gatCalculatedValue: function(from, to, progress) { 5181 if(progress == 1) 5182 return to; 5183 return from + (to - from) * this.getTransition()(progress); 5184 }, 5185 getTransition: function() { 5186 return this.transition.Js; 5187 } 5188}); 5189var SimpleAnimationTransition = ASPx.CreateClass(JsAnimationTransition, { 5190 constructor: function(options) { 5191 this.constructor.prototype.constructor.call(this, null, options); 5192 this.transition = options.transition || AnimationConstants.Transitions.POW_EASE_OUT; 5193 this.onUpdate = options.onUpdate; 5194 this.lastValue = 0; 5195 }, 5196 SetValue: function(value) { 5197 this.onUpdate(value - this.lastValue); 5198 this.lastValue = value; 5199 }, 5200 GetValue: function() { 5201 return this.lastValue; 5202 }, 5203 performOnComplete: function() { 5204 if(this.onComplete) 5205 this.onComplete(); 5206 } 5207}); 5208var MultipleJsAnimationTransition = ASPx.CreateClass(JsAnimationTransition, { 5209 constructor: function(element, options) { 5210 this.constructor.prototype.constructor.call(this, element, options); 5211 this.properties = {}; 5212 }, 5213 Start: function(properties) { 5214 this.initProperties(properties); 5215 this.initTimer(); 5216 }, 5217 initProperties: function(properties) { 5218 this.properties = properties; 5219 for(var propName in this.properties) 5220 if(properties[propName].from == undefined) 5221 properties[propName].from = this.getValueInternal(this.element, propName); 5222 }, 5223 update: function(progress) { 5224 for(var propName in this.properties) { 5225 if(this.properties.hasOwnProperty(propName)) { 5226 var property = this.properties[propName]; 5227 if(property.from != property.to) 5228 this.setValueInternal(this.element, propName, property.unit, this.gatCalculatedValue(property.from, property.to, progress)); 5229 } 5230 } 5231 } 5232}); 5233var CssAnimationTransition = ASPx.CreateClass(AnimationTransitionBase, { 5234 constructor: function(element, options) { 5235 this.constructor.prototype.constructor.call(this, element, options); 5236 this.transitionPropertyName = AnimationUtils.CurrentTransition.property; 5237 this.eventName = AnimationUtils.CurrentTransition.event; 5238 }, 5239 Start: function(from, to) { 5240 AnimationTransitionBase.prototype.Start.call(this, from, to); 5241 this.startTimerId = window.setTimeout(function() { 5242 if(this.from == this.to) 5243 this.onTransitionEnd(); 5244 else { 5245 var isHidden = ASPx.GetElementOffsetHeight(this.element) == 0 && ASPx.GetElementOffsetWidth(this.element) == 0; 5246 if(!isHidden) 5247 this.prepareElementBeforeAnimation(); 5248 this.SetValue(this.to); 5249 if(isHidden) 5250 this.onTransitionEnd(); 5251 } 5252 }.aspxBind(this), 0); 5253 }, 5254 Cancel: function() { 5255 window.clearTimeout(this.startTimerId); 5256 AnimationTransitionBase.prototype.Cancel.call(this); 5257 ASPx.Evt.DetachEventFromElement(this.element, this.eventName, CssAnimationTransition.transitionEnd); 5258 this.setValueInternal(this.element, this.transitionPropertyName, "", ""); 5259 this.stopAnimation(); 5260 }, 5261 prepareElementBeforeAnimation: function() { 5262 ASPx.Evt.AttachEventToElement(this.element, this.eventName, CssAnimationTransition.transitionEnd); 5263 var dummy = this.element.offsetHeight; 5264 this.element.style[this.transitionPropertyName] = this.getTransitionCssString(); 5265 if(ASPx.Browser.Safari && ASPx.Browser.MacOSMobilePlatform && ASPx.Browser.MajorVersion >= 8) 5266 setTimeout(function() { 5267 if(this.element && this.element.aspxTransition) { 5268 this.element.style[this.transitionPropertyName] = ""; 5269 this.element.aspxTransition.onTransitionEnd(); 5270 } 5271 }.aspxBind(this), this.duration + 100); 5272 }, 5273 stopAnimation: function() { 5274 this.SetValue(ASPx.GetCurrentStyle(this.element)[this.property]); 5275 }, 5276 onTransitionEnd: function() { 5277 this.Cancel(); 5278 this.performOnComplete(); 5279 }, 5280 getTransition: function() { 5281 return this.transition.Css; 5282 }, 5283 getTransitionCssString: function() { 5284 return this.getTransitionCssStringInternal(this.getCssName(this.property)); 5285 }, 5286 getTransitionCssStringInternal: function(cssProperty) { 5287 return cssProperty + " " + this.duration + "ms " + this.getTransition(); 5288 }, 5289 getCssName: function(property) { 5290 switch(property) { 5291 case "marginLeft": 5292 return "margin-left"; 5293 case "marginTop": 5294 return "margin-top"; 5295 } 5296 return property; 5297 } 5298}); 5299var MultipleCssAnimationTransition = ASPx.CreateClass(CssAnimationTransition, { 5300 constructor: function(element, options) { 5301 this.constructor.prototype.constructor.call(this, element, options); 5302 this.properties = null; 5303 }, 5304 Start: function(properties) { 5305 this.properties = properties; 5306 this.forEachProperties(function(property, propName) { 5307 if(property.from !== undefined) 5308 this.setValueInternal(this.element, propName, property.unit, property.from); 5309 }.aspxBind(this)); 5310 this.prepareElementBeforeAnimation(); 5311 window.setTimeout(function() { 5312 this.forEachProperties(function(property, propName) { 5313 this.setValueInternal(this.element, propName, property.unit, property.to);
5314 }.aspxBind(this)); 5315 }.aspxBind(this), 0); 5316 }, 5317 stopAnimation: function() { 5318 var style = ASPx.GetCurrentStyle(this.element); 5319 this.forEachProperties(function(property, propName) { 5320 this.setValueInternal(this.element, propName, "", style[propName]); 5321 }.aspxBind(this)); 5322 }, 5323 getTransitionCssString: function() { 5324 var str = ""; 5325 this.forEachProperties(function(property, propName) { 5326 str += this.getTransitionCssStringInternal(this.getCssName(propName)) + ","; 5327 }.aspxBind(this)); 5328 str = str.substring(0, str.length - 1); 5329 return str; 5330 }, 5331 forEachProperties: function(func) { 5332 for(var propName in this.properties) { 5333 if(this.properties.hasOwnProperty(propName)) { 5334 var property = this.properties[propName]; 5335 if(property.from == undefined) 5336 property.from = this.getValueInternal(this.element, propName); 5337 if(property.from != property.to) 5338 func(property, propName); 5339 } 5340 } 5341 } 5342}); 5343CssAnimationTransition.transitionEnd = function(evt) { 5344 var element = evt.target; 5345 if(element && element.aspxTransition) 5346 element.aspxTransition.onTransitionEnd(); 5347}; 5348var AnimationUtils = { 5349 CanUseCssTransition: function() { return ASPx.EnableCssAnimation && this.CurrentTransition; }, 5350 CanUseCssTransform: function() { return this.CanUseCssTransition() && this.CurrentTransform; }, 5351 CurrentTransition: (function() { 5352 if(ASPx.Browser.IE) 5353 return null; 5354 var transitions = [ 5355 { property: "webkitTransition", event: "webkitTransitionEnd" }, 5356 { property: "MozTransition", event: "transitionend" }, 5357 { property: "OTransition", event: "oTransitionEnd" }, 5358 { property: "transition", event: "transitionend" } 5359 ]; 5360 var fakeElement = document.createElement("DIV"); 5361 for(var i = 0; i < transitions.length; i++) 5362 if(transitions[i].property in fakeElement.style) 5363 return transitions[i]; 5364 })(), 5365 CurrentTransform: (function() { 5366 var transforms = ["transform", "MozTransform", "-webkit-transform", "msTransform", "OTransform"]; 5367 var fakeElement = document.createElement("DIV"); 5368 for(var i = 0; i < transforms.length; i++) 5369 if(transforms[i] in fakeElement.style) 5370 return transforms[i]; 5371 })(), 5372 SetTransformValue: function(element, position, isTop) { 5373 if(this.CanUseCssTransform()) 5374 element.style[this.CurrentTransform] = this.GetTransformCssText(position, isTop); 5375 else 5376 element.style[!isTop ? "left" : "top"] = position + "px"; 5377 }, 5378 GetTransformValue: function(element, isTop) { 5379 if(this.CanUseCssTransform()) { 5380 var cssValue = element.style[this.CurrentTransform]; 5381 return cssValue && cssValue != "none" ? Number(cssValue.replace('matrix(1, 0, 0, 1,', '').replace(')', '').split(',')[!isTop ? 0 : 1]) : 0; 5382 } 5383 else 5384 return !isTop ? element.offsetLeft : element.offsetTop; 5385 }, 5386 GetTransformCssText: function(position, isTop) { 5387 if(!position) 5388 return "none"; 5389 return "matrix(1, 0, 0, 1," + (!isTop ? position : 0) + ", " + (!isTop ? 0 : position) + ")"; 5390 }, 5391 createMultipleAnimationTransition: function (element, options) { 5392 return this.CanUseCssTransition() && !options.onStep ? new MultipleCssAnimationTransition(element, options) : new MultipleJsAnimationTransition(element, options); 5393 }, 5394 createSimpleAnimationTransition: function(options) { 5395 return new SimpleAnimationTransition(options); 5396 }, 5397 createJsAnimationTransition: function(element, options) { 5398 return new JsAnimationTransition(element, options); 5399 }, 5400 createCssAnimationTransition: function(element, options) { 5401 return new CssAnimationTransition(element, options); 5402 }, 5403 setOpacity: function(element, value) { 5404 ASPx.SetElementOpacity(element, value); 5405 } 5406}; 5407var AsyncTracker = function() { 5408 var currentToken, 5409 lockedTokens, 5410 onDoneDelegates, 5411 lockedDelegates; 5412 function clearState() { 5413 currentToken = 1; 5414 lockedTokens = []; 5415 onDoneDelegates = []; 5416 lockedDelegates = {}; 5417 } 5418 clearState(); 5419 var log = function(msg) { }; 5420 function setLog(delegate){ 5421 log = delegate; 5422 } 5423 function getLockToken() { 5424 if(onDoneDelegates.length === 0) 5425 return -1; 5426 var token = currentToken++; 5427 lockedTokens.push(token); 5428 lockedDelegates[token] = []; 5429 for (var i = 0; i < onDoneDelegates.length; i++) { 5430 lockedDelegates[token].push(onDoneDelegates[i]); 5431 } 5432 log("module locks token " + token); 5433 return token; 5434 } 5435 function releaseToken(token) { 5436 if(token < 0) return; 5437 log("module releasing token " + token); 5438 ASPx.Data.ArrayRemove(lockedTokens, token); 5439 delete lockedDelegates[token]; 5440 invokeUnlockedDelegates(); 5441 if(lockedTokens.length === 0) 5442 clearState(); 5443 log("module released token " + token); 5444 } 5445 function invokeUnlockedDelegates() { 5446 var onDoneDelegate; 5447 for (var i = onDoneDelegates.length - 1; i >= 0; i--) { 5448 if(onDoneDelegates[i] && !isDelegateLocked(onDoneDelegates[i])) { 5449 onDoneDelegate = onDoneDelegates[i]; 5450 delete onDoneDelegates[i]; 5451 onDoneDelegate(); 5452 } 5453 } 5454 } 5455 function isDelegateLocked(delegate) { 5456 for (var i = lockedTokens.length - 1; i >= 0; i--) { 5457 var token = lockedTokens[i]; 5458 var delegates = lockedDelegates[token]; 5459 if(delegates) { 5460 for (var j = delegates.length - 1; j >= 0; j--) { 5461 if(delegates[j] && delegates[j] === delegate) 5462 return true; 5463 } 5464 } 5465 } 5466 return false; 5467 } 5468 function track(doDelegate, onDoneDelegate) { 5469 if(onDoneDelegate) 5470 onDoneDelegates.push(onDoneDelegate); 5471 doDelegate(); 5472 if(onDoneDelegate) 5473 invokeUnlockedDelegates(); 5474 } 5475 return { 5476 getLockToken: getLockToken, 5477 releaseToken: releaseToken, 5478 track: track, 5479 setLog:setLog, 5480 }; 5481}; 5482var GetEditorValuesInContainer = function(containerOrId, processInvisibleEditors, needSerialize) { 5483 var container = typeof(containerOrId) === "string" ? ASPx.GetElementById(containerOrId) : containerOrId;
5484 var result = {}; 5485 if(!ASPx.ProcessEditorsInContainer) 5486 return result; 5487 ASPx.ProcessEditorsInContainer(container, function(editor){ 5488 result[editor.name] = GetCorrectedByTypeValue(ASPx.GetEditorValueByControl(editor), needSerialize); 5489 }, null, null, processInvisibleEditors, false); 5490 return result; 5491}; 5492var SetEditorValues = function(values) { 5493 for(var controlName in values) { 5494 if(values.hasOwnProperty(controlName)) { 5495 var trackedControl = ASPxClientControl.GetControlCollection().Get(controlName); 5496 if(!trackedControl) 5497 continue; 5498 var setValueMethod = trackedControl.SetTokenCollection || trackedControl.SelectValues || trackedControl.SetValue; 5499 if(setValueMethod === trackedControl.SelectValues) 5500 trackedControl.UnselectAll(); 5501 setValueMethod.call(trackedControl, values[controlName]); 5502 } 5503 } 5504}; 5505var GetCorrectedByTypeValue = function(value, needSerialize){ 5506 if(ASPx.Ident.IsArray(value)) 5507 for(var i = 0; i < value.length; i++) 5508 value[i] = GetCorrectedByTypeValue(value[i]); 5509 if(needSerialize && ASPx.Ident.IsDate(value)) 5510 return ASPx.DateUtils.GetInvariantDateTimeString(value); 5511 return value; 5512}; 5513var ListBoxTemporaryCache = ASPx.CreateClass(null, { 5514 constructor: function() { 5515 this.cache = { }; 5516 this.invalidateTimerID = -1; 5517 }, 5518 Get: function(key, getObjectFunc, context, args) { 5519 if(this.invalidateTimerID < 0) { 5520 this.invalidateTimerID = window.setTimeout(function() { 5521 this.Invalidate(); 5522 }.aspxBind(this), 0); 5523 } 5524 if(!ASPx.IsExists(this.cache[key])) { 5525 if(!ASPx.IsExists(args)) 5526 args = [ ]; 5527 this.cache[key] = getObjectFunc.apply(context, args); 5528 } 5529 return this.cache[key]; 5530 }, 5531 Invalidate: function() { 5532 this.cache = { }; 5533 this.invalidateTimerID = ASPx.Timer.ClearTimer(this.invalidateTimerID); 5534 } 5535}); 5536ASPx.GetEditorValueByControl = function(control, needSerialize) { 5537 var result; 5538 if(ASPx.IsMultipleValueOwner(control)) 5539 result = control.GetSelectedValues(); 5540 if(ASPx.IsTokenBox(control)) { 5541 if(needSerialize) 5542 result = control.GetTokenValuesCollection(); 5543 else 5544 result = control.GetTokenCollection(); 5545 } 5546 return result || control.GetValue(); 5547}; 5548ASPx.IsMultipleValueOwner = function(control) { 5549 return ASPx.IsListBox(control) || ASPx.IsCheckBoxList(control); 5550}; 5551ASPx.IsCheckBoxList = function(control) { 5552 return control && typeof(ASPxClientCheckBoxList) != "undefined" && control instanceof ASPxClientCheckBoxList; 5553}; 5554ASPx.IsListBox = function(control) { 5555 return control && typeof(ASPxClientListBox) != "undefined" && control instanceof ASPxClientListBox; 5556}; 5557ASPx.IsComboBox = function(control) { 5558 return control && typeof(ASPxClientComboBox) != "undefined" && control instanceof ASPxClientComboBox; 5559}; 5560ASPx.IsTokenBox = function(control) { 5561 return control && typeof(ASPxClientTokenBox) != "undefined" && control instanceof ASPxClientTokenBox; 5562}; 5563ASPx.IsGridLookup = function(control) { 5564 return control && typeof(MVCxClientGridLookup) != "undefined" && control instanceof MVCxClientGridLookup; 5565}; 5566ASPx.IsSpinEdit = function(control) { 5567 return control && typeof(ASPxClientSpinEdit) != "undefined" && control instanceof ASPxClientSpinEdit; 5568}; 5569ASPx.DatePickerType = { 5570 Days: 0, 5571 Months: 1, 5572 Years: 2, 5573 Decades: 3 5574}; 5575ASPx.FullScreenUtils = { 5576 subscribeChange: function(handler) { 5577 Evt.AttachEventToElement(document, "fullscreenchange", handler); 5578 Evt.AttachEventToElement(document, "msfullscreenchange", handler); 5579 Evt.AttachEventToElement(document, "MSFullscreenChange", handler); 5580 Evt.AttachEventToElement(document, "webkitfullscreenchange", handler); 5581 Evt.AttachEventToElement(document, "mozfullscreenchange", handler); 5582 }, 5583 unsubscribeChange: function(handler) { 5584 Evt.DetachEventFromElement(document, "fullscreenchange", handler); 5585 Evt.DetachEventFromElement(document, "msfullscreenchange", handler); 5586 Evt.DetachEventFromElement(document, "MSFullscreenChange", handler); 5587 Evt.DetachEventFromElement(document, "webkitfullscreenchange", handler); 5588 Evt.DetachEventFromElement(document, "mozfullscreenchange", handler); 5589 }, 5590 setFullscreen: function(on) { 5591 var element = window.self.document.body; 5592 if(on) { 5593 if(element.requestFullscreen) { 5594 element.requestFullscreen(); 5595 } else if(element.mozRequestFullScreen) { 5596 element.mozRequestFullScreen(); 5597 } else if(element.webkitRequestFullscreen) { 5598 element.webkitRequestFullscreen(); 5599 } else if(element.msRequestFullscreen) { 5600 element.msRequestFullscreen(); 5601 } 5602 } else { 5603 if(document.exitFullscreen) { 5604 document.exitFullscreen(); 5605 } else if(document.mozCancelFullScreen) { 5606 document.mozCancelFullScreen(); 5607 } else if(document.webkitCancelFullScreen) { 5608 document.webkitCancelFullScreen(); 5609 } else if(document.msExitFullscreen) { 5610 document.msExitFullscreen(); 5611 } 5612 } 5613 }, 5614 inFullscreen: function() { 5615 var fullscreenElement = document.fullscreenElement || document.msFullscreenElement || document.webkitFullscreenElement; 5616 var isInFullscreen = fullscreenElement === document.body || document.webkitIsFullScreen;
5617 return !!isInFullscreen; 5618 } 5619 }; 5620ASPx.InitializeSVGSprite = function () { 5621 if (ASPx.SVGSprites && ASPx.SVGSprites.length > 0) { 5622 var svgContainer = document.getElementById('svgContainer'); 5623 var hasSvgContainer = !!svgContainer; 5624 if (!hasSvgContainer) { 5625 svgContainer = document.createElement('div'); 5626 svgContainer.id = 'svgContainer'; 5627 svgContainer.style.display = "none"; 5628 document.body.appendChild(svgContainer); 5629 } 5630 for (var i = 0; i < ASPx.SVGSprites.length; i++) { 5631 svgContainer.innerHTML += ASPx.SVGSprites[i]; 5632 } 5633 ASPx.SVGSprites = null; 5634 } 5635}; 5636var GridDynamicStyleSheetHelper = ASPx.CreateClass(null, { 5637 constructor: function() { 5638 this.styleSheet = {}; 5639 this.rules = {}; 5640 this.updateLock = 0; 5641 }, 5642 Update: function(control, styleName, rules) { 5643 var key = control.name + "_" + styleName; 5644 this.BeginUpdate(key); 5645 this.ChangeRules(key, rules); 5646 this.EndUpdate(key); 5647 }, 5648 ChangeRules: function(key, rules) { 5649 if(key && rules) 5650 this.rules[key] = rules; 5651 }, 5652 BeginUpdate: function(key) { 5653 this.updateLock++; 5654 this.RemoveStyleSheetElement(key); 5655 }, 5656 EndUpdate: function(key) { 5657 this.updateLock--; 5658 if(this.updateLock !== 0) 5659 return; 5660 var styleArgs = []; 5661 var controlRules = this.rules[key]; 5662 for(var i = 0; i < controlRules.length; i++) { 5663 var rule = controlRules[i]; 5664 styleArgs.push(rule.selector + " { " + rule.cssText + " } "); 5665 } 5666 this.styleSheet[key] = this.CreateStyleSheet(key, styleArgs.join("")); 5667 }, 5668 CreateStyleSheet: function(key, cssText) { 5669 var container = document.createElement("DIV"); 5670 ASPx.Security.setInnerHtml(container, "<style type='text/css' id='" + key + "'>" + cssText + "</style>", ASPx.Security.DataType.Trusted); 5671 styleSheet = ASPx.GetNodeByTagName(container, "style", 0); 5672 if(styleSheet) 5673 ASPx.GetNodeByTagName(document, "HEAD", 0).appendChild(styleSheet); 5674 return styleSheet; 5675 }, 5676 ClearStyleSheet: function(control, styleName) { 5677 var key = control.name + "_" + styleName; 5678 this.RemoveStyleSheetElement(key); 5679 }, 5680 RemoveStyleSheetElement: function(key) { 5681 if(this.styleSheet[key]) { 5682 ASPx.RemoveElement(this.styleSheet[key]); 5683 delete this.styleSheet[key]; 5684 } 5685 } 5686}); 5687GridDynamicStyleSheetHelper.Instance = new GridDynamicStyleSheetHelper(); 5688ASPx.GridDynamicStyleSheetHelper = GridDynamicStyleSheetHelper; 5689ASPxClientUtils = {}; 5690ASPxClientUtils.agent = Browser.UserAgent; 5691ASPxClientUtils.opera = Browser.Opera; 5692ASPxClientUtils.opera9 = Browser.Opera && Browser.MajorVersion == 9; 5693ASPxClientUtils.safari = Browser.Safari; 5694ASPxClientUtils.safari3 = Browser.Safari && Browser.MajorVersion == 3; 5695ASPxClientUtils.safariMacOS = Browser.Safari && Browser.MacOSPlatform; 5696ASPxClientUtils.chrome = Browser.Chrome; 5697ASPxClientUtils.ie = Browser.IE; 5698ASPxClientUtils.ie7 = Browser.IE && Browser.MajorVersion == 7; 5699ASPxClientUtils.firefox = Browser.Firefox; 5700ASPxClientUtils.firefox3 = Browser.Firefox && Browser.MajorVersion == 3; 5701ASPxClientUtils.mozilla = Browser.Mozilla; 5702ASPxClientUtils.netscape = Browser.Netscape; 5703ASPxClientUtils.browserVersion = Browser.Version; 5704ASPxClientUtils.browserMajorVersion = Browser.MajorVersion; 5705ASPxClientUtils.macOSPlatform = Browser.MacOSPlatform; 5706ASPxClientUtils.windowsPlatform = Browser.WindowsPlatform; 5707ASPxClientUtils.webKitFamily = Browser.WebKitFamily; 5708ASPxClientUtils.netscapeFamily = Browser.NetscapeFamily; 5709ASPxClientUtils.touchUI = Browser.TouchUI; 5710ASPxClientUtils.webKitTouchUI = Browser.WebKitTouchUI; 5711ASPxClientUtils.msTouchUI = Browser.MSTouchUI; 5712ASPxClientUtils.iOSPlatform = Browser.MacOSMobilePlatform; 5713ASPxClientUtils.androidPlatform = Browser.AndroidMobilePlatform; 5714ASPxClientUtils.ArrayInsert = Data.ArrayInsert; 5715ASPxClientUtils.ArrayRemove = Data.ArrayRemove; 5716ASPxClientUtils.ArrayRemoveAt = Data.ArrayRemoveAt; 5717ASPxClientUtils.ArrayClear = Data.ArrayClear; 5718ASPxClientUtils.ArrayIndexOf = Data.ArrayIndexOf; 5719ASPxClientUtils.AttachEventToElement = Evt.AttachEventToElement; 5720ASPxClientUtils.DetachEventFromElement = Evt.DetachEventFromElement; 5721ASPxClientUtils.GetEventSource = Evt.GetEventSource; 5722ASPxClientUtils.GetEventX = Evt.GetEventX; 5723ASPxClientUtils.GetEventY = Evt.GetEventY; 5724ASPxClientUtils.GetKeyCode = Evt.GetKeyCode; 5725ASPxClientUtils.PreventEvent = Evt.PreventEvent; 5726ASPxClientUtils.PreventEventAndBubble = Evt.PreventEventAndBubble; 5727ASPxClientUtils.PreventDragStart = Evt.PreventDragStart; 5728ASPxClientUtils.ClearSelection = Selection.Clear; 5729ASPxClientUtils.IsExists = ASPx.IsExists; 5730ASPxClientUtils.IsFunction = ASPx.IsFunction; 5731ASPxClientUtils.GetAbsoluteX = ASPx.GetAbsoluteX; 5732ASPxClientUtils.GetAbsoluteY = ASPx.GetAbsoluteY; 5733ASPxClientUtils.SetAbsoluteX = ASPx.SetAbsoluteX; 5734ASPxClientUtils.SetAbsoluteY = ASPx.SetAbsoluteY; 5735ASPxClientUtils.GetDocumentScrollTop = ASPx.GetDocumentScrollTop; 5736ASPxClientUtils.GetDocumentScrollLeft = ASPx.GetDocumentScrollLeft; 5737ASPxClientUtils.GetDocumentClientWidth = ASPx.GetDocumentClientWidth; 5738ASPxClientUtils.GetDocumentClientHeight = ASPx.GetDocumentClientHeight; 5739ASPxClientUtils.AddClassNameToElement = ASPx.AddClassNameToElement; 5740ASPxClientUtils.RemoveClassNameFromElement = ASPx.RemoveClassNameFromElement; 5741ASPxClientUtils.ToggleClassName = ASPx.ToggleClassNameToElement; 5742ASPxClientUtils.GetIsParent = ASPx.GetIsParent; 5743ASPxClientUtils.GetParentById = ASPx.GetParentById; 5744ASPxClientUtils.GetParentByTagName = ASPx.GetParentByTagName; 5745ASPxClientUtils.GetParentByClassName = ASPx.GetParentByPartialClassName; 5746ASPxClientUtils.GetChildById = ASPx.GetChildById; 5747ASPxClientUtils.GetChildByTagName = ASPx.GetChildByTagName; 5748ASPxClientUtils.SetCookie = Cookie.SetCookie;
5749ASPxClientUtils.GetCookie = Cookie.GetCookie; 5750ASPxClientUtils.DeleteCookie = Cookie.DelCookie; 5751ASPxClientUtils.GetShortcutCode = ASPx.GetShortcutCode; 5752ASPxClientUtils.GetShortcutCodeByEvent = ASPx.GetShortcutCodeByEvent; 5753ASPxClientUtils.StringToShortcutCode = ASPx.ParseShortcutString; 5754ASPxClientUtils.Trim = Str.Trim; 5755ASPxClientUtils.TrimStart = Str.TrimStart; 5756ASPxClientUtils.TrimEnd = Str.TrimEnd; 5757ASPxClientUtils.GetEditorValuesInContainer = GetEditorValuesInContainer; 5758ASPxClientUtils.SetEditorValues = SetEditorValues; 5759ASPxClientUtils.SendMessageToAssistiveTechnology = ASPx.AccessibilityUtils.SendMessageToAssistiveTechnology; 5760window.ASPxClientUtils = ASPxClientUtils; 5761window.ListBoxTemporaryCache = ListBoxTemporaryCache; 5762ASPx.AnimationUtils = AnimationUtils; 5763ASPx.AnimationTransitionBase = AnimationTransitionBase; 5764ASPx.AnimationConstants = AnimationConstants; 5765ASPx.AsyncTracker = AsyncTracker; 5766ASPx.Security = Security; 5767})(ASPx, dx); 5768 5769(function () { 5770 function IntersectionObserversManager() { 5771 this.rootElementToObserverMap = new Map(); 5772 this.elementToHandlerMap = new Map(); 5773 this.clearInvalidElementsInterval = null; 5774 this.clearInvalidElementsPeriod = 5000; 5775 this.AddTargetElement = function (element, rootElement, visibilityChangedHandler) { 5776 this.addTargetElementCore(element, rootElement, visibilityChangedHandler); 5777 }; 5778 this.SubscribeElemensVisibilityChangeInBrowserWindow = function (element, visibilityChangedHandler) { 5779 this.addTargetElementCore(element, null, visibilityChangedHandler); 5780 }; 5781 this.initializeObserver = function (rootElement) { 5782 if(!this.rootElementToObserverMap.get(rootElement)) { 5783 var options = { 5784 root: rootElement, 5785 rootMargin: '-1px', 5786 threshold: 0.0 5787 }; 5788 var observer = new IntersectionObserver(this.visibilityChanged.bind(this), options); 5789 this.rootElementToObserverMap.set(rootElement, observer); 5790 } 5791 }; 5792 this.addTargetElementCore = function (element, rootElement, visibilityChangedHandler) { 5793 this.initializeObserver(rootElement); 5794 if(!this.isAlreadyObserved(element)) { 5795 var observer = this.rootElementToObserverMap.get(rootElement); 5796 if(observer) { 5797 observer.observe(element); 5798 this.setObservedMarker(element); 5799 this.setElementVisibilityChangedHandler(element, visibilityChangedHandler, observer); 5800 if(this.clearInvalidElementsInterval === null) { 5801 this.clearInvalidElementsInterval = setInterval(this.removeDeletedElements.bind(this), this.clearInvalidElementsPeriod); 5802 } 5803 } 5804 } 5805 }; 5806 this.visibilityChanged = function (entries, observer) { 5807 entries.forEach(function (entry) { 5808 if(ASPx.IsExistsElement(entry.target)){ 5809 var handler = this.elementToHandlerMap.get(observer).get(entry.target); 5810 if(handler) { 5811 handler(entry.isIntersecting); 5812 } 5813 } 5814 }.bind(this)); 5815 }; 5816 this.removeDeletedElements = function () { 5817 this.elementToHandlerMap.forEach(function(elements, observer) { 5818 elements.forEach(function(handler, element) { 5819 if(!ASPx.IsExistsElement(element)) { 5820 elements.delete(element); 5821 } 5822 }.bind(this)); 5823 if(elements.size === 0) { 5824 this.elementToHandlerMap.delete(observer); 5825 } 5826 }.bind(this)); 5827 if(this.elementToHandlerMap.size === 0) { 5828 clearInterval(this.clearInvalidElementsInterval); 5829 this.clearInvalidElementsInterval = null; 5830 } 5831 }; 5832 this.setElementVisibilityChangedHandler = function (element, visibilityChangedHandler, observer) { 5833 if(!this.elementToHandlerMap.get(observer)) { 5834 this.elementToHandlerMap.set(observer, new Map()); 5835 } 5836 this.elementToHandlerMap.get(observer).set(element, visibilityChangedHandler); 5837 }; 5838 this.isAlreadyObserved = function (element) { 5839 return !!element.dataset.observed; 5840 }; 5841 this.setObservedMarker = function (element) { 5842 element.dataset.observed = true; 5843 }; 5844 this.reset = function () { 5845 this.rootElementToObserverMap.forEach(function(observer, rootElement) { 5846 observer.disconnect(); 5847 }.bind(this)); 5848 this.rootElementToObserverMap = new Map(); 5849 this.elementToHandlerMap = new Map(); 5850 this.clearInvalidElementsInterval = null; 5851 this.clearInvalidElementsPeriod = 5000; 5852 }; 5853 } 5854 function IntersectionObserversManagerForOldBrowsers() { 5855 this.SubscribeElemensVisibilityChangeInBrowserWindow = function (element, visibilityChangedH
5855andler) { 5856 }; 5857 } 5858 ASPx.IntersectionObserversManager = ASPx.IntersectionObserversManager || ((typeof(IntersectionObserver) !== "undefined") ? new IntersectionObserversManager() : new IntersectionObserversManagerForOldBrowsers()); 5859} 5860)(ASPx); 5861(function module(ASPx, options) { 5862ASPx.modules.Classes = module; 5863ASPx.classesScriptParsed = false; 5864ASPx.documentLoaded = false; 5865ASPx.CallbackType = { 5866 Data: "d", 5867 Common: "c" 5868}; 5869ASPx.callbackState = { 5870 aborted: "aborted", 5871 inTurn: "inTurn", 5872 sent: "sent" 5873}; 5874var ASPxClientEvent = ASPx.CreateClass(null, { 5875 constructor: function() { 5876 this.handlerInfoList = []; 5877 this.firingIndex = -1; 5878 }, 5879 AddHandler: function(handler, executionContext) { 5880 if(typeof(executionContext) == "undefined") 5881 executionContext = null; 5882 this.RemoveHandler(handler, executionContext); 5883 var handlerInfo = ASPxClientEvent.CreateHandlerInfo(handler, executionContext); 5884 this.handlerInfoList.push(handlerInfo); 5885 }, 5886 RemoveHandler: function(handler, executionContext) { 5887 this.removeHandlerByCondition(function(handlerInfo) { 5888 return handlerInfo.handler == handler && 5889 (!executionContext || handlerInfo.executionContext == executionContext); 5890 }); 5891 }, 5892 removeHandlerByCondition: function(predicate) { 5893 for(var i = this.handlerInfoList.length - 1; i >= 0; i--) { 5894 var handlerInfo = this.handlerInfoList[i]; 5895 if(predicate(handlerInfo)) { 5896 ASPx.Data.ArrayRemoveAt(this.handlerInfoList, i); 5897 if(i <= this.firingIndex) 5898 this.firingIndex--; 5899 } 5900 } 5901 }, 5902 removeHandlerByControlName: function(controlName) { 5903 this.removeHandlerByCondition(function(handlerInfo) { 5904 return handlerInfo.executionContext && 5905 handlerInfo.executionContext.name === controlName; 5906 }); 5907 }, 5908 ClearHandlers: function() { 5909 this.handlerInfoList.length = 0; 5910 }, 5911 FireEvent: function(obj, args) { 5912 for(this.firingIndex = 0; this.firingIndex < this.handlerInfoList.length; this.firingIndex++) { 5913 var handlerInfo = this.handlerInfoList[this.firingIndex]; 5914 handlerInfo.handler.call(handlerInfo.executionContext, obj, args); 5915 } 5916 }, 5917 InsertFirstHandler: function(handler, executionContext){ 5918 if(typeof(executionContext) == "undefined") 5919 executionContext = null; 5920 var handlerInfo = ASPxClientEvent.CreateHandlerInfo(handler, executionContext); 5921 ASPx.Data.ArrayInsert(this.handlerInfoList, handlerInfo, 0); 5922 }, 5923 IsEmpty: function() { 5924 return this.handlerInfoList.length == 0; 5925 } 5926}); 5927ASPxClientEvent.CreateHandlerInfo = function(handler, executionContext) { 5928 return { 5929 handler: handler, 5930 executionContext: executionContext 5931 }; 5932}; 5933var ASPxClientEventArgs = ASPx.CreateClass(null, { 5934 constructor: function() { 5935 } 5936}); 5937ASPxClientEventArgs.Empty = new ASPxClientEventArgs(); 5938var ASPxClientCancelEventArgs = ASPx.CreateClass(ASPxClientEventArgs, { 5939 constructor: function(){ 5940 this.constructor.prototype.constructor.call(this); 5941 this.cancel = false; 5942 } 5943}); 5944var ASPxClientProcessingModeEventArgs = ASPx.CreateClass(ASPxClientEventArgs, { 5945 constructor: function(processOnServer){ 5946 this.constructor.prototype.constructor.call(this); 5947 this.processOnServer = !!processOnServer; 5948 } 5949}); 5950var ASPxClientProcessingModeCancelEventArgs = ASPx.CreateClass(ASPxClientProcessingModeEventArgs, { 5951 constructor: function(processOnServer){ 5952 this.constructor.prototype.constructor.call(this, processOnServer); 5953 this.cancel = false; 5954 } 5955}); 5956var OrderedMap = ASPx.CreateClass(null, { 5957 constructor: function(){ 5958 this.entries = {}; 5959 this.firstEntry = null; 5960 this.lastEntry = null; 5961 }, 5962 add: function(key, element) { 5963 var entry = this.addEntry(key, element); 5964 this.entries[key] = entry; 5965 }, 5966 remove: function(key) { 5967 var entry = this.entries[key]; 5968 if(entry === undefined) 5969 return; 5970 this.removeEntry(entry); 5971 delete this.entries[key]; 5972 }, 5973 clear: function() { 5974 this.markAllEntriesAsRemoved(); 5975 this.entries = {}; 5976 this.firstEntry = null; 5977 this.lastEntry = null; 5978 }, 5979 get: function(key) { 5980 var entry = this.entries[key]; 5981 return entry ? entry.value : undefined; 5982 }, 5983 forEachEntry: function(processFunc, context) { 5984 context = context || this; 5985 for(var entry = this.firstEntry; entry; entry = entry.next) { 5986 if(entry.removed) 5987 continue; 5988 if(processFunc.call(context, entry.key, entry.value)) 5989 return; 5990 } 5991 }, 5992 addEntry: function(key, element) { 5993 var entry = { key: key, value: element, next: null, prev: null }; 5994 if(!this.firstEntry) 5995 this.firstEntry = entry; 5996 else { 5997 entry.prev = this.lastEntry; 5998 this.lastEntry.next = entry; 5999 } 6000 this.lastEntry = entry; 6001 return entry; 6002 }, 6003 removeEntry: function(entry) { 6004 if(this.firstEntry == entry) 6005 this.firstEntry = entry.next; 6006 if(this.lastEntry == entry) 6007 this.lastEntry = entry.prev; 6008 if(entry.prev) 6009 entry.prev.next = entry.next; 6010 if(entry.next) 6011 entry.next.prev = entry.prev; 6012 entry.removed = true; 6013 }, 6014 markAllEntriesAsRemoved: function() { 6015 for(var entry = this.firstEntry; entry; entry = entry.next) 6016 entry.removed = true; 6017 } 6018}); 6019var CollectionBase = ASPx.CreateClass(null, { 6020 constructor: function(){ 6021 this.elementsMap = new OrderedMap(); 6022 this.isASPxClientCollection = true; 6023 }, 6024 Add: function(key, element) { 6025 this.elementsMap.add(key, element); 6026 }, 6027 Remove: function(key) { 6028 this.elementsMap.remove(key); 6029 }, 6030 Clear: function(){ 6031 this.elementsMap.clear(); 6032 }, 6033 Get: function(key){ 6034 return this.elementsMap.get(key); 6035 } 6036}); 6037(function garbageCollector(ASPx, options) { 6038 ASPx.modules.garbageCollector = garbageCollector; 6039 var interval = options.GCCheckInterval; 6040 window.setInterval(collectObjects, interval); 6041 function canCollectObjects() { 6042 if (!ASPx.GetControlCollection) return false; 6043 var collection = ASPx.GetControlCollection(); 6044 return collection && !collection.InCallback(); 6045 } 6046 function collectObjects() { 6047 if (!canCollectObjects()) return; 6048 ASPx.GetControlCollectionCollection().RemoveDisposedControls(); 6049 if(typeof(ASPx.GetStateController) != "undefined") 6050 ASPx.GetStateController().RemoveDisposedItems();
6051 if(ASPx.TableScrollHelperCollection) 6052 ASPx.TableScrollHelperCollection.RemoveDisposedObjects(); 6053 if(ASPx.Ident.scripts.ASPxClientRatingControl) 6054 ASPxClientRatingControl.RemoveDisposedElementUnderCursor(); 6055 var postHandler = ASPx.GetPostHandler(); 6056 if(postHandler) 6057 postHandler.RemoveDisposedFormsFromCache(); 6058 } 6059})(ASPx, options); 6060var ControlTree = ASPx.CreateClass(null, { 6061 constructor: function(controlCollection, container, controlFilter) { 6062 this.container = container; 6063 this.domMap = { }; 6064 this.rootNode = this.createNode(null, null); 6065 this.createControlTree(controlCollection, container, controlFilter); 6066 }, 6067 createControlTree: function(controlCollection, container, controlFilter) { 6068 controlCollection.ProcessControlsInContainer(container, function(control) { 6069 control.RegisterInControlTree(this); 6070 }.aspxBind(this), controlFilter); 6071 var fixedNodes = []; 6072 var fixedNodesChildren = []; 6073 for(var domElementID in this.domMap) { 6074 if(!this.domMap.hasOwnProperty(domElementID)) continue; 6075 var node = this.domMap[domElementID]; 6076 var controlOwner = node.control ? node.control.controlOwner : null; 6077 if(controlOwner && this.domMap[controlOwner.name]) 6078 continue; 6079 if(this.isFixedNode(node)) 6080 fixedNodes.push(node); 6081 else { 6082 var parentNode = this.findParentNode(domElementID); 6083 parentNode = parentNode || this.rootNode; 6084 if(this.isFixedNode(parentNode)) 6085 fixedNodesChildren.push(node); 6086 else { 6087 var childNode = node.mainNode || node; 6088 this.addChildNode(parentNode, childNode); 6089 } 6090 } 6091 } 6092 for(var i = fixedNodes.length - 1; i >= 0; i--) 6093 this.insertChildNode(this.rootNode, fixedNodes[i], 0); 6094 for(var i = fixedNodesChildren.length - 1; i >= 0; i--) 6095 this.insertChildNode(this.rootNode, fixedNodesChildren[i], 0); 6096 }, 6097 findParentNode: function(id) { 6098 var element = document.getElementById(id).parentNode; 6099 while(element && element.tagName !== "BODY") { 6100 if(element.id) { 6101 var parentNode = this.domMap[element.id]; 6102 if(parentNode) 6103 return parentNode; 6104 } 6105 element = element.parentNode; 6106 } 6107 return null; 6108 }, 6109 addChildNode: function(node, childNode) { 6110 if(!childNode.parentNode) { 6111 node.children.push(childNode); 6112 childNode.parentNode = node; 6113 } 6114 }, 6115 insertChildNode: function(node, childNode, index) { 6116 if(!childNode.parentNode) { 6117 ASPx.Data.ArrayInsert(node.children, childNode, index); 6118 childNode.parentNode = node; 6119 } 6120 }, 6121 addRelatedNode: function(node, relatedNode) { 6122 this.addChildNode(node, relatedNode); 6123 relatedNode.mainNode = node; 6124 }, 6125 isFixedNode: function(node) { 6126 var control = node.mainNode ? node.mainNode.control : node.control; 6127 return control && control.HasFixedPosition(); 6128 }, 6129 createNode: function(domElementID, control) { 6130 var node = { 6131 control: control, 6132 children: [], 6133 parentNode: null, 6134 mainNode: null 6135 }; 6136 if(domElementID) 6137 this.domMap[domElementID] = node; 6138 return node; 6139 } 6140}); 6141var ControlAdjuster = ASPx.CreateClass(null, { 6142 constructor: function() { 6143 }, 6144 adjustControlsInHierarchy: function(controlCollection, adjustFunc, container, collapseControls, controlFilter) { 6145 var controlTree = new ASPx.ControlTree(controlCollection, container, controlFilter); 6146 this.adjustControlsInTree(controlTree.rootNode, adjustFunc, container, collapseControls); 6147 }, 6148 adjustControlsInTree: function(treeNode, adjustFunc, container, collapseControls) { 6149 var observer = _aspxGetDomObserver(); 6150 observer.pause(container, true); 6151 var documentScrollInfo; 6152 if(collapseControls) { 6153 documentScrollInfo = ASPx.GetOuterScrollPosition(document.body); 6154 this.collapseControls(treeNode); 6155 } 6156 var adjustNodes = [], 6157 autoHeightNodes = []; 6158 var requireReAdjust = this.forEachControlCore(treeNode, collapseControls, adjustFunc, adjustNodes, autoHeightNodes); 6159 if(requireReAdjust) 6160 this.forEachControlsBackward(adjustNodes, collapseControls, adjustFunc); 6161 else { 6162 for(var i = 0, node; node = autoHeightNodes[i]; i++) 6163 node.control.AdjustAutoHeight(); 6164 } 6165 if(collapseControls) 6166 ASPx.RestoreOuterScrollPosition(documentScrollInfo); 6167 observer.resume(container, true); 6168 }, 6169 forEachControlCore: function(node, collapseControls, processFunc, adju
6169stNodes, autoHeightNodes) { 6170 var requireReAdjust = false, 6171 size, newSize; 6172 if(node.control) { 6173 var checkReadjustment = collapseControls && node.control.IsControlCollapsed() && node.control.CanCauseReadjustment(); 6174 if(checkReadjustment) 6175 size = node.control.GetControlPercentMarkerSize(false, true); 6176 if(node.control.IsControlCollapsed() && !node.control.IsExpandableByAdjustment()) 6177 node.control.ExpandControl(); 6178 node.control.isInsideHierarchyAdjustment = true; 6179 processFunc(node.control); 6180 node.control.isInsideHierarchyAdjustment = false; 6181 if(checkReadjustment) { 6182 newSize = node.control.GetControlPercentMarkerSize(false, true); 6183 requireReAdjust = size.width !== newSize.width; 6184 } 6185 if(node.control.sizingConfig.supportAutoHeight) 6186 autoHeightNodes.push(node); 6187 node.control.ResetControlPercentMarkerSize(); 6188 } 6189 for(var childNode, i = 0; childNode = node.children[i]; i++) 6190 requireReAdjust = this.forEachControlCore(childNode, collapseControls, processFunc, adjustNodes, autoHeightNodes) || requireReAdjust; 6191 adjustNodes.push(node); 6192 return requireReAdjust; 6193 }, 6194 forEachControlsBackward: function(adjustNodes, collapseControls, processFunc) { 6195 for(var i = 0, node; node = adjustNodes[i]; i++) 6196 this.forEachControlsBackwardCore(node, collapseControls, processFunc); 6197 }, 6198 forEachControlsBackwardCore: function(node, collapseControls, processFunc) { 6199 if(node.control) 6200 processFunc(node.control); 6201 if(node.children.length > 1) { 6202 for(var i = 0, childNode; childNode = node.children[i]; i++) { 6203 if(childNode.control) 6204 processFunc(childNode.control); 6205 } 6206 } 6207 }, 6208 collapseControls: function(node) { 6209 for(var childNode, i = 0; childNode = node.children[i]; i++) 6210 this.collapseControls(childNode); 6211 if(node.control && node.control.NeedCollapseControl()) 6212 node.control.CollapseControl(); 6213 } 6214}); 6215var controlAdjuster = null; 6216function GetControlAdjuster() { 6217 if(!controlAdjuster) 6218 controlAdjuster = new ControlAdjuster(); 6219 return controlAdjuster; 6220} 6221function _aspxFunctionIsInCallstack(currentCallee, targetFunction, depthLimit) { 6222 var candidate = currentCallee; 6223 var depth = 0; 6224 while(candidate && depth <= depthLimit) { 6225 candidate = candidate.caller; 6226 if(candidate == targetFunction) 6227 return true; 6228 depth++; 6229 } 6230 return false; 6231} 6232ASPx.attachToReady(aspxClassesWindowOnLoad); 6233function aspxClassesWindowOnLoad(){ 6234 ASPx.documentLoaded = true; 6235 _aspxMoveLinkElements(); 6236 _aspxSweepDuplicatedLinks(); 6237 ResourceManager.SynchronizeResources(); 6238 var externalScriptProcessor = GetExternalScriptProcessor(); 6239 if(externalScriptProcessor) 6240 externalScriptProcessor.ShowErrorMessages(); 6241 ASPx.AccessibilityUtils.initialize(); 6242 ASPx.GetControlCollection().Initialize(); 6243 _aspxInitializeScripts(); 6244 _aspxInitializeLinks(); 6245 _aspxInitializeFocus(); 6246 ASPx.GetControlCollection().FinalizeInitialization(); 6247} 6248Ident = { }; 6249Ident.IsDate = function(obj) { 6250 return obj && obj.constructor == Date; 6251}; 6252Ident.IsRegExp = function(obj) { 6253 return obj && obj.constructor === RegExp; 6254}; 6255Ident.IsArray = function(obj) { 6256 return obj && obj.constructor == Array; 6257}; 6258Ident.IsASPxClientCollection = function(obj) { 6259 return obj && obj.isASPxClientCollection; 6260}; 6261Ident.IsASPxClientControl = function(obj) { 6262 return obj && obj instanceof ASPxClientControlBase; 6263}; 6264Ident.IsASPxClientEdit = function(obj) { 6265 return obj && obj.isASPxClientEdit; 6266}; 6267Ident.IsFocusableElementRegardlessTabIndex = function (element) { 6268 var tagName = element.tagName; 6269 return tagName == "TEXTAREA" || tagName == "INPUT" || tagName == "A" || 6270 tagName == "SELECT" || tagName == "IFRAME" || tagName == "OBJECT" || tagName == "BUTTON"; 6271}; 6272Ident.isDialogInvisibleControl = function(control) { 6273 return !!ASPx.Dialog && ASPx.Dialog.isDialogInvisibleControl(control); 6274}; 6275Ident.isBatchEditUnusedEditor = function(control) { 6276 return !!ASPx.BatchEditHelper && ASPx.BatchEditHelper.isBatchEditUnusedEditor(control); 6277}; 6278Ident.scripts = {}; 6279if(ASPx.IsFunction(window.WebForm_InitCallbackAddField)) { 6280 (function() { 6281 var original = window.WebForm_InitCallbackAddField; 6282 window.WebForm_InitCallbackAddField = function(name, value) { 6283 if(typeof(name) == "string" && name) 6284 original.apply(null, arguments); 6285 }; 6286 })(); 6287} 6288ASPx.FireDefaultButton = function(evt, buttonID) { 6289 if(_aspxIsDefaultButtonEvent(evt, buttonID)) { 6290 var defaultButton = ASPx.GetElementById(buttonID);
6291 if(defaultButton && defaultButton.click) { 6292 if(ASPx.IsFocusable(defaultButton)) 6293 defaultButton.focus(); 6294 ASPx.Evt.DoElementClick(defaultButton); 6295 ASPx.Evt.PreventEventAndBubble(evt); 6296 return false; 6297 } 6298 } 6299 return true; 6300}; 6301function _aspxIsDefaultButtonEvent(evt, defaultButtonID) { 6302 if(evt.keyCode != ASPx.Key.Enter) 6303 return false; 6304 var srcElement = ASPx.Evt.GetEventSource(evt); 6305 if(!srcElement || srcElement.id === defaultButtonID) 6306 return true; 6307 var tagName = srcElement.tagName; 6308 var type = srcElement.type; 6309 return tagName != "TEXTAREA" && tagName != "BUTTON" && tagName != "A" && 6310 (tagName != "INPUT" || type != "checkbox" && type != "radio" && type != "button" && type != "submit" && type != "reset"); 6311} 6312var PostHandler = ASPx.CreateClass(null, { 6313 constructor: function() { 6314 this.Post = new ASPxClientEvent(); 6315 this.PostFinalization = new ASPxClientEvent(); 6316 this.observableForms = []; 6317 this.dxCallbackTriggers = {}; 6318 this.lastSubmitElementName = null; 6319 this.beforeOnSubmit = function() { }; 6320 this.ReplaceGlobalPostFunctions(); 6321 this.HandleDxCallbackBeginning(); 6322 this.HandleMSAjaxRequestBeginning(); 6323 }, 6324 Update: function() { 6325 this.ReplaceFormsSubmit(true); 6326 }, 6327 ProcessPostRequest: function(ownerID, isCallback, isMSAjaxRequest, isDXCallback) { 6328 this.cancelPostProcessing = false; 6329 this.isMSAjaxRequest = isMSAjaxRequest; 6330 if(this.SkipRaiseOnPost(ownerID, isCallback, isDXCallback)) 6331 return; 6332 var args = new PostHandlerOnPostEventArgs(ownerID, isCallback, isMSAjaxRequest, isDXCallback); 6333 this.Post.FireEvent(this, args); 6334 this.cancelPostProcessing = args.cancel; 6335 if(!args.cancel) 6336 this.PostFinalization.FireEvent(this, args); 6337 }, 6338 SkipRaiseOnPost: function(ownerID, isCallback, isDXCallback) { 6339 if(!isCallback) 6340 return false; 6341 var dxOwner = isDXCallback && ASPx.GetControlCollection().GetByName(ownerID); 6342 if(dxOwner) { 6343 this.dxCallbackTriggers[dxOwner.uniqueID] = true; 6344 return false; 6345 } 6346 if(this.dxCallbackTriggers[ownerID]) { 6347 this.dxCallbackTriggers[ownerID] = false; 6348 return true; 6349 } 6350 return false; 6351 }, 6352 ReplaceGlobalPostFunctions: function() { 6353 if(ASPx.IsFunction(window.__doPostBack)) 6354 this.ReplaceDoPostBack(); 6355 if(ASPx.IsFunction(window.WebForm_DoCallback)) 6356 this.ReplaceDoCallback(); 6357 if(ASPx.IsFunction(window.WebForm_ExecuteCallback)) 6358 this.ReplaceExecuteCallback(); 6359 this.ReplaceFormsSubmit(); 6360 }, 6361 HandleDxCallbackBeginning: function() { 6362 ASPx.GetControlCollection().BeforeInitCallback.AddHandler(function(s, e) { 6363 aspxRaisePostHandlerOnPost(e.callbackOwnerID, true, false, true); 6364 }); 6365 }, 6366 HandleMSAjaxRequestBeginning: function() { 6367 var pageRequestManager = ASPx.GetMSAjaxRequestManager(); 6368 if(pageRequestManager != null && Ident.IsArray(pageRequestManager._onSubmitStatements)) { 6369 pageRequestManager._onSubmitStatements.unshift(function() { 6370 var postbackSettings = Sys.WebForms.PageRequestManager.getInstance()._postBackSettings; 6371 var postHandler = aspxGetPostHandler(); 6372 aspxRaisePostHandlerOnPost(postbackSettings.asyncTarget, true, true); 6373 return !postHandler.cancelPostProcessing; 6374 }); 6375 } 6376 }, 6377 ReplaceDoPostBack: function() { 6378 var original = __doPostBack; 6379 __doPostBack = function(eventTarget, eventArgument) { 6380 var postHandler = aspxGetPostHandler(); 6381 aspxRaisePostHandlerOnPost(eventTarget); 6382 if(postHandler.cancelPostProcessing) 6383 return; 6384 ASPxClientControl.postHandlingLocked = true; 6385 original(eventTarget, eventArgument); 6386 delete ASPxClientControl.postHandlingLocked; 6387 }; 6388 }, 6389 ReplaceDoCallback: function() { 6390 var original = WebForm_DoCallback; 6391 WebForm_DoCallback = function(eventTarget, eventArgument, eventCallback, context, errorCallback, useAsync) { 6392 var postHandler = aspxGetPostHandler(); 6393 aspxRaisePostHandlerOnPost(eventTarget, true); 6394 if(postHandler.cancelPostProcessing) 6395 return; 6396 return original(eventTarget, eventArgument, eventCallback, context, errorCallback, useAsync); 6397 }; 6398 }, 6399 ReplaceExecuteCallback: function() { 6400 var original = WebForm_ExecuteCallback; 6401 var handler = this; 6402 WebForm_ExecuteCallback = function(callbackObject) { 6403 var isDxCallback = callbackObject && callbackObject.context && ASPx.GetControlCollection().Get(callbackObject.context) !== null; 6404 ASPx.callbackProcessed = false; 6405 original(callbackObject);
6406 if(isDxCallback && !ASPx.callbackProcessed) { 6407 var request = callbackObject.xmlRequest; 6408 if(handler.HasAppErrorOnCallback(request) && ASPxClientUtils.IsExists(callbackObject.eventCallback)) 6409 callbackObject.eventCallback(handler.GetServerErrorText(), callbackObject.context); 6410 } 6411 }; 6412 }, 6413 HasAppErrorOnCallback: function(request) { 6414 if(!request) return false; 6415 var isServerError = request.status && request.status == 500; 6416 var pattern = /<html[^>]*>([\w|\W]*)<\/html>/im; 6417 var text = request.responseText; 6418 return isServerError && !!text && pattern.test(text); 6419 }, 6420 GetServerErrorText: function() { 6421 return "Internal Server Error"; 6422 }, 6423 ReplaceFormsSubmit: function(checkObservableCollection) { 6424 for(var i = 0; i < document.forms.length; i++) { 6425 var form = document.forms[i]; 6426 if(checkObservableCollection && ASPx.Data.ArrayIndexOf(this.observableForms, form) >= 0) 6427 continue; 6428 if(form.submit) 6429 this.ReplaceFormSubmit(form); 6430 this.ReplaceFormOnSumbit(form); 6431 this.observableForms.push(form); 6432 } 6433 }, 6434 ReplaceFormSubmit: function(form) { 6435 var originalSubmit = form.submit; 6436 form.submit = function() { 6437 var postHandler = aspxGetPostHandler(); 6438 aspxRaisePostHandlerOnPost(); 6439 if(postHandler.cancelPostProcessing) 6440 return false; 6441 var callee = arguments.callee; 6442 this.submit = originalSubmit; 6443 var submitResult = this.submit(); 6444 this.submit = callee; 6445 return submitResult; 6446 }; 6447 form = null; 6448 }, 6449 ReplaceFormOnSumbit: function(form) { 6450 var originalSubmit = form.onsubmit; 6451 form.onsubmit = function() { 6452 var postHandler = aspxGetPostHandler(); 6453 postHandler.beforeOnSubmit(); 6454 if(postHandler.isMSAjaxRequest) 6455 postHandler.isMsAjaxRequest = false; 6456 else 6457 aspxRaisePostHandlerOnPost(postHandler.GetLastSubmitElementName()); 6458 if(postHandler.cancelPostProcessing) 6459 return false; 6460 return ASPx.IsFunction(originalSubmit) 6461 ? originalSubmit.apply(this, arguments) 6462 : true; 6463 }; 6464 form = null; 6465 }, 6466 SetBeforeOnSubmit: function(action) { 6467 this.beforeOnSubmit = action; 6468 }, 6469 SetLastSubmitElementName: function(elementName) { 6470 this.lastSubmitElementName = elementName; 6471 }, 6472 GetLastSubmitElementName: function() { 6473 return this.lastSubmitElementName; 6474 }, 6475 RemoveDisposedFormsFromCache: function(){ 6476 for(var i = 0; this.observableForms && i < this.observableForms.length; i++){ 6477 var form = this.observableForms[i]; 6478 if(!ASPx.IsExistsElement(form)){ 6479 ASPx.Data.ArrayRemove(this.observableForms, form); 6480 i--; 6481 } 6482 } 6483 } 6484}); 6485function aspxRaisePostHandlerOnPost(ownerID, isCallback, isMSAjaxRequest, isDXCallback) { 6486 if(ASPxClientControl.postHandlingLocked) return; 6487 var postHandler = aspxGetPostHandler(); 6488 if(postHandler) 6489 postHandler.ProcessPostRequest(ownerID, isCallback, isMSAjaxRequest, isDXCallback); 6490} 6491var aspxPostHandler; 6492function aspxGetPostHandler() { 6493 if(!aspxPostHandler) 6494 aspxPostHandler = new PostHandler(); 6495 return aspxPostHandler; 6496} 6497var PostHandlerOnPostEventArgs = ASPx.CreateClass(ASPxClientCancelEventArgs, { 6498 constructor: function(ownerID, isCallback, isMSAjaxCallback, isDXCallback){ 6499 this.constructor.prototype.constructor.call(this); 6500 this.ownerID = ownerID; 6501 this.isCallback = !!isCallback; 6502 this.isDXCallback = !!isDXCallback; 6503 this.isMSAjaxCallback = !!isMSAjaxCallback; 6504 } 6505}); 6506var ResourceManager = { 6507 HandlerStr: "DXR.axd?r=", 6508 ResourceHashes: {}, 6509 SynchronizeResources: function(method){ 6510 if(!method){ 6511 method = function(name, resource) { 6512 this.UpdateInputElements(name, resource); 6513 }.aspxBind(this); 6514 } 6515 var resources = this.GetResourcesData(); 6516 for(var name in resources) 6517 if(resources.hasOwnProperty(name)) 6518 method(name, resources[name]); 6519 }, 6520 GetResourcesData: function(){ 6521 return { 6522 DXScript: this.GetResourcesElementsString(_aspxGetIncludeScripts(), "src", "DXScript"), 6523 DXCss: this.GetResourcesElementsString(_aspxGetLinks(), "href", "DXCss") 6524 }; 6525 }, 6526 ParseBundleSrc: function(elements, urlAttr){ 6527 var timeStamp = ""; 6528 var resourceUrlArray = []; 6529 for(var i = 0; i < elements.length; i++) { 6530 var resourceUrl = ASPx.Attr.GetAttribute(elements[i], urlAttr); 6531 if(resourceUrl) { 6532 var pos = resourceUrl.indexOf(this.HandlerStr); 6533 if(pos > -1){ 6534 var list = resourceUrl.substr(pos + this.HandlerStr.length); 6535 var ampPos = list.lastIndexOf("-"); 6536 if(ampPos > -1) { 6537 timeStamp = list.substr(ampPos);
6538 list = list.substr(0, ampPos); 6539 } 6540 var indexes = list.split(","); 6541 for(var j = 0; j < indexes.length; j++) { 6542 resourceUrlArray.push(indexes[j]); 6543 } 6544 } 6545 else 6546 resourceUrlArray.push(resourceUrl); 6547 } 6548 } 6549 return { 6550 'resourceUrlArray': resourceUrlArray, 6551 'timeStamp': timeStamp 6552 }; 6553 }, 6554 GetResourceHashes: function (id) { 6555 if (!this.ResourceHashes[id]) 6556 this.ResourceHashes[id] = {}; 6557 return this.ResourceHashes[id]; 6558 }, 6559 GetResourcesElementsString: function (elements, urlAttr, id) { 6560 var hash = this.GetResourceHashes(id); 6561 var resourceUrlArray = this.ParseBundleSrc(elements, urlAttr).resourceUrlArray; 6562 for(var i = 0; i < resourceUrlArray.length; i++) { 6563 hash[resourceUrlArray[i]] = resourceUrlArray[i]; 6564 } 6565 var array = []; 6566 for(var key in hash) 6567 if(hash.hasOwnProperty(key)) 6568 array.push(key); 6569 return array.join(","); 6570 }, 6571 GetNewResourcesElementString: function (element, urlAttr, id) { 6572 var originalUrl = ASPx.Attr.GetAttribute(element, urlAttr); 6573 var handlerStrIndex = originalUrl.indexOf(this.HandlerStr); 6574 var dxResources = handlerStrIndex > -1; 6575 if(!dxResources) return element[urlAttr]; 6576 var hash = this.GetResourceHashes(id); 6577 var srcInfo = this.ParseBundleSrc([element], urlAttr); 6578 var resourceUrlArray = srcInfo.resourceUrlArray; 6579 var timeStamp = srcInfo.timeStamp; 6580 var newResourceArray = []; 6581 for(var i = 0; i < resourceUrlArray.length; i++) { 6582 if(!hash[resourceUrlArray[i]]) 6583 newResourceArray.push(resourceUrlArray[i]); 6584 } 6585 var newResources = ""; 6586 if(newResourceArray.length > 0) { 6587 var baseUrl = originalUrl.substr(0, handlerStrIndex); 6588 newResources = baseUrl + this.HandlerStr + newResourceArray.join(",") + timeStamp; 6589 } 6590 return newResources; 6591 }, 6592 UpdateInputElements: function(typeName, list){ 6593 for(var i = 0; i < document.forms.length; i++){ 6594 var inputElement = document.forms[i][typeName]; 6595 if(!inputElement) 6596 inputElement = this.CreateInputElement(document.forms[i], typeName); 6597 inputElement.value = list; 6598 } 6599 }, 6600 CreateInputElement: function(form, typeName){ 6601 var inputElement = ASPx.CreateHiddenField(typeName); 6602 form.appendChild(inputElement); 6603 return inputElement; 6604 } 6605}; 6606ASPx.includeScriptPrefix = "dxis_"; 6607ASPx.startupScriptPrefix = "dxss_"; 6608var includeScriptsCache = {}; 6609var createdIncludeScripts = []; 6610var appendedScriptsCount = 0; 6611var callbackOwnerNames = []; 6612var scriptsRestartHandlers = { }; 6613function _aspxIsKnownIncludeScript(script) { 6614 return !!includeScriptsCache[script.src]; 6615} 6616function _aspxCacheIncludeScript(script) { 6617 includeScriptsCache[script.src] = 1; 6618} 6619function _aspxProcessScriptsAndLinks(ownerName, isCallback) { 6620 if(!ASPx.documentLoaded) return; 6621 _aspxProcessScripts(ownerName, isCallback); 6622 getLinkProcessor().process(); 6623 ASPx.ClearCachedCssRules(); 6624} 6625function _aspxGetStartupScripts(container) { 6626 return _aspxGetScriptsCore(ASPx.startupScriptPrefix, container); 6627} 6628function _aspxGetIncludeScripts() { 6629 return _aspxGetScriptsCore(ASPx.includeScriptPrefix); 6630} 6631function _aspxGetScriptsCore(prefix, container) { 6632 var result = []; 6633 var scripts; 6634 if(ASPx.IsExists(container)) 6635 scripts = ASPx.GetNodesByTagName(container, "SCRIPT"); 6636 else 6637 scripts = document.getElementsByTagName("SCRIPT"); 6638 for(var i = 0; i < scripts.length; i++) { 6639 if(scripts[i].id.indexOf(prefix) == 0) 6640 result.push(scripts[i]); 6641 } 6642 return result; 6643} 6644function _aspxGetLinks() { 6645 var result = []; 6646 var links = document.getElementsByTagName("LINK"); 6647 for(var i = 0; i < links.length; i++) 6648 result[i] = links[i]; 6649 return result; 6650} 6651function _aspxIsLinksLoaded() { 6652 var links = _aspxGetLinks(); 6653 for(var i = 0, link; link = links[i]; i++) 6654 if(link.readyState && link.readyState.toLowerCase() == "loading") 6655 return false; 6656 return true; 6657} 6658function _aspxInitializeLinks() { 6659 var links = _aspxGetLinks(); 6660 for(var i = 0; i < links.length; i++) 6661 links[i].loaded = true; 6662} 6663var scriptExecutedAttrName = "data-executed"; 6664var scriptDelayedExecutionAttrName = "data-dx-delayedeval"; 6665ASPx.MarkInnerScriptBlocksAsDelayedExecution = function(scriptsContainer) { 6666 var scripts = scriptsContainer.querySelectorAll("script[id^=" + ASPx.startupScriptPrefix + "]"); 6667 for(var i = 0; i < scripts.length; i++) 6668 ASPx.Attr.SetAttribute(scripts[i], scriptDelayedExecutionAttrName, true); 6669}; 6670function isScriptExecuted(script) { 6671 return ASPx.Attr.GetAttribute(script, scriptExecutedAttrName); 6672} 6673function markScriptAsExecuted(script) { 6674 if(ASPx.Attr.GetAttribute(script, scriptDelayedExecutionAttrName)) 6675 ASPx.Attr.RemoveAttribute(script, scriptDelayedExecutionAttrName); 6676 else
6677 ASPx.Attr.SetAttribute(script, scriptExecutedAttrName, true); 6678} 6679function _aspxInitializeScripts() { 6680 var scripts = _aspxGetIncludeScripts(); 6681 for(var i = 0; i < scripts.length; i++) 6682 _aspxCacheIncludeScript(scripts[i]); 6683 var startupScripts = _aspxGetStartupScripts(); 6684 for(var i = 0; i < startupScripts.length; i++) 6685 markScriptAsExecuted(startupScripts[i]); 6686} 6687function _aspxSweepDuplicatedLinks() { 6688 var hash = { }; 6689 var links = _aspxGetLinks(); 6690 for(var i = 0; i < links.length; i++) { 6691 var href = links[i].href; 6692 if(!href) 6693 continue; 6694 if(hash[href]){ 6695 if((ASPx.Browser.IE || !hash[href].loaded) && links[i].loaded) { 6696 ASPx.RemoveElement(hash[href]); 6697 hash[href] = links[i]; 6698 } 6699 else 6700 ASPx.RemoveElement(links[i]); 6701 } 6702 else 6703 hash[href] = links[i]; 6704 } 6705} 6706function _aspxSweepDuplicatedScripts() { 6707 var hash = { }; 6708 var scripts = _aspxGetIncludeScripts(); 6709 for(var i = 0; i < scripts.length; i++) { 6710 var src = scripts[i].src; 6711 if(!src) continue; 6712 if(hash[src]) 6713 ASPx.RemoveElement(scripts[i]); 6714 else 6715 hash[src] = scripts[i]; 6716 } 6717} 6718function _aspxAreScriptsEqual(script1, script2) { 6719 return script1.src == script2.src; 6720} 6721function _aspxProcessScripts(ownerName, isCallback) { 6722 var scripts = _aspxGetIncludeScripts(); 6723 var previousCreatedScript = null; 6724 var firstCreatedScript = null; 6725 for(var i = 0; i < scripts.length; i++) { 6726 var script = scripts[i]; 6727 if(script.src == "") continue; 6728 if(_aspxIsKnownIncludeScript(script)) 6729 continue; 6730 var getOnlyNewResources = true; 6731 var onlyNewScripts = ResourceManager.GetNewResourcesElementString(script, "src", "DXScript", getOnlyNewResources); 6732 if (onlyNewScripts == "") 6733 continue; 6734 var createdScript = document.createElement("script"); 6735 ASPx.Attr.AppendScriptType(createdScript); 6736 createdScript.src = onlyNewScripts; 6737 createdScript.id = script.id; 6738 if(ASPx.Data.ArrayIndexOf(createdIncludeScripts, createdScript, _aspxAreScriptsEqual) >= 0) 6739 continue; 6740 createdIncludeScripts.push(createdScript); 6741 ASPx.RemoveElement(script); 6742 if(ASPx.Browser.IE && ASPx.Browser.Version < 9) { 6743 createdScript.onreadystatechange = new Function("ASPx.OnScriptReadyStateChangedCallback(this, " + isCallback + ");"); 6744 } else if(ASPx.Browser.Edge || ASPx.Browser.WebKitFamily || (ASPx.Browser.Firefox && ASPx.Browser.Version >= 4) || ASPx.Browser.IE && ASPx.Browser.Version >= 9) { 6745 createdScript.onload = new Function("ASPx.OnScriptLoadCallback(this, " + isCallback + ");"); 6746 if(firstCreatedScript == null) 6747 firstCreatedScript = createdScript; 6748 createdScript.nextCreatedScript = null; 6749 if(previousCreatedScript != null) 6750 previousCreatedScript.nextCreatedScript = createdScript; 6751 previousCreatedScript = createdScript; 6752 } else { 6753 createdScript.onload = new Function("ASPx.OnScriptLoadCallback(this);"); 6754 ASPx.AppendScript(createdScript); 6755 _aspxCacheIncludeScript(createdScript); 6756 } 6757 } 6758 if(firstCreatedScript != null) { 6759 ASPx.AppendScript(firstCreatedScript); 6760 _aspxCacheIncludeScript(firstCreatedScript); 6761 } 6762 if(isCallback) 6763 callbackOwnerNames.push(ownerName); 6764 if(createdIncludeScripts.length == 0) { 6765 var newLinks = ASPx.GetNodesByTagName(document.body, "link"); 6766 var needProcessLinks = isCallback && newLinks.length > 0; 6767 if(needProcessLinks) 6768 needProcessLinks = getLinkProcessor().addLinks(newLinks); 6769 if(!needProcessLinks) 6770 ASPx.FinalizeScriptProcessing(isCallback); 6771 } 6772} 6773ASPx.FinalizeScriptProcessing = function(isCallback) { 6774 createdIncludeScripts = []; 6775 appendedScriptsCount = 0; 6776 var linkProcessor = getLinkProcessor(); 6777 if(linkProcessor.hasLinks()) 6778 _aspxSweepDuplicatedLinks(); 6779 linkProcessor.reset(); 6780 _aspxSweepDuplicatedScripts(); 6781 ResourceManager.SynchronizeResources(); 6782 _aspxRunStartupScripts(isCallback); 6783}; 6784var startupScriptsRunning = false; 6785function _aspxRunStartupScripts(isCallback, container) { 6786 startupScriptsRunning = true; 6787 try { 6788 _aspxRunStartupScriptsCore(container); 6789 } 6790 finally { 6791 startupScriptsRunning = false; 6792 } 6793 if(ASPx.documentLoaded) { 6794 ASPx.GetControlCollection().ProcessActionByPredicate( 6795 function(collection) { collection.InitializeElements(isCallback); }, 6796 function(control) { return !ASPx.IsExists(container) || ASPx.GetIsParent(container, control.GetMainElement()); } 6797 ); 6798 for(var key in scriptsRestartHandlers) 6799 if(scriptsRestartHandlers.hasOwnProperty(key)) 6800 scriptsRestartHandlers[key](); 6801 _aspxRunEndCallbackScript(); 6802 } 6803} 6804function _aspxIsStartupScriptsRunning(isCallback) { 6805 return startupScriptsRunning; 6806} 6807function _aspxRunStartupScriptsCore(container) { 6808 var scripts = _aspxGetStartupScripts(container); 6809 var code; 6810 for(var i = 0; i < scripts.length; i++){ 6811 var script = scripts[i]; 6812 if(!isScriptExecuted(script)) { 6813 _aspxEnsureStartupScriptIsUnique(script.id); 6814 code = ASPx.GetScriptCode(script); 6815 eval(code); 6816 markScriptAsExecuted(script); 6817 } 6818 } 6819} 6820function _aspxEnsureStartupScriptIsUnique(scriptId) { 6821 if(!scriptId) 6822 return; 6823 var scriptExecutedSelector = "script[" + scriptExecutedAttrName + "='true']#" + scriptId; 6824 ASPx.RemoveElement(document.querySelector(scriptExecutedSelector)); 6825} 6826function _aspxRunEndCallbackScript() { 6827 while(callbackOwnerNames.length > 0) { 6828 var callbackOwnerName = callbackOwnerNames.pop(); 6829 var callbackOwner = ASPx.GetControlCollection().Get(callbackOwnerName); 6830 if(callbackOwner) 6831 callbackOwner.DoEndCallback(); 6832 } 6833} 6834ASPx.OnScriptReadyStateChangedCallback = function(scriptElement, isCallback) { 6835 if(scriptElement.readyState == "loaded") { 6836 _aspxCacheIncludeScript(scriptElement); 6837 for(var i = 0; i < createdIncludeScripts.length; i++) { 6838 var script = createdIncludeScripts[i]; 6839 if(_aspxIsKnownIncludeScript(script)) { 6840 if(!isScriptExecuted(script)) { 6841 markScriptAsExecuted(script); 6842 ASPx.AppendScript(script); 6843 appendedScriptsCount++; 6844 } 6845 } else 6846 break; 6847 } 6848 if(createdIncludeScripts.length == appendedScriptsCount) 6849 ASPx.FinalizeScriptProcessing(isCallback); 6850 } 6851}; 6852ASPx.OnScriptLoadCallback = function(scriptElement, isCallback) { 6853 appendedScriptsCount++; 6854 if(scriptElement.nextCreatedScript) { 6855 ASPx.AppendScript(scriptElement.nextCreatedScript); 6856 _aspxCacheIncludeScript(scriptElement.nextCreatedScript); 6857 } 6858 if(createdIncludeScripts.length == appendedScriptsCount) 6859 ASPx.FinalizeScriptProcessing(isCallback); 6860}; 6861function _aspxAddScriptsRestartHandler(objectName, handler) { 6862 scriptsRestartHandlers[objectName] = handler; 6863} 6864function _aspxMoveLinkElements() { 6865 var head = ASPx.GetNodesByTagName(document, "head")[0]; 6866 var bodyLinks = ASPx.GetNodesByTagName(document.body, "link"); 6867 if(head && bodyLinks.length > 0){ 6868 var headLinks = ASPx.GetNodesByTagName(head, "link"); 6869 var dxLinkAnchor = head.firstChild; 6870 for(var i = 0; i < headLinks.length; i++){ 6871 if(headLinks[i].href.indexOf(ResourceManager.HandlerStr) > -1) 6872 dxLinkAnchor = headLinks[i].nextSibling; 6873 } 6874 while(bodyLinks.length > 0) 6875 head.insertBefore(bodyLinks[0], dxLinkAnchor); 6876 } 6877} 6878var LinkProcessor = ASPx.CreateClass(null, { 6879 constructor: function() { 6880 this.loadedLinkCount = 0; 6881 this.linkInfos = []; 6882 this.loadingObservationTimerID = -1; 6883 }, 6884 process: function() { 6885 if(this.hasLinks()) { 6886 if(this.isLinkLoadEventSupported()) 6887 this.processViaLoadEvent(); 6888 else 6889 this.processViaTimer(); 6890 } 6891 else 6892 _aspxSweepDuplicatedLinks();
6893 _aspxMoveLinkElements(); 6894 }, 6895 addLinks: function(links) { 6896 var prevLinkCount = this.linkInfos.length; 6897 for(var i = 0; i < links.length; i++) { 6898 var link = links[i]; 6899 if(link.loaded || link.rel != "stylesheet" || link.href.toLowerCase().indexOf("dxr.axd?r=") == -1) 6900 continue; 6901 var linkInfo = { 6902 link: link, 6903 href: link.href 6904 }; 6905 this.linkInfos.push(linkInfo); 6906 } 6907 return prevLinkCount != this.linkInfos.length; 6908 }, 6909 hasLinks: function() { 6910 return this.linkInfos.length > 0; 6911 }, 6912 reset: function() { 6913 this.linkInfos = []; 6914 this.loadedLinkCount = 0; 6915 }, 6916 processViaLoadEvent: function() { 6917 var that = this; 6918 for(var i = 0, linkInfo; linkInfo = this.linkInfos[i]; i++) { 6919 if(ASPx.Browser.IE && ASPx.Browser.Version < 9) 6920 linkInfo.link.onreadystatechange = function() { that.onLinkReadyStateChanged(this); }; 6921 else 6922 linkInfo.link.onload = this.onLinkLoad.aspxBind(this); 6923 } 6924 }, 6925 isLinkLoadEventSupported: function() { 6926 return !(ASPx.Browser.Chrome && ASPx.Browser.MajorVersion < 19 || ASPx.Browser.Firefox && ASPx.Browser.MajorVersion < 9 || 6927 ASPx.Browser.Safari && ASPx.Browser.MajorVersion < 6 || ASPx.Browser.AndroidDefaultBrowser && ASPx.Browser.MajorVersion < 4.4); 6928 }, 6929 processViaTimer: function() { 6930 if(this.loadingObservationTimerID == -1) 6931 this.onLinksLoadingObserve(); 6932 }, 6933 onLinksLoadingObserve: function() { 6934 if(this.getIsAllLinksLoaded()) { 6935 this.loadingObservationTimerID = -1; 6936 this.onAllLinksLoad(); 6937 } 6938 else 6939 this.loadingObservationTimerID = window.setTimeout(this.onLinksLoadingObserve.aspxBind(this), 100); 6940 }, 6941 getIsAllLinksLoaded: function() { 6942 var styleSheets = document.styleSheets; 6943 var loadedLinkHrefs = { }; 6944 for(var i = 0; i < styleSheets.length; i++) { 6945 var styleSheet = styleSheets[i]; 6946 try { 6947 if(styleSheet.cssRules) 6948 loadedLinkHrefs[styleSheet.href] = 1; 6949 } 6950 catch(ex) { } 6951 } 6952 var loadedLinksCount = 0; 6953 for(var i = 0, linkInfo; linkInfo = this.linkInfos[i]; i++) { 6954 if(loadedLinkHrefs[linkInfo.href]) 6955 loadedLinksCount++; 6956 } 6957 return loadedLinksCount == this.linkInfos.length; 6958 }, 6959 onAllLinksLoad: function() { 6960 this.reset(); 6961 _aspxSweepDuplicatedLinks(); 6962 if(createdIncludeScripts.length == 0) 6963 ASPx.FinalizeScriptProcessing(true); 6964 }, 6965 onLinkReadyStateChanged: function(linkElement) { 6966 if(linkElement.readyState == "complete") 6967 this.onLinkLoadCore(linkElement); 6968 }, 6969 onLinkLoad: function(evt) { 6970 var linkElement = ASPx.Evt.GetEventSource(evt); 6971 this.onLinkLoadCore(linkElement); 6972 }, 6973 onLinkLoadCore: function(linkElement) { 6974 if(!this.hasLinkElement(linkElement)) return; 6975 this.loadedLinkCount++; 6976 if(!ASPx.Browser.Firefox && this.loadedLinkCount == this.linkInfos.length || 6977 ASPx.Browser.Firefox && this.loadedLinkCount == 2 * this.linkInfos.length) { 6978 this.onAllLinksLoad(); 6979 } 6980 }, 6981 hasLinkElement: function(linkElement) { 6982 for(var i = 0, linkInfo; linkInfo = this.linkInfos[i]; i++) { 6983 if(linkInfo.link == linkElement) 6984 return true; 6985 } 6986 return false; 6987 } 6988}); 6989var linkProcessor = null; 6990function getLinkProcessor() { 6991 if(linkProcessor == null) 6992 linkProcessor = new LinkProcessor(); 6993 return linkProcessor; 6994} 6995ASPx.LinkProcessor = LinkProcessor; 6996var IFrameHelper = ASPx.CreateClass(null, { 6997 constructor: function(params) { 6998 this.params = params || {}; 6999 this.params.src = this.params.src || ""; 7000 this.CreateElements(); 7001 }, 7002 CreateElements: function() { 7003 var elements = IFrameHelper.Create(this.params); 7004 this.containerElement = elements.container; 7005 this.iframeElement = elements.iframe; 7006 this.AttachOnLoadHandler(this, this.iframeElement); 7007 this.SetLoading(true); 7008 if(this.params.onCreate) 7009 this.params.onCreate(this.containerElement, this.iframeElement); 7010 }, 7011 AttachOnLoadHandler: function(instance, element) { 7012 ASPx.Evt.AttachEventToElement(element, "load", function() { 7013 instance.OnLoad(element); 7014 }); 7015 }, 7016 OnLoad: function(element) { 7017 this.SetLoading(false, element); 7018 if(!element.preventCustomOnLoad && this.params.onLoad) 7019 this.params.onLoad(); 7020 }, 7021 IsLoading: function(element) { 7022 element = element || this.iframeElement; 7023 if(element) 7024 return element.loading; 7025 return false; 7026 }, 7027 SetLoading: function(value, element) { 7028 element = element || this.iframeElement; 7029 if(element) 7030 element.loading = value; 7031 }, 7032 GetContentUrl: function() { 7033 return this.params.src; 7034 }, 7035 SetContentUrl: function(url, preventBrowserCaching) { 7036 if(url) { 7037 this.params.src = url; 7038 if(preventBrowserCaching) 7039 url = IFrameHelper.AddRandomParamToUrl(url);
7040 this.SetLoading(true); 7041 this.iframeElement.src = url; 7042 } 7043 }, 7044 RefreshContentUrl: function() { 7045 if(this.IsLoading()) 7046 return; 7047 this.SetLoading(true); 7048 var oldContainerElement = this.containerElement; 7049 var oldIframeElement = this.iframeElement; 7050 var postfix = "_del" + Math.floor(Math.random()*100000).toString(); 7051 if(this.params.id) 7052 oldIframeElement.id = this.params.id + postfix; 7053 if(this.params.name) 7054 oldIframeElement.name = this.params.name + postfix; 7055 ASPx.SetStyles(oldContainerElement, { height: 0 }); 7056 this.CreateElements(); 7057 oldIframeElement.preventCustomOnLoad = true; 7058 oldIframeElement.src = ASPx.BlankUrl; 7059 window.setTimeout(function() { 7060 oldContainerElement.parentNode.removeChild(oldContainerElement); 7061 }, 10000); 7062 } 7063}); 7064IFrameHelper.Create = function(params) { 7065 var iframeHtmlStringParts = [ "<iframe frameborder='0'" ]; 7066 if(params) { 7067 if(params.id) 7068 iframeHtmlStringParts.push(" id='", params.id, "'"); 7069 if(params.name) 7070 iframeHtmlStringParts.push(" name='", params.name, "'"); 7071 if(params.title) 7072 iframeHtmlStringParts.push(" title='", params.title, "'"); 7073 if(params.scrolling) 7074 iframeHtmlStringParts.push(" scrolling='", params.scrolling, "'"); 7075 if(params.src) 7076 iframeHtmlStringParts.push(" src='", params.src, "'"); 7077 } 7078 iframeHtmlStringParts.push("></iframe>"); 7079 var containerElement = ASPx.CreateHtmlElementFromString("<div style='border-width: 0px; padding: 0px; margin: 0px'></div>"); 7080 var iframeElement = ASPx.CreateHtmlElementFromString(iframeHtmlStringParts.join("")); 7081 containerElement.appendChild(iframeElement); 7082 return { 7083 container: containerElement, 7084 iframe: iframeElement 7085 }; 7086}; 7087IFrameHelper.AddRandomParamToUrl = function(url) { 7088 var prefix = url.indexOf("?") > -1 7089 ? "&" 7090 : "?"; 7091 var param = prefix + Math.floor(Math.random()*100000).toString(); 7092 var anchorIndex = url.indexOf("#"); 7093 return anchorIndex == -1 7094 ? url + param 7095 : url.substr(0, anchorIndex) + param + url.substr(anchorIndex); 7096}; 7097IFrameHelper.GetWindow = function(name) { 7098 if(ASPx.Browser.IE) 7099 return window.frames[name].window; 7100 else{ 7101 var frameElement = document.getElementById(name); 7102 return (frameElement != null) ? frameElement.contentWindow : null; 7103 } 7104}; 7105IFrameHelper.GetDocument = function(name) { 7106 var frameElement; 7107 if(ASPx.Browser.IE) { 7108 frameElement = window.frames[name]; 7109 return (frameElement != null) ? frameElement.document : null; 7110 } 7111 else { 7112 frameElement = document.getElementById(name); 7113 return (frameElement != null) ? frameElement.contentDocument : null; 7114 } 7115}; 7116IFrameHelper.GetDocumentBody = function(name) { 7117 var doc = IFrameHelper.GetDocument(name); 7118 return (doc != null) ? doc.body : null; 7119}; 7120IFrameHelper.GetDocumentHead = function (name) { 7121 var doc = IFrameHelper.GetDocument(name); 7122 return (doc != null) ? doc.head || doc.getElementsByTagName('head')[0] : null; 7123}; 7124IFrameHelper.GetElement = function(name) { 7125 if(ASPx.Browser.IE) 7126 return window.frames[name].window.frameElement; 7127 else 7128 return document.getElementById(name); 7129}; 7130var KbdHelper = ASPx.CreateClass(null, { 7131 constructor: function(control) { 7132 this.control = control; 7133 }, 7134 Init: function() { 7135 KbdHelper.GlobalInit(); 7136 var elements = this.getFocusableElements(); 7137 for(var i = 0; i < elements.length; i++) { 7138 var element = elements[i]; 7139 element.tabIndex = Math.max(element.tabIndex, 0); 7140 ASPx.Evt.AttachEventToElement(element, "click", function(e) { this.HandleClick(e); }.aspxBind(this)); 7141 ASPx.Evt.AttachEventToElement(element, "focus", function(e) { 7142 return this.onElementFocus(e); 7143 }.aspxBind(this)); 7144 ASPx.Evt.AttachEventToElement(element, "blur", function () { this.onBlur(); }.aspxBind(this)); 7145 } 7146 }, 7147 onElementFocus: function(e) { 7148 if(!this.CanFocus(e)) 7149 return true; 7150 KbdHelper.active = this; 7151 }, 7152 getFocusableElements: function() { 7153 return [this.GetFocusableElement()]; 7154 }, 7155 GetFocusableElement: function() { return this.control.GetMainElement(); }, 7156 canHandleNoFocusAction: function() { 7157 var focusableElements = this.getFocusableElements(); 7158 for(var i = 0; i < focusableElements.length; i++) { 7159 if(focusableElements[i] === _aspxGetFocusedElement()) 7160 return false; 7161 } 7162 return true; 7163 }, 7164 RequirePreventScrollOnFocus: function() { return false; }, 7165 CanFocus: function(e) { 7166 var tag = ASPx.Evt.GetEventSource(e).tagName; 7167 return !(tag === "A" || tag === "TEXTAREA" || tag === "INPUT" || tag === "SELECT" || tag === "IFRAME" || tag === "OBJECT"); 7168 }, 7169 HandleClick: function(e) { 7170 if(!this.CanFocus(e)) 7171 return; 7172 this.Focus(); 7173 }, 7174 Focus: function() { 7175 var preventScroll = this.RequirePreventScrollOnFocus() && !ASPx.Browser.IE; 7176 var savedDocumentScrollTop = preventScroll ? ASPx.GetDocumentScrollTop() : -1; 7177 try { 7178 this.GetFocusableElement().focus({ preventScroll: preventScroll }); 7179 } catch(e) { } 7180 if(preventScroll && !this.IsNativePreventScrollOnFocusSupported() && savedDocumentScrollTop !== ASPx.GetDocumentScrollTop()) 7181 ASPx.SetDocumentScrollTop(savedDocumentScrollTop); 7182 }, 7183 IsNativePreventScrollOnFocusSupported: function() { 7184 if(this.isNativePreventScrollOnFocusSupported === undefined) 7185 this.isNativePreventScrollOnFocusSupported = this.CalcIsNativePreventScrollOnFocusSupported(); 7186 return this.isNativePreventScrollOnFocusSupported; 7187 }, 7188 CalcIsNativePreventScrollOnFocusSupported: function() { 7189 var result = false; 7190 try { 7191 ASPx.GetActiveElement().focus(Object.defineProperty({}, "preventScroll", { get: function() { result = true; } })); 7192 } catch(e) { result = false; } 7193 return result; 7194 }, 7195 onBlur: function(){ 7196 delete KbdHelper.active; 7197 }, 7198 HandleKeyDown: function(e) { }, 7199 HandleKeyPress: function(e) { }, 7200 HandleKeyUp: function (e) { }, 7201 HandleNoFocusAction: function(e) { }, 7202 FocusByAccessKey: function () { } 7203}); 7204KbdHelper.GlobalInit = function() { 7205 if(KbdHelper.ready) 7206 return; 7207 ASPx.Evt.AttachEventToDocument("keydown", KbdHelper.OnKeyDown); 7208 ASPx.Evt.AttachEventToDocument("keypress", KbdHelper.OnKeyPress); 7209 ASPx.Evt.AttachEventToDocument("keyup", KbdHelper.OnKeyUp); 7210 KbdHelper.ready = true; 7211}; 7212KbdHelper.swallowKey = false; 7213KbdHelper.accessKeys = { }; 7214KbdHelper.ProcessKey = function(e, actionName) { 7215 if(!KbdHelper.active) 7216 return; 7217 if (KbdHelper.active.canHandleNoFocusAction()) { 7218 KbdHelper.active["HandleNoFocusAction"](e, actionName); 7219 return; 7220 } 7221 var ctl = KbdHelper.active.control; 7222 if(ctl !== ASPx.GetControlCollection().Get(ctl.name)) { 7223 delete KbdHelper.active; 7224 return; 7225 } 7226 if(!KbdHelper.swallowKey) 7227 KbdHelper.swallowKey = KbdHelper.active[actionName](e); 7228 if(KbdHelper.swallowKey) 7229 ASPx.Evt.PreventEvent(e); 7230};
7231KbdHelper.OnKeyDown = function(e) { 7232 KbdHelper.swallowKey = false; 7233 if(KbdHelper.TryAccessKey(KbdHelper.getKeyName(e))) 7234 ASPx.Evt.PreventEvent(e); 7235 else 7236 KbdHelper.ProcessKey(e, "HandleKeyDown"); 7237}; 7238KbdHelper.OnKeyPress = function(e) { KbdHelper.ProcessKey(e, "HandleKeyPress"); }; 7239KbdHelper.OnKeyUp = function(e) { KbdHelper.ProcessKey(e, "HandleKeyUp"); }; 7240KbdHelper.RegisterAccessKey = function(obj) { 7241 var key; 7242 if(obj.accessKey) 7243 key = "CtrlShift" + obj.accessKey; 7244 else if(obj.keyTipModeShortcut) 7245 key = obj.keyTipModeShortcut; 7246 if(!key) return; 7247 KbdHelper.accessKeys[key.toLowerCase()] = obj.name; 7248}; 7249KbdHelper.TryAccessKey = function(code) { 7250 var key = code.toLowerCase ? code.toLowerCase() : String.fromCharCode(code).toLowerCase(); 7251 var name = KbdHelper.accessKeys[key]; 7252 if(!name) return false; 7253 var obj = ASPx.GetControlCollection().Get(name); 7254 return KbdHelper.ClickAccessKey(obj); 7255}; 7256KbdHelper.ClickAccessKey = function (control) { 7257 if (!control) return false; 7258 var el = control.GetMainElement(); 7259 if (!el) return false; 7260 el.focus(); 7261 setTimeout(function () { 7262 if (KbdHelper.active && KbdHelper.active.FocusByAccessKey) 7263 KbdHelper.active.FocusByAccessKey(); 7264 }.aspxBind(this), 100); 7265 return true; 7266}; 7267KbdHelper.getKeyName = function(e) { 7268 var name = ""; 7269 if(e.altKey) 7270 name += "Alt"; 7271 if(e.ctrlKey) 7272 name += "Ctrl"; 7273 if(e.shiftKey) 7274 name += "Shift"; 7275 var keyCode = e.key || e.code || String.fromCharCode(ASPx.Evt.GetKeyCode(e)); 7276 if(keyCode.match(/key/i)) 7277 name += keyCode.replace(/key/i, ""); 7278 else if(keyCode.match(/digit/i)) 7279 name += keyCode.replace(/digit/i, ""); 7280 else if(keyCode.match(/arrow/i)) 7281 name += keyCode.replace(/arrow/i, ""); 7282 else if(keyCode.match(/ins/i)) 7283 name += "Ins"; 7284 else if(keyCode.match(/del/i)) 7285 name += "Del"; 7286 else if(keyCode.match(/back/i)) 7287 name += "Back"; 7288 else if(!keyCode.match(/alt/i) && !keyCode.match(/control/i) && !keyCode.match(/shift/i)) 7289 name += keyCode; 7290 return name.replace(/^a-zA-Z0-9/, ""); 7291}; 7292AccessKeysHelper = ASPx.CreateClass(KbdHelper, { 7293 constructor: function (control) { 7294 this.constructor.prototype.constructor.call(this, control); 7295 this.accessKeysVisible = false; 7296 this.activeKey = null; 7297 this.accessKey = control.createAccessKey ? control.createAccessKey(control.accessKey) : new AccessKey(control.accessKey); 7298 this.accessKeys = this.accessKey.accessKeys; 7299 this.charIndex = 0; 7300 this.onFocusByAccessKey = null; 7301 this.onClose = null; 7302 this.manualStopProcessing = false; 7303 this.isActive = false; 7304 this.areAccessKeysShown = false; 7305 }, 7306 Init: function (control) { 7307 KbdHelper.prototype.Init.call(this); 7308 KbdHelper.RegisterAccessKey(control); 7309 }, 7310 Add: function (accessKey) { 7311 this.accessKey.Add(accessKey); 7312 }, 7313 HandleKeyDown: function (e) { 7314 var keyCode = ASPx.Evt.GetKeyCode(e); 7315 var stopProcessing = this.processKeyDown(keyCode); 7316 if (stopProcessing.value) { 7317 this.stopProcessing(); 7318 if(this.onClosedOnEscape && (keyCode == ASPx.Key.Esc || stopProcessing.fireEvent)) 7319 this.onClosedOnEscape(); 7320 } 7321 return stopProcessing; 7322 }, 7323 HandleNoFocusAction: function (e, actionName) { 7324 var keyCode = ASPx.Evt.GetKeyCode(e); 7325 if (this.onClosedOnEscape && keyCode == ASPx.Key.Esc && actionName == "HandleKeyDown") 7326 this.onClosedOnEscape(); 7327 }, 7328 Activate: function () { 7329 KbdHelper.ClickAccessKey(this.control); 7330 this.areAccessKeysShown = true; 7331 }, 7332 Stop: function() { 7333 this.stopProcessing(); 7334 }, 7335 stopProcessing: function () { 7336 this.HideAccessKeys(); 7337 if (KbdHelper.active && this.isActive) { 7338 this.isActive = false; 7339 KbdHelper.active.control.GetMainElement().blur(); 7340 delete KbdHelper.active; 7341 } 7342 }, 7343 onBlur: function() { 7344 if (this.manualStopProcessing) { 7345 this.manualStopProcessing = false; 7346 return; 7347 } 7348 this.HideAccessKeys(); 7349 KbdHelper.prototype.onBlur.call(this); 7350 }, 7351 processKeyDown: function (keyCode) { 7352 switch (keyCode) { 7353 case ASPx.Key.Left: 7354 this.TryMoveFocusLeft(); 7355 return { value: false }; 7356 case ASPx.Key.Right: 7357 this.TryMoveFocusRight(); 7358 return { value: false }; 7359 case ASPx.Key.Esc: 7360 if(this.control.hideAllPopups) 7361 this.control.hideAllPopups(true, true); 7362 if(this.activeKey) 7363 this.activeKey = this.activeKey.Return(); 7364 this.charIndex = 0; 7365 if (!this.activeKey) 7366 return { value: true }; 7367 break; 7368 case ASPx.Key.Enter: 7369 return { value: true }; 7370 default: 7371 if (!ASPx.IsPrintableKey(keyCode)) 7372 return { value: false }; 7373 var char = String.fromCharCode(keyCode).toUpperCase(); 7374 var needToContinue = { value: false }; 7375 var keyResult; 7376 if(this.activeKey)
7377 keyResult = this.activeKey.TryAccessKey(char, this.charIndex, needToContinue); 7378 if (needToContinue.value) { 7379 this.charIndex++; 7380 return { value: false }; 7381 } 7382 this.charIndex = 0; 7383 if(keyResult !== undefined) 7384 this.activeKey = keyResult; 7385 else 7386 return { value: true, fireEvent: true }; 7387 if (!this.activeKey || !this.activeKey.accessKeys || this.activeKey.accessKeys.length == 0) { 7388 if (this.activeKey && this.activeKey.manualStopProcessing) { 7389 this.manualStopProcessing = true; 7390 break; 7391 } 7392 return { value: true, fireEvent: true }; 7393 } 7394 } 7395 return { value: false }; 7396 }, 7397 TryMoveFocusLeft: function (modifier) {}, 7398 TryMoveFocusRight: function (modifier) {}, 7399 TryMoveFocusUp: function (modifier) {}, 7400 TryMoveFocusDown: function (modifier) {}, 7401 FocusByAccessKey: function() { 7402 if (this.onFocusByAccessKey) 7403 this.onFocusByAccessKey(); 7404 this.HideAccessKeys(); 7405 KbdHelper.prototype.FocusByAccessKey.call(this); 7406 this.activeKey = this.accessKey; 7407 this.activeKey.execute(); 7408 this.isActive = true; 7409 this.areAccessKeysShown = true; 7410 }, 7411 HideAccessKeys: function() { 7412 this.areAccessKeysShown = false; 7413 this.hideAccessKeys(this.accessKey); 7414 }, 7415 Update: function() { 7416 this.throttleMethod(this.refresh, 100); 7417 }, 7418 refresh: function() { 7419 if(this.activeKey && this.areAccessKeysShown) { 7420 this.activeKey.execute(); 7421 } 7422 }, 7423 throttleMethod: function(method, delay) { 7424 clearTimeout(method.timerId); 7425 method.timerId = setTimeout(function() { 7426 method.call(this); 7427 }.aspxBind(this), delay); 7428 }, 7429 AreAccessKeysShown: function() { 7430 return this.areAccessKeysShown; 7431 }, 7432 hideAccessKeys: function (accessKey) { 7433 for (var i = 0, ak; ak = accessKey.accessKeys[i]; i++) { 7434 this.hideAccessKeys(ak); 7435 } 7436 if (accessKey) 7437 accessKey.hide(); 7438 }, 7439 HandleClick: function(e) { 7440 KbdHelper.prototype.HandleClick.call(this, e); 7441 this.stopProcessing(); 7442 } 7443}); 7444AccessKey = ASPx.CreateClass(null, { 7445 constructor: function (popupItem, getPopupElement, keyTipElement, key, onlyClick, manualStopProcessing) { 7446 this.key = key ? key : keyTipElement ? ASPxClientUtils.Trim(ASPx.GetInnerText(keyTipElement)) : null; 7447 this.popupItem = popupItem; 7448 this.getPopupElement = getPopupElement; 7449 this.keyTipElement = keyTipElement; 7450 this.accessKeys = []; 7451 this.needShowChilds = true; 7452 this.parent = null; 7453 this.onlyClick = onlyClick; 7454 this.manualStopProcessing = manualStopProcessing; 7455 }, 7456 Add: function (accessKey) { 7457 this.accessKeys.push(accessKey); 7458 accessKey.parent = this; 7459 }, 7460 TryAccessKey: function (char, index, needToContinue) { 7461 if (!this.accessKeys || this.accessKeys.length == 0) 7462 return; 7463 for (var i = 0, accessKey; accessKey = this.accessKeys[i]; i++) { 7464 if (accessKey.key[index] == char && accessKey.isVisible()) { 7465 if (accessKey.key[index + 1]) { 7466 needToContinue.value = true; 7467 } 7468 else { 7469 accessKey.execute(); 7470 return accessKey; 7471 } 7472 } else { 7473 accessKey.hide(); 7474 } 7475 } 7476 for (var i = 0, accessKey; accessKey = this.accessKeys[i]; i++) { 7477 var key = accessKey.TryAccessKey(char, index, needToContinue); 7478 if (key) 7479 return key; 7480 } 7481 return; 7482 }, 7483 isVisible: function(){ 7484 return ASPx.GetElementVisibility(this.keyTipElement); 7485 }, 7486 Return: function () { 7487 this.hideChildAccessKeys(); 7488 if (this.parent) { 7489 this.parent.showAccessKeys(true); 7490 } 7491 return this.parent; 7492 }, 7493 execute: function () { 7494 this.hideAll(); 7495 if (this.popupItem && this.popupItem.accessKeyClick && !this.onlyClick) 7496 this.popupItem.accessKeyClick(); 7497 if (this.getPopupElement && this.onlyClick) 7498 ASPx.Evt.EmulateMouseClick(this.getPopupElement(this.popupItem)); 7499 if (this.accessKeys) 7500 setTimeout(function () { 7501 this.showAccessKeys(true); 7502 }.aspxBind(this), 100); 7503 }, 7504 showAccessKeys: function(directShow) { 7505 if (!directShow && !this.needShowChilds) 7506 return; 7507 for (var i = 0; i < this.accessKeys.length; i++) { 7508 var accessKey = this.accessKeys[i]; 7509 if (accessKey) { 7510 var popupElement = accessKey.getPopupElement ? accessKey.getPopupElement(accessKey.popupItem) : null; 7511 if (popupElement && this.isElementVisible(popupElement)) { 7512 this.show(accessKey); 7513 } 7514 accessKey.showAccessKeys(); 7515 } 7516 } 7517 }, 7518 isElementVisible: function (el) { return ASPx.IsElementVisible(el, true); }, 7519 show: function(accessKey) { 7520 var keyTipElement = accessKey.keyTipElement; 7521 var popupElement = accessKey.getPopupElement(accessKey.popupItem); 7522 this.showKeyTipElement(keyTipElement, this.calculateCoordinates(accessKey, keyTipElement, popupElement)); 7523 }, 7524 showKeyTipElement: function (keyTipElement, coordinates) { 7525 ASPx.SetAbsoluteY(keyTipElement, coordinates.top); 7526 ASPx.SetAbsoluteX(keyTipElement, coordinates.left); 7527 ASPx.SetElementVisibility(keyTipElement, true); 7528 }, 7529 calculateCoordinates: function (accessKey, keyTipElement, popupElement) { 7530 var top = ASPx.GetAbsolutePositionY(popupElement); 7531 var left = ASPx.GetAbsolutePositionX(popupElement); 7532 if (accessKey.popupItem.getAccessKeyPosition) 7533 switch (accessKey.popupItem.getAccessKeyPosition()) { 7534 case "AboveRight": 7535 left = left + popupElement.offsetWidth - keyTipElement.offsetWidth / 3; 7536 top = top - keyTipElement.offsetHeight / 2; 7537 break; 7538 case "Right": 7539 left = left + popupElement.offsetWidth - keyTipElement.offsetWidth / 3;
7540 top = top + popupElement.offsetHeight / 2 - keyTipElement.offsetHeight / 2; 7541 break; 7542 case "BelowRight": 7543 left = left + popupElement.offsetWidth - keyTipElement.offsetWidth / 3; 7544 top = top + keyTipElement.offsetHeight / 2; 7545 break; 7546 default: 7547 top = top + popupElement.offsetHeight; 7548 left = left + popupElement.offsetWidth / 2 - keyTipElement.offsetWidth / 2; 7549 break; 7550 } 7551 else { 7552 top = top + popupElement.offsetHeight; 7553 left = left + popupElement.offsetWidth / 2 - keyTipElement.offsetWidth / 2; 7554 } 7555 return { top: top, left: left }; 7556 }, 7557 hide: function() { 7558 if (this.keyTipElement) 7559 ASPx.SetElementVisibility(this.keyTipElement, false); 7560 }, 7561 hideChildAccessKeys: function () { 7562 this.hideAccessKeys(this.accessKeys); 7563 }, 7564 hideAccessKeys: function (accessKeys) { 7565 if (accessKeys) { 7566 for (var i = 0, accessKey; accessKey = accessKeys[i]; i++) { 7567 if (accessKey.keyTipElement) 7568 accessKey.hide(); 7569 accessKey.hideChildAccessKeys(); 7570 } 7571 } 7572 }, 7573 hideAll: function () { 7574 this.getRoot(this).hideChildAccessKeys(); 7575 }, 7576 getRoot: function (accessKey) { 7577 if (!accessKey.parent) 7578 return accessKey; 7579 return this.getRoot(accessKey.parent); 7580 } 7581}); 7582var focusedElement = null; 7583function aspxOnElementFocused(evt) { 7584 evt = ASPx.Evt.GetEvent(evt); 7585 if(evt && evt.target) 7586 focusedElement = evt.target; 7587} 7588function _aspxInitializeFocus() { 7589 if(!ASPx.GetActiveElement()) 7590 ASPx.Evt.AttachEventToDocument("focus", aspxOnElementFocused); 7591} 7592function _aspxGetFocusedElement() { 7593 var activeElement = ASPx.GetActiveElement(); 7594 return activeElement ? activeElement : focusedElement; 7595} 7596CheckBoxCheckState = { 7597 Checked : "Checked", 7598 Unchecked : "Unchecked", 7599 Indeterminate : "Indeterminate" 7600}; 7601CheckBoxInputKey = { 7602 Checked : "C", 7603 Unchecked : "U", 7604 Indeterminate : "I" 7605}; 7606var CheckableElementStateController = ASPx.CreateClass(null, { 7607 constructor: function(imageProperties) { 7608 this.checkBoxStates = []; 7609 this.imageProperties = imageProperties; 7610 this.customImageMarkerClassName = "dxcbCI"; 7611 }, 7612 GetValueByInputKey: function(inputKey) { 7613 return this.GetFirstValueBySecondValue("Value", "StateInputKey", inputKey); 7614 }, 7615 GetInputKeyByValue: function(value) { 7616 return this.GetFirstValueBySecondValue("StateInputKey", "Value", value); 7617 }, 7618 GetImagePropertiesNumByInputKey: function(value) { 7619 return this.GetFirstValueBySecondValue("ImagePropertiesNumber", "StateInputKey", value); 7620 }, 7621 GetNextCheckBoxValue: function(currentValue, allowGrayed) { 7622 var currentInputKey = this.GetInputKeyByValue(currentValue); 7623 var nextInputKey = ''; 7624 switch(currentInputKey) { 7625 case CheckBoxInputKey.Checked: 7626 nextInputKey = CheckBoxInputKey.Unchecked; break; 7627 case CheckBoxInputKey.Unchecked: 7628 nextInputKey = allowGrayed ? CheckBoxInputKey.Indeterminate : CheckBoxInputKey.Checked; break; 7629 case CheckBoxInputKey.Indeterminate: 7630 nextInputKey = CheckBoxInputKey.Checked; break; 7631 } 7632 return this.GetValueByInputKey(nextInputKey); 7633 }, 7634 GetCheckStateByInputKey: function(inputKey) { 7635 switch(inputKey) { 7636 case CheckBoxInputKey.Checked: 7637 return CheckBoxCheckState.Checked; 7638 case CheckBoxInputKey.Unchecked: 7639 return CheckBoxCheckState.Unchecked; 7640 case CheckBoxInputKey.Indeterminate: 7641 return CheckBoxCheckState.Indeterminate; 7642 } 7643 }, 7644 GetValueByCheckState: function(checkState) { 7645 switch(checkState) { 7646 case CheckBoxCheckState.Checked: 7647 return this.GetValueByInputKey(CheckBoxInputKey.Checked); 7648 case CheckBoxCheckState.Unchecked: 7649 return this.GetValueByInputKey(CheckBoxInputKey.Unchecked); 7650 case CheckBoxCheckState.Indeterminate: 7651 return this.GetValueByInputKey(CheckBoxInputKey.Indeterminate); 7652 } 7653 }, 7654 GetFirstValueBySecondValue: function(firstValueName, secondValueName, secondValue) { 7655 return this.GetValueByFunc(firstValueName, 7656 function(checkBoxState) { return checkBoxState[secondValueName] === secondValue; }); 7657 }, 7658 GetValueByFunc: function(valueName, func) { 7659 for(var i = 0; i < this.checkBoxStates.length; i++) { 7660 if(func(this.checkBoxStates[i])) 7661 return this.checkBoxStates[i][valueName]; 7662 } 7663 }, 7664 AssignElementClassName: function(element, cssClassPropertyKey, disabledCssClassPropertyKey, assignedClassName) { 7665 var classNames = [ ]; 7666 for(var i = 0; i < this.imageProperties[cssClassPropertyKey].length; i++) { 7667 classNames.push(this.imageProperties[disabledCssClassPropertyKey][i]); 7668 classNames.push(this.imageProperties[cssClassPropertyKey][i]); 7669 } 7670 var elementClassName = element.className; 7671 for(var i = 0; i < classNames.length; i++) { 7672 var className = classNames[i]; 7673 var index = elementClassName.indexOf(className); 7674 if(index > -1) 7675 elementClassName = elementClassName.replace((index == 0 ? '' : ' ') + className, ""); 7676 } 7677 elementClassName += " " + assignedClassName; 7678 element.className = elementClassName; 7679 }, 7680 UpdateInternalCheckBoxDecoration: function(mainElement, inputKey, enabled) { 7681 var imagePropertiesNumber = this.GetImagePropertiesNumByInputKey(inputKey); 7682 for(var imagePropertyKey in this.imageProperties) { 7683 if(this.imageProperties.hasOwnProperty(imagePropertyKey)) { 7684 var propertyValue = this.imageProperties[imagePropertyKey][imagePropertiesNumber]; 7685 propertyValue = propertyValue || !isNaN(propertyValue) ? propertyValue : ""; 7686 switch(imagePropertyKey) {
7687 case "0" : mainElement.title = propertyValue; break; 7688 case "1" : mainElement.style.width = propertyValue + (propertyValue != "" ? "px" : ""); break; 7689 case "2" : mainElement.style.height = propertyValue + (propertyValue != "" ? "px" : ""); break; 7690 } 7691 if(enabled) { 7692 switch(imagePropertyKey) { 7693 case "3" : this.SetImageSrc(mainElement, propertyValue); break; 7694 case "4" : 7695 this.AssignElementClassName(mainElement, "4", "8", propertyValue); 7696 break; 7697 case "5" : this.SetBackgroundPosition(mainElement, propertyValue, true); break; 7698 case "6" : this.SetBackgroundPosition(mainElement, propertyValue, false); break; 7699 } 7700 } else { 7701 switch(imagePropertyKey) { 7702 case "7" : this.SetImageSrc(mainElement, propertyValue); break; 7703 case "8" : 7704 this.AssignElementClassName(mainElement, "4", "8", propertyValue); 7705 break; 7706 case "9" : this.SetBackgroundPosition(mainElement, propertyValue, true); break; 7707 case "10" : this.SetBackgroundPosition(mainElement, propertyValue, false); break; 7708 } 7709 } 7710 } 7711 } 7712 }, 7713 SetImageSrc: function(mainElement, src) { 7714 if(src === ""){ 7715 mainElement.style.backgroundImage = ""; 7716 mainElement.style.backgroundPosition = ""; 7717 ASPx.RemoveClassNameFromElement(mainElement, this.customImageMarkerClassName); 7718 } 7719 else{ 7720 mainElement.style.backgroundImage = "url('" + src + "')"; 7721 this.SetBackgroundPosition(mainElement, 0, true); 7722 this.SetBackgroundPosition(mainElement, 0, false); 7723 ASPx.AddClassNameToElement(mainElement, this.customImageMarkerClassName); 7724 } 7725 }, 7726 SetBackgroundPosition: function(element, value, isX) { 7727 if(value === "") { 7728 element.style.backgroundPosition = value; 7729 return; 7730 } 7731 if(element.style.backgroundPosition === "") 7732 element.style.backgroundPosition = isX ? "-" + value.toString() + "px 0px" : "0px -" + value.toString() + "px"; 7733 else { 7734 var position = element.style.backgroundPosition.split(' '); 7735 element.style.backgroundPosition = isX ? '-' + value.toString() + "px " + position[1] : position[0] + " -" + value.toString() + "px"; 7736 } 7737 }, 7738 AddState: function(value, stateInputKey, imagePropertiesNumber) { 7739 this.checkBoxStates.push({ 7740 "Value" : value, 7741 "StateInputKey" : stateInputKey, 7742 "ImagePropertiesNumber" : imagePropertiesNumber 7743 }); 7744 }, 7745 GetAriaCheckedValue: function(state) { 7746 switch(state) { 7747 case ASPx.CheckBoxCheckState.Checked: return "true"; 7748 case ASPx.CheckBoxCheckState.Unchecked: return "false"; 7749 case ASPx.CheckBoxCheckState.Indeterminate: return "mixed"; 7750 default: return ""; 7751 } 7752 }, 7753 GetAriaSelectedValue: function(state) { 7754 switch(state) { 7755 case ASPx.CheckBoxCheckState.Checked: return "true"; 7756 case ASPx.CheckBoxCheckState.Unchecked: return "false"; 7757 case ASPx.CheckBoxCheckState.Indeterminate: return "undefined"; 7758 default: return ""; 7759 } 7760 }, 7761 SetAriaCheckedSelectedAttributes: function(mainElement, state) { 7762 if(mainElement.attributes["aria-checked"] !== undefined) { 7763 var ariaCheckedValue = this.GetAriaCheckedValue(state); 7764 mainElement.setAttribute("aria-checked", ariaCheckedValue); 7765 } 7766 if(mainElement.attributes["aria-selected"] !== undefined) { 7767 var ariaSelectedValue = this.GetAriaSelectedValue(state); 7768 mainElement.setAttribute("aria-selected", ariaSelectedValue); 7769 } 7770 } 7771}); 7772CheckableElementStateController.Create = function(imageProperties, valueChecked, valueUnchecked, valueGrayed, allowGrayed) { 7773 var stateController = new CheckableElementStateController(imageProperties); 7774 stateController.AddState(valueChecked, CheckBoxInputKey.Checked, 0); 7775 stateController.AddState(valueUnchecked, CheckBoxInputKey.Unchecked, 1); 7776 if(typeof(valueGrayed) != "undefined") 7777 stateController.AddState(valueGrayed, CheckBoxInputKey.Indeterminate, allowGrayed ? 2 : 1); 7778 stateController.allowGrayed = allowGrayed; 7779 return stateController; 7780}; 7781var CheckableElementHelper = ASPx.CreateClass(null, { 7782 InternalCheckBoxInitialize: function(internalCheckBox) { 7783 this.AttachToMainElement(internalCheckBox); 7784 this.AttachToInputElement(internalCheckBox); 7785 }, 7786 AttachToMainElement: function(internalCheckBox) { 7787 var instance = this; 7788 if(internalCheckBox.mainElement) { 7789 var toggleEvent = internalCheckBox.displaySwitch ? ASPx.TouchUIHelper.touchMouseDownEventName : "click"; 7790 ASPx.Evt.AttachEventToElement(internalCheckBox.mainElement, toggleEvent, 7791 function (evt) { 7792 if(ASPx.Evt.IsRightButtonPressed(evt)) 7793 return; 7794 instance.InvokeClick(internalCheckBox, evt); 7795 if(!internalCheckBox.disableCancelBubble) 7796 return ASPx.Evt.PreventEventAndBubble(evt); 7797 } 7798 ); 7799 ASPx.Evt.AttachEventToElement(internalCheckBox.mainElement, "mousedown", 7800 function (evt) { 7801 internalCheckBox.Refocus(); 7802 } 7803 ); 7804 ASPx.Evt.PreventElementDragAndSelect(internalCheckBox.mainElement, true); 7805 } 7806 }, 7807 AttachToInputElement: function(internalCheckBox) { 7808 var instance = this; 7809 if(internalCheckBox.inputElement && internalCheckBox.mainElement) { 7810 var checkableElement = internalCheckBox.accessibilityCompliant ? internalCheckBox.mainElement : internalCheckBox.inputElement; 7811 ASPx.Evt.AttachEventToElement(checkableElement, "focus", 7812 function (evt) { 7813 if(!internalCheckBox.enabled) 7814 checkableElement.blur(); 7815 else 7816 internalCheckBox.OnFocus(); 7817 } 7818 ); 7819 ASPx.Evt.AttachEventToElement(checkableElement, "blur", 7820 function (evt) { 7821 internalCheckBox.OnLostFocus(); 7822 } 7823 ); 7824 ASPx.Evt.AttachEventToElement(checkableElement, "keyup", 7825 function (evt) { 7826 if(ASPx.Evt.GetKeyCode(evt) == ASPx.Key.Space) 7827 instance.InvokeClick(internalCheckBox, evt); 7828 } 7829 ); 7830 ASPx.Evt.AttachEventToElement(checkableElement, "keydown", 7831 function (evt) { 7832 if(ASPx.Evt.GetKeyCode(evt) == ASPx.Key.Space) 7833 return ASPx.Evt.PreventEvent(evt); 7834 } 7835 ); 7836 } 7837 }, 7838 IsKBSInputWrapperExist: function() { 7839 return ASPx.Browser.Opera || ASPx.Browser.WebKitFamily; 7840 }, 7841 GetICBMainElementByInput: function(icbInputElement) { 7842 return this.IsKBSInputWrapperExist() ? icbInputElement.parentNode.parentNode : icbInputElement.parentNode; 7843 }, 7844 RequirePreventFocus: function() { return false; }, 7845 InvokeClick: function(internalCheckBox, evt) { 7846 if(internalCheckBox.enabled && !internalCheckBox.GetReadOnly()) { 7847 var inputElementValue = internalCheckBox.inputElement.value; 7848 var focusableElement = internalCheckBox.accessibilityCompliant ? internalCheckBox.mainElement : internalCheckBox.inputElement; 7849 if(!this.RequirePreventFocus()) 7850 focusableElement.focus(); 7851 if(!ASPx.Browser.IE) 7852 internalCheckBox.inputElement.value = inputElementValue; 7853 this.InvokeClickCore(internalCheckBox, evt); 7854 } 7855 }, 7856 InvokeClickCore: function(internalCheckBox, evt) { 7857 internalCheckBox.OnClick(evt); 7858 } 7859}); 7860CheckableElementHelper.Instance = new CheckableElementHelper(); 7861var CheckBoxInternal = ASPx.CreateClass(null, { 7862 constructor: function(inputElement, stateController, allowGrayed, allowGrayedByClick, helper, container, storeValueInInput, key, disableCancelBubble, 7863 accessibilityCompliant, displaySwitch) { 7864 this.inputElement = inputElement; 7865 this.mainElement = helper.GetICBMainElementByInput(this.inputElement); 7866 this.name = (key ? key : this.inputElement.id) + CheckBoxInternal.GetICBMainElementPostfix(); 7867 this.mainElement.id = this.name; 7868 this.stateController = stateController; 7869 this.container = container; 7870 this.allowGrayed = allowGrayed; 7871 this.allowGrayedByClick = allowGrayedByClick; 7872 this.autoSwitchEnabled = true; 7873 this.displaySwitch = displaySwitch; 7874 this.storeValueInInput = !!storeValueInInput; 7875 this.storedInputKey = !this.storeValueInInput ? this.inputElement.value : null; 7876 this.disableCancelBubble = !!disableCancelBubble; 7877 this.accessibilityCompliant = accessibilityCompliant; 7878 this.focusDecoration = null; 7879 this.focused = false; 7880 this.focusLocked = false; 7881 this.enabled = !this.mainElement.className.match(/dxWeb_\w+Disabled(\b|_)/); 7882 this.readOnly = false; 7883 this.preventFocus = helper.RequirePreventFocus(); 7884 this.CheckedChanged = new ASPxClientEvent(); 7885 this.Focus = new ASPxClientEvent(); 7886 this.LostFocus = new ASPxClientEvent(); 7887 helper.InternalCheckBoxInitialize(this); 7888 }, 7889 GetReadOnly: function() { 7890 return this.readOnly; 7891 }, 7892 ChangeInputElementTabIndex: function() { 7893 var changeMethod = this.enabled ? ASPx.Attr.RestoreTabIndexAttribute : ASPx.Attr.SaveTabIndexAttributeAndReset; 7894 changeMethod(this.inputElement); 7895 }, 7896 CreateFocusDecoration: function(focusedStyle) { 7897 this.focusDecoration = new FocusedStyleDecoration(this); 7898 this.focusDecoration.AddStyle('F', focusedStyle[0], focusedStyle[1]); 7899 this.focusDecoration.AddPostfix(""); 7900 }, 7901 UpdateFocusDecoration: function() { 7902 this.focusDecoration.Update(); 7903 }, 7904 StoreInputKey: function(inputKey) { 7905 if(this.storeValueInInput) 7906 this.inputElement.value = inputKey; 7907 else 7908 this.storedInputKey = inputKey; 7909 }, 7910 GetStoredInputKey: function() { 7911 if(this.storeValueInInput) 7912 return this.inputElement.value; 7913 else 7914 return this.storedInputKey; 7915 }, 7916 OnClick: function(e) { 7917 if(this.autoSwitchEnabled) { 7918 var currentValue = this.GetValue(); 7919 var value = this.stateController.GetNextCheckBoxValue(currentValue, this.allowGrayedByClick && this.allowGrayed); 7920 this.SetValue(value); 7921 } 7922 this.CheckedChanged.FireEvent(this, e); 7923 }, 7924 OnFocus: function() { 7925 if(!this.IsFocusLocked()) { 7926 this.focused = true; 7927 this.UpdateFocusDecoration(); 7928 this.Focus.FireEvent(this, null); 7929 } else 7930 this.UnlockFocus(); 7931 }, 7932 OnLostFocus: function() { 7933 if(!this.IsFocusLocked()) { 7934 this.focused = false; 7935 this.UpdateFocusDecoration(); 7936 this.LostFocus.FireEvent(this, null); 7937 } 7938 }, 7939 Refocus: function() { 7940 if(this.preventFocus) return; 7941 if(this.focused) {
7942 this.LockFocus(); 7943 this.inputElement.blur(); 7944 if(ASPx.Browser.MacOSMobilePlatform) { 7945 window.setTimeout(function() { 7946 ASPx.SetFocus(this.inputElement); 7947 }, 100); 7948 } else { 7949 ASPx.SetFocus(this.inputElement); 7950 } 7951 } 7952 }, 7953 LockFocus: function() { 7954 this.focusLocked = true; 7955 }, 7956 UnlockFocus: function() { 7957 this.focusLocked = false; 7958 }, 7959 IsFocusLocked: function() { 7960 if(!!ASPx.Attr.GetAttribute(this.mainElement, ASPx.Attr.GetTabIndexAttributeName())) 7961 return false; 7962 return this.focusLocked; 7963 }, 7964 SetValue: function(value, force) { 7965 var currentValue = this.GetValue(); 7966 if(currentValue !== value || force) { 7967 var newInputKey = this.stateController.GetInputKeyByValue(value); 7968 if(newInputKey) { 7969 this.StoreInputKey(newInputKey); 7970 this.stateController.UpdateInternalCheckBoxDecoration(this.mainElement, newInputKey, this.enabled); 7971 } 7972 } 7973 if(this.accessibilityCompliant) { 7974 var state = this.GetCurrentCheckState(); 7975 this.stateController.SetAriaCheckedSelectedAttributes(this.mainElement, state); 7976 } 7977 }, 7978 GetValue: function() { 7979 return this.stateController.GetValueByInputKey(this.GetCurrentInputKey()); 7980 }, 7981 GetCurrentCheckState: function() { 7982 return this.stateController.GetCheckStateByInputKey(this.GetCurrentInputKey()); 7983 }, 7984 GetCurrentInputKey: function() { 7985 return this.GetStoredInputKey(); 7986 }, 7987 GetChecked: function() { 7988 return this.GetCurrentInputKey() === CheckBoxInputKey.Checked; 7989 }, 7990 SetChecked: function(checked) { 7991 var newValue = this.stateController.GetValueByCheckState(checked ? CheckBoxCheckState.Checked : CheckBoxCheckState.Unchecked); 7992 this.SetValue(newValue); 7993 }, 7994 SetEnabled: function(enabled) { 7995 if(this.enabled != enabled) { 7996 this.enabled = enabled; 7997 this.stateController.UpdateInternalCheckBoxDecoration(this.mainElement, this.GetCurrentInputKey(), this.enabled); 7998 this.ChangeInputElementTabIndex(); 7999 } 8000 }, 8001 GetEnabled: function() { 8002 return this.enabled; 8003 } 8004}); 8005CheckBoxInternal.GetICBMainElementPostfix = function() { 8006 return "_D"; 8007}; 8008var CheckBoxInternalCollection = ASPx.CreateClass(CollectionBase, { 8009 constructor: function(imageProperties, allowGrayed, storeValueInInput, helper, disableCancelBubble, accessibilityCompliant) { 8010 this.constructor.prototype.constructor.call(this); 8011 this.stateController = allowGrayed 8012 ? CheckableElementStateController.Create(imageProperties, CheckBoxInputKey.Checked, CheckBoxInputKey.Unchecked, CheckBoxInputKey.Indeterminate, true) 8013 : CheckableElementStateController.Create(imageProperties, CheckBoxInputKey.Checked, CheckBoxInputKey.Unchecked); 8014 this.helper = helper || CheckableElementHelper.Instance; 8015 this.storeValueInInput = !!storeValueInInput; 8016 this.disableCancelBubble = !!disableCancelBubble; 8017 this.accessibilityCompliant = accessibilityCompliant; 8018 }, 8019 Add: function(key, inputElement, container) { 8020 this.Remove(key); 8021 var checkBox = this.CreateInternalCheckBox(key, inputElement, container); 8022 CollectionBase.prototype.Add.call(this, key, checkBox); 8023 return checkBox; 8024 }, 8025 SetImageProperties: function(imageProperties) { 8026 this.stateController.imageProperties = imageProperties; 8027 }, 8028 CreateInternalCheckBox: function(key, inputElement, container) { 8029 return new CheckBoxInternal(inputElement, this.stateController, this.stateController.allowGrayed, false, this.helper, container, 8030 this.storeValueInInput, key, this.disableCancelBubble, this.accessibilityCompliant); 8031 } 8032}); 8033var FocusedStyleDecoration = ASPx.CreateClass(null, { 8034 constructor: function(editor) { 8035 this.editor = editor; 8036 this.postfixList = []; 8037 this.styles = {}; 8038 this.innerStyles = {}; 8039 }, 8040 AddPostfix: function(value) { 8041 this.postfixList.push(value); 8042 }, 8043 AddStyle: function(key, className, cssText) { 8044 this.styles[key] = this.CreateRule(className, cssText); 8045 this.innerStyles[key] = this.CreateRule("", this.FilterInnerCss(cssText)); 8046 }, 8047 CreateRule: function(className, cssText) { 8048 return ASPx.Str.Trim(className + " " + ASPx.CreateImportantStyleRule(this.GetStyleSheet(), cssText)); 8049 }, 8050 GetStyleSheet: function() { 8051 return ASPx.GetCurrentStyleSheet(); 8052 }, 8053 FilterInnerCss: function(css) { 8054 return css.replace(/(border|background-image)[^:]*:[^;]+/gi, ""); 8055 }, 8056 Update: function() { 8057 for(var i = 0; i < this.postfixList.length; i++) { 8058 var postfix = this.postfixList[i]; 8059 var inner = postfix.length > 0;
8060 var element = this.GetElementByPostfix(postfix); 8061 if(element) 8062 this.ApplyStyles(element, inner); 8063 } 8064 }, 8065 GetElementByPostfix: function(postfix) { 8066 return ASPx.GetElementById(this.editor.name + postfix); 8067 }, 8068 ApplyStyles: function(element, inner) { 8069 this.ApplyFocusedStyle(element, inner); 8070 }, 8071 ApplyFocusedStyle: function(element, inner) { 8072 if(this.HasDecoration("F")) 8073 this.ApplyDecoration("F", element, inner, this.editor.focused); 8074 }, 8075 HasDecoration: function(key) { 8076 return !!this.styles[key]; 8077 }, 8078 ApplyDecoration: function(key, element, inner, active) { 8079 var value = inner ? this.innerStyles[key] : this.styles[key]; 8080 this.RemoveDecoration(element, value); 8081 if(active) { 8082 ASPx.AddClassNameToElement(element, value); 8083 if(ASPx.Browser.IE && ASPx.Browser.Version > 10 && element.border != null) 8084 this.EnsureElementBorder(element); 8085 } 8086 }, 8087 RemoveDecoration: function(element, value) { 8088 ASPx.RemoveClassNameFromElement(element, value); 8089 if(ASPx.Browser.IE && ASPx.Browser.MajorVersion >= 11) 8090 var dummy = element.offsetWidth; 8091 }, 8092 ApplyDecorationCore: function() { 8093 }, 8094 EnsureElementBorder: function(element) { 8095 var border = parseInt(element.border) || 0; 8096 element.border = 1; 8097 element.border = border; 8098 } 8099}); 8100var EditorStyleDecoration = ASPx.CreateClass(FocusedStyleDecoration, { 8101 constructor: function(editor) { 8102 this.constructor.prototype.constructor.call(this, editor); 8103 this.lockUpdate = false; 8104 }, 8105 LockUpdate: function() { 8106 this.lockUpdate = true; 8107 }, 8108 UnlockUpdate: function() { 8109 this.lockUpdate = false; 8110 }, 8111 IsUpdateLocked: function() { 8112 return this.lockUpdate; 8113 }, 8114 Update: function () { 8115 if(this.IsUpdateLocked()) 8116 return; 8117 ASPx.FocusedStyleDecoration.prototype.Update.call(this); 8118 }, 8119 ApplyStyles: function (element, inner) { 8120 this.ApplyInvalidStyle(element, inner); 8121 ASPx.FocusedStyleDecoration.prototype.ApplyStyles.call(this, element, inner); 8122 }, 8123 ApplyInvalidStyle: function (element, inner) { 8124 if(this.HasDecoration("I")) { 8125 var isValid = this.editor.GetIsValid(); 8126 this.ApplyDecoration("I", element, inner, !isValid); 8127 } 8128 } 8129}); 8130var TextEditorStyleDecoration = ASPx.CreateClass(EditorStyleDecoration, { 8131 constructor: function(editor) { 8132 this.constructor.prototype.constructor.call(this, editor); 8133 this.nullTextClassName = ""; 8134 }, 8135 ApplyStyles: function(element, inner) { 8136 ASPx.EditorStyleDecoration.prototype.ApplyStyles.call(this, element, inner); 8137 this.ApplyNullTextStyle(element, inner); 8138 }, 8139 ApplyNullTextStyle: function(element, inner) { 8140 if(!this.HasDecoration("N")) 8141 return; 8142 var apply = !this.editor.focused && this.editor.CanApplyNullTextDecoration(); 8143 this.EnsureSpellcheckAttribute(element, apply); 8144 this.ApplyDecoration("N", element, inner, apply); 8145 }, 8146 EnsureSpellcheckAttribute: function(element, apply) { 8147 if(apply) 8148 ASPx.Attr.ChangeAttribute(element, "spellcheck", "false"); 8149 else 8150 ASPx.Attr.RestoreAttribute(element, "spellcheck"); 8151 }, 8152 ApplyNullTextClassName: function(active) { 8153 var nullTextClassName = this.GetNullTextClassName(); 8154 var editorMainElement = this.editor.GetMainElement(); 8155 if(active) 8156 ASPx.AddClassNameToElement(editorMainElement, nullTextClassName); 8157 else 8158 ASPx.RemoveClassNameFromElement(editorMainElement, nullTextClassName); 8159 }, 8160 GetNullTextClassName: function() { 8161 if (!this.nullTextClassName) 8162 this.InitializeNullTextClassName(); 8163 return this.nullTextClassName; 8164 }, 8165 InitializeNullTextClassName: function() { 8166 var nullTextStyle = this.styles["N"]; 8167 if (nullTextStyle) { 8168 var nullTextStyleClassNames = nullTextStyle.split(" "); 8169 for (var i = 0; i < nullTextStyleClassNames.length; i++) 8170 if (nullTextStyleClassNames[i].match("dxeNullText")) 8171 this.nullTextClassName = nullTextStyleClassNames[i]; 8172 } 8173 } 8174}); 8175var TouchUIHelper = { 8176 isGesture: false, 8177 isMouseEventFromScrolling: false, 8178 isNativeScrollingAllowed: true, 8179 clickSensetivity: 10, 8180 documentTouchHandlers: {}, 8181 documentEventAttachingAllowed: true, 8182 msTouchDraggableClassName: "dxMSTouchDraggable", 8183 touchMouseDownEventName: ASPx.Browser.WebKitTouchUI ? "touchstart" : (ASPx.Browser.Edge && ASPx.Browser.MSTouchUI && window.PointerEvent ? "pointerdown" : "mousedown"), 8184 touchMouseUpEventName: ASPx.Browser.WebKitTouchUI ? "touchend" : (ASPx.Browser.Edge && ASPx.Browser.MSTouchUI && window.PointerEvent ? "pointerup" : "mouseup"), 8185 touchMouseMoveEventName: ASPx.Browser.WebKitTouchUI ? "touchmove" : (ASPx.Browser.Edge && ASPx.Browser.MSTouchUI && window.PointerEvent ? "pointermove" : "mousemove"), 8186 isTouchEvent: function(evt) { 8187 if(!evt) return false; 8188 return ASPx.Browser.WebKitTouchUI && ASPx.IsExists(evt.changedTouches); 8189 }, 8190 isTouchEventName: function(eventName) { 8191 return ASPx.Browser.WebKitTouchUI && (eventName.indexOf("touch") > -1 || eventName.indexOf("gesture") > -1); 8192 }, 8193 getEventX: function(evt) { 8194 if(ASPx.Browser.IE) 8195 return evt.pageX; 8196 var touchPoint = null; 8197 if(evt.changedTouches.length > 0) 8198 touchPoint = evt.changedTouches; 8199 else if(evt.targetTouches.length > 0) 8200 touchPoint = evt.targetTouches; 8201 return touchPoint ? touchPoint[0].pageX : 0; 8202 }, 8203 getEventY: function(evt) { 8204 if(ASPx.Browser.IE) 8205 return evt.pageY; 8206 var touchPoint = null; 8207 if(evt.changedTouches.length > 0) 8208 touchPoint = evt.changedTouches; 8209 else if(evt.targetTouches.length > 0) 8210 touchPoint = evt.targetTouches; 8211 return touchPoint ? touchPoint[0].pageY : 0; 8212 }, 8213 getWebkitMajorVersion: function(){ 8214 if(!this.webkitMajorVersion){ 8215 var regExp = new RegExp("applewebkit/(\\d+)", "i"); 8216 var matches = regExp.exec(ASPx.Browser.UserAgent); 8217 if(matches && matches.index >= 1) 8218 this.webkitMajorVersion = matches[1]; 8219 } 8220 return this.webkitMajorVersion; 8221 }, 8222 getIsLandscapeOrientation: function(){ 8223 if(ASPx.Browser.MacOSMobilePlatform || ASPx.Browser.AndroidMobilePlatform) 8224 return Math.abs(window.orientation) == 90; 8225 return ASPx.GetDocumentClientWidth() > ASPx.GetDocumentClientHeight(); 8226 }, 8227 nativeScrollingSupported: function() { 8228 var allowedSafariVersion = ASPx.Browser.Version >= 5.1 && ASPx.Browser.Version < 8; 8229 var webkitMajorVersion = this.getWebkitMajorVersion(); 8230 var allowedWebKitVersion = webkitMajorVersion > 533 && webkitMajorVersion < 600; 8231 return (ASPx.Browser.MacOSMobilePlatform && (allowedSafariVersion || allowedWebKitVersion)) 8232 || (ASPx.Browser.AndroidMobilePlatform && ASPx.Browser.PlaformMajorVersion >= 3) || (ASPx.Browser.MSTouchUI && (!ASPx.Browser.WindowsPhonePlatform || !ASPx.Browser.IE)); 8233 }, 8234 makeScrollableIfRequired: function(element, options) { 8235 if(ASPx.Browser.WebKitTouchUI && element) { 8236 var overflow = ASPx.GetCurrentStyle(element).overflow; 8237 if(element.tagName == "DIV" && overflow != "hidden" && overflow != "visible" ){ 8238 return this.MakeScrollable(element); 8239 } 8240 } 8241 }, 8242 preventScrollOnEvent: function(evt){ 8243 }, 8244 handleFastTapIfRequired: function(evt, action, preventCommonClickEvents) { 8245 if(ASPx.Browser.WebKitTouchUI && evt.type == 'touchstart' && action) { 8246 this.FastTapHelper.HandleFastTap(evt, action, preventCommonClickEvents); 8247 return true; 8248 } 8249 return false; 8250 }, 8251 ensureDocumentSizesCorrect: function (){ 8252 return (document.documentElement.clientWidth - document.documentElement.clientHeight) / (screen.width - screen.height) > 0;
8253 }, 8254 ensureOrientationChanged: function(onOrientationChangedFunction){ 8255 if(ASPxClientUtils.iOSPlatform || this.ensureDocumentSizesCorrect()) 8256 onOrientationChangedFunction(); 8257 else { 8258 window.setTimeout(function(){ 8259 this.ensureOrientationChanged(onOrientationChangedFunction); 8260 }.aspxBind(this), 100); 8261 } 8262 }, 8263 onEventAttachingToDocument: function(eventName, func){ 8264 if(ASPx.Browser.MacOSMobilePlatform && this.isTouchEventName(eventName)) { 8265 if(!this.documentTouchHandlers[eventName]) 8266 this.documentTouchHandlers[eventName] = []; 8267 this.documentTouchHandlers[eventName].push(func); 8268 return this.documentEventAttachingAllowed; 8269 } 8270 return true; 8271 }, 8272 onEventDettachedFromDocument: function(eventName, func){ 8273 if(ASPx.Browser.MacOSMobilePlatform && this.isTouchEventName(eventName)) { 8274 var handlers = this.documentTouchHandlers[eventName]; 8275 if(handlers) 8276 ASPx.Data.ArrayRemove(handlers, func); 8277 } 8278 }, 8279 processDocumentTouchEventHandlers: function(proc) { 8280 var touchEventNames = ["touchstart", "touchend", "touchmove", "gesturestart", "gestureend"]; 8281 for(var i = 0; i < touchEventNames.length; i++) { 8282 var eventName = touchEventNames[i]; 8283 var handlers = this.documentTouchHandlers[eventName]; 8284 if(handlers) { 8285 for(var j = 0; j < handlers.length; j++) { 8286 proc(eventName,handlers[j]); 8287 } 8288 } 8289 } 8290 }, 8291 removeDocumentTouchEventHandlers: function() { 8292 if(ASPx.Browser.MacOSMobilePlatform) { 8293 this.documentEventAttachingAllowed = false; 8294 this.processDocumentTouchEventHandlers(ASPx.Evt.DetachEventFromDocumentCore); 8295 } 8296 }, 8297 restoreDocumentTouchEventHandlers: function () { 8298 if(ASPx.Browser.MacOSMobilePlatform) { 8299 this.documentEventAttachingAllowed = true; 8300 this.processDocumentTouchEventHandlers(ASPx.Evt.AttachEventToDocumentCore); 8301 } 8302 }, 8303 IsNativeScrolling: function() { 8304 return TouchUIHelper.nativeScrollingSupported() && TouchUIHelper.isNativeScrollingAllowed; 8305 }, 8306 pointerEnabled: !!(window.PointerEvent || window.MSPointerEvent), 8307 pointerDownEventName: window.PointerEvent ? "pointerdown" : "MSPointerDown", 8308 pointerUpEventName: window.PointerEvent ? "pointerup" : "MSPointerUp", 8309 pointerCancelEventName: window.PointerEvent ? "pointercancel" : "MSPointerCancel", 8310 pointerMoveEventName: window.PointerEvent ? "pointermove" : "MSPointerMove", 8311 pointerOverEventName: window.PointerEvent ? "pointerover" : "MSPointerOver", 8312 pointerOutEventName: window.PointerEvent ? "pointerout" : "MSPointerOut", 8313 pointerType: { 8314 Touch: (ASPx.Browser.IE && ASPx.Browser.Version == 10) ? 2 : "touch", 8315 Pen: (ASPx.Browser.IE && ASPx.Browser.Version == 10) ? 3 : "pen", 8316 Mouse: (ASPx.Browser.IE && ASPx.Browser.Version == 10) ? 4 : "mouse" 8317 }, 8318 msGestureEnabled: !!(window.PointerEvent || window.MSPointerEvent) && typeof(MSGesture) != "undefined", 8319 msTouchCreateGesturesWrapper: function(element, onTap){ 8320 if(!TouchUIHelper.msGestureEnabled) 8321 return; 8322 var gesture = new MSGesture(); 8323 gesture.target = element; 8324 ASPx.Evt.AttachEventToElement(element, TouchUIHelper.pointerDownEventName, function(evt){ 8325 gesture.addPointer(evt.pointerId); 8326 }); 8327 ASPx.Evt.AttachEventToElement(element, TouchUIHelper.pointerUpEventName, function(evt){ 8328 gesture.stop(); 8329 }); 8330 if(onTap) 8331 ASPx.Evt.AttachEventToElement(element, "MSGestureTap", onTap); 8332 return gesture; 8333 }, 8334 useLongTapHelper: function () { 8335 return ASPx.Browser.Safari && ASPx.Browser.TouchUI; 8336 }, 8337 attachLongTapHandler: function(element, handler, onlyBubbling) { 8338 var timerID = -1; 8339 var timeout = 1000; 8340 var event = null; 8341 var preventClickEvent = false; 8342 var startX = -1; 8343 var startY = -1; 8344 var pixelLimit = 5; 8345 function onTouchMouseDown(evt) { 8346 abortWating(); 8347 event = evt; 8348 startX = evt.pageX; 8349 startY = evt.pageY; 8350 preventClickEvent = false; 8351 timerID = window.setTimeout(onTimeout, timeout); 8352 } 8353 function onTouchMouseMove(evt) { 8354 if (!isUnderTouch()) 8355 return; 8356 var shiftX = Math.abs(startX - evt.pageX), 8357 shiftY = Math.abs(startY - evt.pageY), 8358 maxShift = Math.max(shiftX, shiftY); 8359 if (maxShift > pixelLimit) 8360 abortWating(); 8361 } 8362 function onTouchMouseUp(evt) { 8363 abortWating(); 8364 if (preventClickEvent) { 8365 ASPx.Evt.PreventEventAndBubble(evt); 8366 preventClickEvent = false; 8367 } 8368 } 8369 function onTimeout() { 8370 handler(event); 8371 preventClickEvent = true; 8372 abortWatingInternal(); 8373 } 8374 function isUnderTouch() { 8375 return timerID !== -1; 8376 } 8377 function abortWating() { 8378 if (isUnderTouch()) { 8379 window.clearTimeout(timerID); 8380 abortWatingInternal(); 8381 } 8382 } 8383 function abortWatingInternal() { 8384 timerID = -1; 8385 event = null; 8386 } 8387 ASPx.Evt.AttachEventToElement(element, TouchUIHelper.touchMouseDownEventName, onTouchMouseDown, onlyBubbling); 8388 ASPx.Evt.AttachEventToElement(element, TouchUIHelper.touchMouseMoveEventName, onTouchMouseMove, onlyBubbling); 8389 ASPx.Evt.AttachEventToElement(element, TouchUIHelper.touchMouseUpEventName, onTouchMouseUp, onlyBubbling); 8390 element.style["-webkit-user-select"] = "none"; 8391 return function () { 8392 ASPx.Evt.DetachEventFromElement(element, TouchUIHelper.touchMouseDownEventName, onTouchMouseDown);
8393 ASPx.Evt.DetachEventFromElement(element, TouchUIHelper.touchMouseMoveEventName, onTouchMouseMove); 8394 ASPx.Evt.DetachEventFromElement(element, TouchUIHelper.touchMouseUpEventName, onTouchMouseUp); 8395 element.style["-webkit-user-select"] = ""; 8396 }; 8397 } 8398}; 8399var CacheHelper = {}; 8400CacheHelper.GetCachedValueCore = function(obj, key, func, cacheObj, fillValueMethod) { 8401 if(!cacheObj) 8402 cacheObj = obj; 8403 if(!cacheObj.cache) 8404 cacheObj.cache = {}; 8405 if(!key) 8406 key = "default"; 8407 fillValueMethod(obj, key, func, cacheObj); 8408 return cacheObj.cache[key]; 8409}; 8410CacheHelper.GetCachedValue = function(obj, key, func, cacheObj) { 8411 return CacheHelper.GetCachedValueCore(obj, key, func, cacheObj, 8412 function(obj, key, func, cacheObj) { 8413 if(!ASPx.IsExists(cacheObj.cache[key])) 8414 cacheObj.cache[key] = func.apply(obj, []); 8415 }); 8416}; 8417CacheHelper.GetCachedElement = function(obj, key, func, cacheObj) { 8418 return CacheHelper.GetCachedValueCore(obj, key, func, cacheObj, 8419 function(obj, key, func, cacheObj) { 8420 if(!ASPx.IsValidElement(cacheObj.cache[key])) 8421 cacheObj.cache[key] = func.apply(obj, []); 8422 }); 8423}; 8424CacheHelper.GetCachedElements = function(obj, key, func, cacheObj) { 8425 return CacheHelper.GetCachedValueCore(obj, key, func, cacheObj, 8426 function(obj, key, func, cacheObj) { 8427 if(!ASPx.IsValidElements(cacheObj.cache[key])){ 8428 var elements = func.apply(obj, []); 8429 if(!Ident.IsArray(elements)) 8430 elements = [elements]; 8431 cacheObj.cache[key] = elements; 8432 } 8433 }); 8434}; 8435CacheHelper.GetCachedElementById = function(obj, id, cacheObj) { 8436 return CacheHelper.GetCachedElement(obj, id, function() { return ASPx.GetElementById(id); }, cacheObj); 8437}; 8438CacheHelper.GetCachedChildById = function(obj, parent, id, cacheObj) { 8439 return CacheHelper.GetCachedElement(obj, id, function() { return ASPx.GetChildById(parent, id); }, cacheObj); 8440}; 8441CacheHelper.DropCachedValue = function(cacheObj, key) { 8442 cacheObj.cache[key] = null; 8443}; 8444CacheHelper.DropCache = function(cacheObj) { 8445 cacheObj.cache = null; 8446}; 8447var DomObserver = ASPx.CreateClass(null, { 8448 constructor: function() { 8449 this.items = { }; 8450 }, 8451 subscribe: function(elementID, callbackFunc) { 8452 var item = this.items[elementID]; 8453 if(item) 8454 this.unsubscribe(elementID); 8455 item = { 8456 elementID: elementID, 8457 callbackFunc: callbackFunc, 8458 pauseCount: 0 8459 }; 8460 this.prepareItem(item); 8461 this.items[elementID] = item; 8462 }, 8463 prepareItem: function(item) { 8464 }, 8465 unsubscribe: function(elementID) { 8466 this.items[elementID] = null; 8467 }, 8468 getItemElement: function(item) { 8469 var element = this.getElementById(item.elementID); 8470 if(element) 8471 return element; 8472 this.unsubscribe(item.elementID); 8473 return null; 8474 }, 8475 getElementById: function(elementID) { 8476 var element = document.getElementById(elementID); 8477 return element && ASPx.IsValidElement(element) ? element : null; 8478 }, 8479 pause: function(element, includeSubtree) { 8480 this.changeItemsState(element, includeSubtree, true); 8481 }, 8482 resume: function(element, includeSubtree) { 8483 this.changeItemsState(element, includeSubtree, false); 8484 }, 8485 forEachItem: function(processFunc, context) { 8486 context = context || this; 8487 for(var itemName in this.items) { 8488 if(!this.items.hasOwnProperty(itemName)) 8489 continue; 8490 var item = this.items[itemName]; 8491 if(item) { 8492 var needBreak = processFunc.call(context, item); 8493 if(needBreak) 8494 return; 8495 } 8496 } 8497 }, 8498 changeItemsState: function(element, includeSubtree, pause) { 8499 this.forEachItem(function(item) { 8500 if(!element) 8501 this.changeItemState(item, pause); 8502 else { 8503 var itemElement = this.getItemElement(item); 8504 if(itemElement && (element == itemElement || (includeSubtree && ASPx.GetIsParent(element, itemElement)))) { 8505 this.changeItemState(item, pause); 8506 if(!includeSubtree) 8507 return true; 8508 } 8509 } 8510 }.aspxBind(this)); 8511 }, 8512 changeItemState: function(item, pause) { 8513 if(pause) 8514 this.pauseItem(item); 8515 else 8516 this.resumeItem(item); 8517 }, 8518 pauseItem: function(item) { 8519 item.paused = true; 8520 item.pauseCount++; 8521 }, 8522 resumeItem: function(item) { 8523 if(item.pauseCount > 0) { 8524 if(item.pauseCount == 1) 8525 item.paused = false; 8526 item.pauseCount--; 8527 } 8528 } 8529}); 8530DomObserver.IsMutationObserverAvailable = function() { 8531 return !!window.MutationObserver; 8532}; 8533var TimerObserver = ASPx.CreateClass(DomObserver, { 8534 constructor: function() { 8535 this.constructor.prototype.constructor.call(this); 8536 this.timerID = -1; 8537 this.observationTimeout = 300; 8538 }, 8539 subscribe: function(elementID, callbackFunc) { 8540 DomObserver.prototype.subscribe.call(this, elementID, callbackFunc); 8541 if(!this.isActivated()) 8542 this.startObserving(); 8543 }, 8544 isActivated: function() { 8545 return this.timerID !== -1; 8546 }, 8547 startObserving: function() { 8548 if(this.isActivated()) 8549 window.clearTimeout(this.timerID); 8550 this.timerID = window.setTimeout(this.onTimeout, this.observationTimeout); 8551 }, 8552 onTimeout: function() { 8553 var observer = _aspxGetDomObserver(); 8554 observer.doObserve(); 8555 observer.startObserving(); 8556 }, 8557 doObserve: function() { 8558 if(!ASPx.documentLoaded) return; 8559 this.forEachItem(function(item) { 8560 if(!item.paused) 8561 this.doObserveForItem(item); 8562 }.aspxBind(this)); 8563 }, 8564 doObserveForItem: function(item) { 8565 var element = this.getItemElement(item); 8566 if(element) 8567 item.callbackFunc.call(this, element); 8568 } 8569}); 8570var MutationObserver = ASPx.CreateClass(DomObserver, { 8571 constructor: function() { 8572 this.constructor.prototype.constructor.call(this); 8573 this.callbackTimeout = 10; 8574 }, 8575 prepareItem: function(item) { 8576 item.callbackTimerID = -1; 8577 var target = this.getElementById(item.elementID); 8578 if(!target) 8579 return; 8580 var observerCallbackFunc = function() { 8581 if(item.callbackTimerID === -1) { 8582 var timeoutHander = function() { 8583 item.callbackTimerID = -1; 8584 item.callbackFunc.call(this, target); 8585 }.aspxBind(this); 8586 item.callbackTimerID = window.setTimeout(timeoutHander, this.callbackTimeout); 8587 } 8588 }.aspxBind(this); 8589 var observer = new window.MutationObserver(observerCallbackFunc); 8590 var config = { attributes: true, childList: true, characterData: true, subtree: true }; 8591 observer.observe(target, config); 8592 item.observer = observer; 8593 item.config = config; 8594 }, 8595 unsubscribe: function(elementID) { 8596 var item = this.items[elementID]; 8597 if(item) { 8598 item.observer.disconnect(); 8599 item.observer = null; 8600 } 8601 DomObserver.prototype.unsubscribe.call(this, elementID); 8602 }, 8603 pauseItem: function(item) { 8604 DomObserver.prototype.pauseItem.call(this, item); 8605 item.observer.disconnect(); 8606 }, 8607 resumeItem: function(item) { 8608 DomObserver.prototype.resumeItem.call(this, item); 8609 if(!item.paused) { 8610 var target = this.getItemElement(item); 8611 if(target) 8612 item.observer.observe(target, item.config); 8613 } 8614 } 8615}); 8616var domObserver = null; 8617function _aspxGetDomObserver() { 8618 if(domObserver == null) 8619 domObserver = DomObserver.IsMutationObserverAvailable() ? new MutationObserver() : new TimerObserver(); 8620 return domObserver; 8621} 8622var ControlUpdateWatcher = ASPx.CreateClass(null, { 8623 constructor: function() { 8624 this.helpers = { }; 8625 this.clearLockerTimerID = -1; 8626 this.clearLockerTimerDelay = 15; 8627 this.postProcessing = false; 8628 this.init(); 8629 }, 8630 init: function() { 8631 var postHandler = aspxGetPostHandler(); 8632 postHandler.Post.AddHandler(this.OnPost, this); 8633 }, 8634 Add: function(helper) { 8635 this.helpers[helper.GetName()] = helper; 8636 },
8637 CanSendCallback: function(dxCallbackOwner, arg) { 8638 this.LockConfirmOnBeforeWindowUnload(); 8639 var modifiedHelpers = this.FilterModifiedHelpersByDXCallbackOwner(this.GetModifiedHelpers(), dxCallbackOwner, arg); 8640 if(modifiedHelpers.length === 0) return true; 8641 var modifiedHelpersInfo = this.GetToConfirmAndToResetLists(modifiedHelpers, dxCallbackOwner.name); 8642 if(!modifiedHelpersInfo) return true; 8643 if(modifiedHelpersInfo.toConfirm.length === 0) { 8644 this.ResetClientChanges(modifiedHelpersInfo.toReset); 8645 return true; 8646 } 8647 var helper = modifiedHelpersInfo.toConfirm[0]; 8648 if(!confirm(helper.GetConfirmUpdateText())) 8649 return false; 8650 this.ResetClientChanges(modifiedHelpersInfo.toReset); 8651 return true; 8652 }, 8653 OnPost: function(s, e) { 8654 if(this.isDxCallback(e)) 8655 return; 8656 this.postProcessing = true; 8657 this.LockConfirmOnBeforeWindowUnload(); 8658 var modifiedHelpersInfo = this.GetModifedHelpersInfo(e); 8659 if(!modifiedHelpersInfo) 8660 return; 8661 if(modifiedHelpersInfo.toConfirm.length === 0) { 8662 this.ResetClientChanges(modifiedHelpersInfo.toReset); 8663 return; 8664 } 8665 var helper = modifiedHelpersInfo.toConfirm[0]; 8666 if(!confirm(helper.GetConfirmUpdateText())) { 8667 e.cancel = true; 8668 this.finishPostProcessing(); 8669 } 8670 if(!e.cancel) 8671 this.ResetClientChanges(modifiedHelpersInfo.toReset); 8672 }, 8673 isDxCallback: function(e) { 8674 return e.isDXCallback || this.isInternalUploadControlCallback(); 8675 }, 8676 isInternalUploadControlCallback: function() { 8677 var isInCallback = false; 8678 for(var key in this.helpers) { 8679 if(this.helpers.hasOwnProperty(key)) { 8680 var helper = this.helpers[key]; 8681 isInCallback = isInCallback || helper.isInUploadCallback(); 8682 } 8683 } 8684 return isInCallback; 8685 }, 8686 finishPostProcessing: function() { 8687 this.postProcessing = false; 8688 }, 8689 GetModifedHelpersInfo: function(e) { 8690 var modifiedHelpers = this.FilterModifiedHelpers(this.GetModifiedHelpers(), e); 8691 if(modifiedHelpers.length === 0) return; 8692 return this.GetToConfirmAndToResetLists(modifiedHelpers, e && e.ownerID); 8693 }, 8694 GetToConfirmAndToResetLists: function(modifiedHelpers, ownerID) { 8695 var resetList = [ ]; 8696 var confirmList = [ ]; 8697 for(var i = 0; i < modifiedHelpers.length; i++) { 8698 var helper = modifiedHelpers[i]; 8699 if(!helper.GetConfirmUpdateText()) { 8700 resetList.push(helper); 8701 continue; 8702 } 8703 if(helper.CanShowConfirm(ownerID)) { 8704 resetList.push(helper); 8705 confirmList.push(helper); 8706 } 8707 } 8708 return { toConfirm: confirmList, toReset: resetList }; 8709 }, 8710 FilterModifiedHelpers: function(modifiedHelpers, e) { 8711 if(modifiedHelpers.length === 0) 8712 return [ ]; 8713 if(this.RequireProcessUpdatePanelCallback(e)) 8714 return this.FilterModifiedHelpersByUpdatePanels(modifiedHelpers); 8715 if(this.postProcessing) 8716 return this.FilterModifiedHelpersByPostback(modifiedHelpers); 8717 return modifiedHelpers; 8718 }, 8719 FilterModifiedHelpersByDXCallbackOwner: function(modifiedHelpers, dxCallbackOwner, arg) { 8720 var result = [ ]; 8721 for(var i = 0; i < modifiedHelpers.length; i++) { 8722 var helper = modifiedHelpers[i]; 8723 if(helper.NeedConfirmOnCallback(dxCallbackOwner, arg)) 8724 result.push(helper); 8725 } 8726 return result; 8727 }, 8728 FilterModifiedHelpersByUpdatePanels: function(modifiedHelpers) { 8729 var result = [ ]; 8730 var updatePanels = this.GetUpdatePanelsWaitedForUpdate(); 8731 for(var i = 0; i < updatePanels.length; i++) { 8732 var panelID = updatePanels[i].replace(/\$/g, "_"); 8733 var panel = ASPx.GetElementById(panelID); 8734 if(!panel) continue; 8735 for(var j = 0; j < modifiedHelpers.length; j++) { 8736 var helper = modifiedHelpers[j]; 8737 if(ASPx.GetIsParent(panel, helper.GetControlMainElement())) 8738 result.push(helper); 8739 } 8740 } 8741 return result; 8742 }, 8743 FilterModifiedHelpersByPostback: function(modifiedHelpers) { 8744 var result = [ ]; 8745 for(var i = 0; i < modifiedHelpers.length; i++) { 8746 var helper = modifiedHelpers[i]; 8747 if(helper.NeedConfirmOnPostback()) 8748 result.push(helper); 8749 } 8750 return result; 8751 }, 8752 RequireProcessUpdatePanelCallback: function(e) { 8753 var rManager = this.GetMSRequestManager(); 8754 if(rManager && e && e.isMSAjaxCallback) 8755 return rManager._postBackSettings.async; 8756 return false; 8757 }, 8758 GetUpdatePanelsWaitedForUpdate: function() { 8759 var rManager = this.GetMSRequestManager(); 8760 if(!rManager) return [ ];
8761 var panelUniqueIDs = rManager._postBackSettings.panelsToUpdate || [ ]; 8762 var panelClientIDs = [ ]; 8763 for(var i = 0; i < panelUniqueIDs.length; i++) { 8764 var index = ASPx.Data.ArrayIndexOf(rManager._updatePanelIDs, panelUniqueIDs[i]); 8765 if(index >= 0) 8766 panelClientIDs.push(rManager._updatePanelClientIDs[index]); 8767 } 8768 return panelClientIDs; 8769 }, 8770 GetMSRequestManager: function() { 8771 return ASPx.GetMSAjaxRequestManager(); 8772 }, 8773 GetModifiedHelpers: function() { 8774 var result = [ ]; 8775 for(var key in this.helpers) { 8776 if(this.helpers.hasOwnProperty(key)) { 8777 var helper = this.helpers[key]; 8778 if(helper.HasChanges()) 8779 result.push(helper); 8780 } 8781 } 8782 return result; 8783 }, 8784 ResetClientChanges: function(modifiedHelpers) { 8785 for(var i = 0; i < modifiedHelpers.length; i++) 8786 modifiedHelpers[i].ResetClientChanges(); 8787 }, 8788 GetConfirmUpdateMessage: function() { 8789 if(this.confirmOnWindowUnloadLocked) return; 8790 var modifiedHelpersInfo = this.GetModifedHelpersInfo(); 8791 if(!modifiedHelpersInfo || modifiedHelpersInfo.toConfirm.length === 0) 8792 return; 8793 var helper = modifiedHelpersInfo.toConfirm[0]; 8794 return helper.GetConfirmUpdateText(); 8795 }, 8796 LockConfirmOnBeforeWindowUnload: function() { 8797 this.confirmOnWindowUnloadLocked = true; 8798 this.clearLockerTimerID = ASPx.Timer.ClearTimer(this.clearLockerTimerID); 8799 this.clearLockerTimerID = window.setTimeout(function() { 8800 this.confirmOnWindowUnloadLocked = false; 8801 }.aspxBind(this), this.clearLockerTimerDelay); 8802 }, 8803 OnWindowBeforeUnload: function(e) { 8804 var confirmMessage = this.GetConfirmUpdateMessage(); 8805 if(confirmMessage) 8806 e.returnValue = confirmMessage; 8807 this.finishPostProcessing(); 8808 return confirmMessage; 8809 }, 8810 OnWindowUnload: function(e) { 8811 if(this.confirmOnWindowUnloadLocked) return; 8812 var modifiedHelpersInfo = this.GetModifedHelpersInfo(); 8813 if(!modifiedHelpersInfo) return; 8814 this.ResetClientChanges(modifiedHelpersInfo.toReset); 8815 }, 8816 OnMouseDown: function(e) { 8817 if(ASPx.Browser.IE) 8818 this.PreventBeforeUnloadOnLinkClick(e); 8819 }, 8820 OnFocusIn: function(e) { 8821 if(ASPx.Browser.IE) 8822 this.PreventBeforeUnloadOnLinkClick(e); 8823 }, 8824 PreventBeforeUnloadOnLinkClick: function(e) { 8825 if(ASPx.GetObjectKeys(this.helpers).length == 0) 8826 return; 8827 var link = ASPx.GetParentByTagName(ASPx.Evt.GetEventSource(e), "A"); 8828 if(!link || link.dxgvLinkClickHanlderAssigned) 8829 return; 8830 var url = ASPx.Attr.GetAttribute(link, "href"); 8831 if(!url || url.indexOf("javascript:") < 0) 8832 return; 8833 ASPx.Evt.AttachEventToElement(link, "click", function(ev) { return ASPx.Evt.PreventEvent(ev); }); 8834 link.dxgvLinkClickHanlderAssigned = true; 8835 } 8836}); 8837ControlUpdateWatcher.Instance = null; 8838ControlUpdateWatcher.getInstance = function () { 8839 if (!ControlUpdateWatcher.Instance) { 8840 ControlUpdateWatcher.Instance = new ControlUpdateWatcher(); 8841 ASPx.Evt.AttachEventToElement(window, "beforeunload", function(e) { 8842 return ControlUpdateWatcher.Instance.OnWindowBeforeUnload(e); 8843 }); 8844 ASPx.Evt.AttachEventToElement(window, "unload", function(e) { 8845 ControlUpdateWatcher.Instance.OnWindowUnload(e); 8846 }); 8847 ASPx.Evt.AttachEventToDocument("mousedown", function(e) { 8848 ControlUpdateWatcher.Instance.OnMouseDown(e); 8849 }); 8850 ASPx.Evt.AttachEventToDocument("focusin", function(e) { 8851 ControlUpdateWatcher.Instance.OnFocusIn(e); 8852 }); 8853 } 8854 return ControlUpdateWatcher.Instance; 8855}; 8856var UpdateWatcherHelper = ASPx.CreateClass(null, { 8857 constructor: function(owner) { 8858 this.owner = owner; 8859 this.ownerWatcher = ControlUpdateWatcher.getInstance(); 8860 this.ownerWatcher.Add(this); 8861 }, 8862 GetName: function() { 8863 return this.owner.name; 8864 }, 8865 GetControlMainElement: function() { 8866 return this.owner.GetMainElement(); 8867 }, 8868 GetControlParentForm: function(){ 8869 return ASPx.GetParentByTagName(this.GetControlMainElement(), "FORM"); 8870 }, 8871 CanShowConfirm: function(requestOwnerID) { 8872 return true; 8873 }, 8874 HasChanges: function() { 8875 return false; 8876 }, 8877 GetConfirmUpdateText: function() { 8878 return ""; 8879 }, 8880 NeedConfirmOnCallback: function(dxCallbackOwner) { 8881 return true; 8882 }, 8883 NeedConfirmOnPostback: function() { 8884 if(ASPx.IsUploadSubmitRequest) 8885 return !ASPx.IsUploadSubmitRequest(this.GetControlParentForm(
8885)); 8886 return true; 8887 }, 8888 ResetClientChanges: function() { 8889 }, 8890 ConfirmOnCustomControlEvent: function() { 8891 var confirmMessage = this.GetConfirmUpdateText(); 8892 if(confirmMessage) 8893 return confirm(confirmMessage); 8894 return false; 8895 }, 8896 isInUploadCallback: function() { 8897 return false; 8898 } 8899}); 8900var ControlTabIndexManager = ASPx.CreateClass(null, { 8901 constructor: function() { 8902 this.elementsWithChangedTabIndex = {}; 8903 }, 8904 getChangedElementsForControlId: function(id) { 8905 if(!this.elementsWithChangedTabIndex[id]) 8906 this.elementsWithChangedTabIndex[id] = []; 8907 return this.elementsWithChangedTabIndex[id]; 8908 }, 8909 isElementWithChangedIndex: function(element) { 8910 for(var key in this.elementsWithChangedTabIndex) 8911 if(this.elementsWithChangedTabIndex.hasOwnProperty(key)) 8912 if(this.elementsWithChangedTabIndex[key].indexOf(element) !== -1) 8913 return true; 8914 return false; 8915 }, 8916 changeTabIndexAttribute: function(element, id) { 8917 var elements = this.getChangedElementsForControlId(id); 8918 ASPx.Attr.ChangeTabIndexAttribute(element); 8919 if(elements.indexOf(element) === -1) 8920 elements.push(element); 8921 }, 8922 restoreTabIndexAttribute: function(element, id) { 8923 var elements = this.getChangedElementsForControlId(id), 8924 index = elements.indexOf(element); 8925 if(index !== -1) { 8926 elements.splice(index, 1); 8927 if(!this.isElementWithChangedIndex(element)) 8928 ASPx.Attr.RestoreTabIndexAttribute(element); 8929 } 8930 } 8931}); 8932ControlTabIndexManager.Instance = null; 8933ControlTabIndexManager.getInstance = function() { 8934 if(!ControlTabIndexManager.Instance) 8935 ControlTabIndexManager.Instance = new ControlTabIndexManager(); 8936 return ControlTabIndexManager.Instance; 8937}; 8938var ControlCallbackHandlersQueue = ASPx.CreateClass(null, { 8939 constructor: function (owner) { 8940 this.owner = owner; 8941 this.handlerInfos = []; 8942 }, 8943 addCallbackHandler: function(handlerInfo) { 8944 this.handlerInfos.push(handlerInfo); 8945 }, 8946 executeCallbacksHandlers: function() { 8947 for(var i = 0, handlerInfo; handlerInfo = this.handlerInfos[i]; i++) 8948 handlerInfo.handler.call(this.owner, handlerInfo.result); 8949 this.handlerInfos = []; 8950 } 8951}); 8952var ControlCallbackQueueHelper = ASPx.CreateClass(null, { 8953 constructor: function (owner) { 8954 this.owner = owner; 8955 this.pendingCallbacks = []; 8956 this.receivedCallbacks = []; 8957 this.attachEvents(); 8958 }, 8959 showLoadingElements: function () { 8960 this.owner.ShowLoadingDiv(); 8961 if (this.owner.IsCallbackAnimationEnabled())
8962 this.owner.StartBeginCallbackAnimation(); 8963 else 8964 this.owner.ShowLoadingElementsInternal(); 8965 }, 8966 attachEvents: function () { 8967 this.owner.EndCallback.AddHandler(this.onEndCallback.aspxBind(this)); 8968 this.owner.CallbackError.AddHandler(this.onCallbackError.aspxBind(this)); 8969 }, 8970 detachEvents: function () { 8971 this.owner.EndCallback.RemoveHandler(this.onEndCallback); 8972 this.owner.CallbackError.RemoveHandler(this.onCallbackError); 8973 }, 8974 onCallbackError: function (owner, result) { 8975 this.sendErrorToChildControl(result); 8976 }, 8977 ignoreDuplicates: function () { 8978 return true; 8979 }, 8980 hasDuplicate: function (arg) { 8981 for (var i in this.pendingCallbacks) { 8982 if (this.pendingCallbacks[i].arg == arg && this.pendingCallbacks[i].state != ASPx.callbackState.aborted) 8983 return true; 8984 } 8985 return false; 8986 }, 8987 getToken: function (halperContext, callbackInfo) { 8988 return { 8989 cancel: function () { 8990 if (callbackInfo.state == ASPx.callbackState.sent) { 8991 callbackInfo.state = ASPx.callbackState.aborted; 8992 halperContext.sendNext(); 8993 } 8994 if (callbackInfo.state == ASPx.callbackState.inTurn) 8995 ASPx.Data.ArrayRemove(halperContext.pendingCallbacks, callbackInfo); 8996 }, 8997 callbackId: -1 8998 }; 8999 }, 9000 sendCallback: function (arg, handlerContext, handler, commandName, onBeforeSend) { 9001 if (this.ignoreDuplicates() && this.hasDuplicate(arg)) 9002 return false; 9003 var handlerContext = handlerContext || this.owner; 9004 var callbackInfo = { 9005 arg: arg, 9006 handlerContext: handlerContext, 9007 handler: handler || handlerContext.OnCallback, 9008 state: ASPx.callbackState.inTurn, 9009 callbackId: -1, 9010 onBeforeSend: onBeforeSend 9011 }; 9012 this.pendingCallbacks.push(callbackInfo); 9013 if (!this.hasActiveCallback()) { 9014 this.createCallbackByCallbackInfo(callbackInfo, commandName); 9015 } 9016 return this.getToken(this, callbackInfo); 9017 }, 9018 hasActiveCallback: function () { 9019 return this.getCallbacksInfoByState(ASPx.callbackState.sent).length > 0; 9020 }, 9021 sendNext: function () { 9022 var nextCallbackInfo = this.getCallbacksInfoByState(ASPx.callbackState.inTurn)[0]; 9023 if (nextCallbackInfo) { 9024 this.createCallbackByCallbackInfo(nextCallbackInfo); 9025 return nextCallbackInfo.callbackId; 9026 } 9027 }, 9028 createCallbackByCallbackInfo: function(callbackInfo, commandName) { 9029 if(callbackInfo.onBeforeSend) 9030 callbackInfo.onBeforeSend(); 9031 callbackInfo.callbackId = this.owner.CreateCallback(callbackInfo.arg, commandName); 9032 callbackInfo.state = ASPx.callbackState.sent; 9033 }, 9034 onEndCallback: function () { 9035 if (!this.owner.isErrorOnCallback && this.hasPendingCallbacks()) { 9036 var curCallbackId; 9037 var curCallbackInfo; 9038 var handlerContext; 9039 for (var i in this.receivedCallbacks) { 9040 if(this.receivedCallbacks.hasOwnProperty(i)) { 9041 curCallbackId = this.receivedCallbacks[i]; 9042 curCallbackInfo = this.getCallbackInfoById(curCallbackId); 9043 if (curCallbackInfo.state != ASPx.callbackState.aborted) { 9044 handlerContext = curCallbackInfo.handlerContext; 9045 if (handlerContext.OnEndCallback) 9046 handlerContext.OnEndCallback(); 9047 this.sendNext(); 9048 } 9049 ASPx.Data.ArrayRemove(this.pendingCallbacks, curCallbackInfo); 9050 } 9051 } 9052 ASPx.Data.ArrayClear(this.receivedCallbacks); 9053 } 9054 }, 9055 hasPendingCallbacks: function () { 9056 return this.pendingCallbacks && this.pendingCallbacks.length && this.pendingCallbacks.length > 0; 9057 }, 9058 processCallback: function (result, callbackId) { 9059 this.receivedCallbacks.push(callbackId); 9060 if (this.hasPendingCallbacks()) { 9061 var callbackInfo = this.getCallbackInfoById(callbackId); 9062 if (callbackInfo.state != ASPx.callbackState.aborted) 9063 callbackInfo.handler.call(callbackInfo.handlerContext, result); 9064 } 9065 }, 9066 getCallbackInfoById: function (id) { 9067 for (var i in this.pendingCallbacks) { 9068 if (this.pendingCallbacks[i].callbackId == id) 9069 return this.pendingCallbacks[i]; 9070 } 9071 }, 9072 getCallbacksInfoByState: function (state) { 9073 var result = []; 9074 for (var i in this.pendingCallbacks) { 9075 if (this.pendingCallbacks[i].state == state) 9076 result.push(this.pendingCallbacks[i]); 9077 } 9078 return result; 9079 }, 9080 sendErrorToChildControl: function (callbackObj) { 9081 if (!this.hasPendingCallbacks()) 9082 return; 9083 var callbackInfo = this.getCallbackInfoById(callbackObj.callbackId || 0); 9084 if (!callbackInfo) 9085 return; 9086 var hasChildControlHandler = (callbackInfo.handlerContext != this.owner) && callbackInfo.handlerContext.OnCallbackError; 9087 if (hasChildControlHandler) 9088 callbackInfo.handlerContext.OnCallbackError.call(callbackInfo.handlerContext, callbackObj.message, callbackObj.data); 9089 } 9090}); 9091var AccessibilityHelperBase = ASPx.CreateClass(null, { 9092 constructor: function(control) { 9093 this.control = control; 9094 this.timerID = -1; 9095 this.pronounceMessageTimeout = 500; 9096 this.activeItem = this.getItems()[0]; 9097 this.pronounceIsStarted = false; 9098 }, 9099 PronounceMessage: function(text, activeItemArgs, inactiveItemArgs, mainElementArgs, ownerMainElement) { 9100 this.timerID = ASPx.Timer.ClearTimer(this.timerID); 9101 this.pronounceIsStarted = true; 9102 this.timerID = window.setTimeout(function() { 9103 this.PronounceMessageCore(text, activeItemArgs, inactiveItemArgs, mainElementArgs, ownerMainElement); 9104 }.aspxBind(this), this.getPronounceTimeout()); 9105 }, 9106 PronounceMessageCore: function(text, activeItemArgs, inactiveItemArgs, mainElementArgs, ownerMainElement) { 9107 if(!this.getItems()) 9108 return; 9109 this.toogleItem(); 9110 var mainElement = this.getMainElement(); 9111 var activeItem = this.getItem(true); 9112 var inactiveItem = this.getItem(); 9113 if(ASPx.Attr.GetAttribute(mainElement, "role") != "application") 9114 mainElementArgs = this.addArguments(mainElementArgs, { "aria-activedescendant" : activeItem.id }); 9115 var messageAttrObj = {}; 9116 var activeItemRole = ASPx.Attr.GetAttribute(activeItem, "role"); 9117 var attrName = activeItemRole == "combobox" ? "aria-label" : "innerHtml"; 9118 messageAttrObj[attrName] = ASPx.Str.EncodeHtml(text); 9119 activeItemArgs = this.addArguments(activeItemArgs, messageAttrObj); 9120 messageAttrObj[attrName] = ""; 9121 inactiveItemArgs = this.addArguments(inactiveItemArgs, messageAttrObj); 9122 var errorTextElement = null;
9123 if(this.control.GetErrorCell()) { 9124 errorTextElement = this.getAriaExplanatoryTextManager().GetErrorTextElement(); 9125 activeItemArgs = this.addArguments(activeItemArgs, {"aria-invalid" : !this.control.isValid ? "true" : "" }); 9126 mainElementArgs = this.addArguments(mainElementArgs, { "aria-invalid" : "" }); 9127 inactiveItemArgs = this.addArguments(inactiveItemArgs, { "aria-invalid" : "" }); 9128 } 9129 this.changeActivityAttributes(activeItem, activeItemArgs); 9130 if(errorTextElement) { 9131 this.getAriaExplanatoryTextManager().SetOrRemoveText([activeItem], errorTextElement, !this.control.isValid, false, true); 9132 this.getAriaExplanatoryTextManager().SetOrRemoveText([mainElement, inactiveItem], errorTextElement, false, false, false); 9133 } 9134 this.changeActivityAttributes(mainElement, mainElementArgs); 9135 if(!!ownerMainElement && ASPx.Attr.GetAttribute(ownerMainElement, "role") != "application") 9136 this.changeActivityAttributes(ownerMainElement, { "aria-activedescendant": activeItem.id }); 9137 this.changeActivityAttributes(inactiveItem, inactiveItemArgs); 9138 this.pronounceIsStarted = false; 9139 }, 9140 GetActiveElement: function(inputIsMainElement) { 9141 if(this.pronounceIsStarted) return null; 9142 var mainElement = inputIsMainElement ? this.control.GetInputElement() : this.getMainElement(); 9143 var activeElementId = ASPx.Attr.GetAttribute(mainElement, 'aria-activedescendant'); 9144 return activeElementId ? ASPx.GetElementById(activeElementId) : mainElement; 9145 }, 9146 getMainElement: function() { 9147 if(!ASPx.IsExistsElement(this.mainElement)) 9148 this.mainElement = this.control.GetAccessibilityAssistantElement(); 9149 return this.mainElement; 9150 }, 9151 getItems: function() { 9152 if(!ASPx.IsExistsElement(this.items)) 9153 this.items = ASPx.GetChildElementNodes(this.getMainElement()); 9154 return this.items; 9155 }, 9156 getItem: function(isActive) { 9157 if(isActive) 9158 return this.activeItem; 9159 var items = this.getItems(); 9160 return items[0] === this.activeItem ? items[1] : items[0]; 9161 }, 9162 getAriaExplanatoryTextManager: function() { return this.control.ariaExplanatoryTextManager; }, 9163 getPronounceTimeout: function() { return this.pronounceMessageTimeout; }, 9164 toogleItem: function() { 9165 this.activeItem = this.getItem(); 9166 }, 9167 addArguments: function(targetArgs, newArgs) { 9168 if(!targetArgs) targetArgs = { }; 9169 for(var key in newArgs) { 9170 if(newArgs.hasOwnProperty(key) && !targetArgs.hasOwnProperty(key)) 9171 targetArgs[key] = newArgs[key]; 9172 } 9173 return targetArgs; 9174 }, 9175 changeActivityAttributes: function(element, args) { 9176 if(!element) 9177 return; 9178 for(var key in args) { 9179 if(args.hasOwnProperty(key)) { 9180 var value = args[key]; 9181 if(key == "innerHtml") 9182 ASPx.SetInnerHtml(element, value); 9183 else { 9184 var action = value !== "" ? ASPx.Attr.SetAttribute : ASPx.Attr.RemoveAttribute; 9185 action(element, key, value); 9186 } 9187 } 9188 } 9189 } 9190}); 9191var AccessibilityPronouncer = ASPx.CreateClass(null, { 9192 constructor: function() { 9193 this.pronouncerId = "dxPronouncer"; 9194 this.initialized = false; 9195 this.focusableMessageElement = null; 9196 this.messageElement = null; 9197 this.pronouncers = { 9198 live: new AccessibilityLivePronouncer(this), 9199 descendant: new AccessibilityDescendantPronouncer(this) 9200 }; 9201 }, 9202 Pronounce: function(args, type) { 9203 this.pronouncers[type].Pronounce(args); 9204 }, 9205 EnsureInitialize: function() { 9206 if(!this.initialized) 9207 this.initialize(); 9208 }, 9209 RemoveState: function() { 9210 for(var pronouncer in this.pronouncers) 9211 if(this.pronouncers.hasOwnProperty(pronouncer)) 9212 pronouncer.RemoveState(); 9213 }, 9214 RestoreControlState: function(type, mainElement) { 9215 this.pronouncers[type].RestoreControlState(mainElement); 9216 }, 9217 RestoreElementsState: function(type, elements) { 9218 this.pronouncers[type].RestoreElementsState(elements); 9219 }, 9220 RestoreElementState: function(type, element) { 9221 this.pronouncers[type].RestoreElementState(element); 9222 }, 9223 initialize: function() { 9224 this.createFocusableMessageElement(); 9225 this.createMessageElement(); 9226 this.prepareFocusableMessageElement(); 9227 this.setAttributesForKeyboardNavigation(); 9228 this.initialized = true; 9229 }, 9230 createFocusableMessageElement: function() { 9231 var focusableMessageElement = document.createElement("DIV"); 9232 document.body.appendChild(focusableMessageElement); 9233 this.focusableMessageElement = focusableMessageElement; 9234 }, 9235 prepareFocusableMessageElement: function() { 9236 this.focusableMessageElement.className = "dxAIFME"; 9237 }, 9238 setAttributesForKeyboardNavigation: function() { 9239 ASPx.Attr.Aria.SetApplicationRole(this.focusableMessageElement); 9240 ASPx.Attr.Aria.SetSilence(this.focusableMessageElement); 9241 }, 9242 createMessageElement: function() { 9243 var messageElement = document.createElement("DIV"); 9244 messageElement.id = this.pronouncerId; 9245 ASPx.Attr.SetAttribute(messageElement, "role", "note"); 9246 this.focusableMessageElement.appendChild(messageElement); 9247 this.messageElement = messageElement; 9248 }, 9249 getMessage: function(messagePartsArg) { 9250 var messageParts = messagePartsArg.filter(function(x) { return ASPx.IsExists(x); }); 9251 return messageParts.join(", "); 9252 } 9253}); 9254var AccessibilityPronouncerBase = ASPx.CreateClass(null, { 9255 constructor: function() { 9256 this.state = { }; 9257 }, 9258 Pronounce: function(args) { 9259 var messageElement = this.getMessageElement(); 9260 ASPx.Attr.Aria.SetOrRemoveLabel(messageElement); 9261 ASPx.SetInnerHtml(messageElement, ""); 9262 this.PronounceCore(args); 9263 }, 9264 PronounceCore: function(args) { }, 9265 SaveElementState: function(element) {
9266 if(this.state[element.id]) 9267 return; 9268 this.state[element.id] = { 9269 element: element, 9270 descendant: ASPx.Attr.GetAttribute(element, ASPx.Attr.Aria.descendant) 9271 }; 9272 }, 9273 RemoveState: function() { 9274 this.state = { }; 9275 }, 9276 RestoreControlState: function(mainElement) { 9277 for(var elementInfo in this.state) { 9278 if(this.state.hasOwnProperty(elementInfo)) { 9279 var element = this.state[elementInfo].element; 9280 if(!mainElement || ASPx.GetIsParent(mainElement, element)) 9281 this.RestoreElementState(element); 9282 } 9283 } 9284 }, 9285 RestoreElementsState: function(elements) { 9286 for(var i = 0; i < elements.length; i++) 9287 this.RestoreElementState(elements[i]); 9288 }, 9289 RestoreElementState: function(element) { 9290 var elementState = this.state[element.id]; 9291 if(!elementState) 9292 return; 9293 ASPx.Attr.Aria.SetOrRemoveDescendant(element, elementState.descendant); 9294 delete this.state[element.id]; 9295 }, 9296 getMessage: function(args) { 9297 return ASPx.AccessibilityPronouncer.getMessage(args.messageParts); 9298 }, 9299 getMessageElement: function() { 9300 return ASPx.AccessibilityPronouncer.messageElement; 9301 }, 9302 getFocusableMessageElement: function() { 9303 return ASPx.AccessibilityPronouncer.focusableMessageElement; 9304 } 9305}); 9306var AccessibilityLivePronouncer = ASPx.CreateClass(AccessibilityPronouncerBase, { 9307 constructor: function() { 9308 this.constructor.prototype.constructor.call(this); 9309 }, 9310 PronounceCore: function(args) { 9311 var message = this.getMessage(args); 9312 var messageElement = this.getMessageElement(); 9313 ASPx.Attr.SetAttribute(this.getFocusableMessageElement(), "aria-live", "assertive"); 9314 ASPx.Attr.Aria.SetAtomic(this.getFocusableMessageElement(), "true"); 9315 ASPx.SetInnerHtml(messageElement, ASPx.Str.EncodeHtml(message)); 9316 } 9317}); 9318var AccessibilityDescendantPronouncer = ASPx.CreateClass(AccessibilityPronouncerBase, { 9319 constructor: function() { 9320 this.constructor.prototype.constructor.call(this); 9321 }, 9322 PronounceCore: function(args) { 9323 var message = this.getMessage(args); 9324 var activeElement = ASPx.GetActiveElement(); 9325 var messageElement = this.getMessageElement(); 9326 this.SaveElementState(activeElement); 9327 ASPx.Attr.RemoveAttribute(this.getFocusableMessageElement(), "aria-live"); 9328 ASPx.Attr.RemoveAttribute(this.getFocusableMessageElement(), "aria-atomic"); 9329 ASPx.Attr.Aria.SetOrRemoveLabel(messageElement, message); 9330 ASPx.Attr.Aria.SetOrRemoveDescendant(activeElement, messageElement.id); 9331 } 9332}); 9333ASPx.AccessibilityPronouncerType = { 9334 live: "live", 9335 descendant: "descendant" 9336}; 9337ASPx.AccessibilityPronouncer = new AccessibilityPronouncer(); 9338var RestoreFocusHelper = ASPx.CreateClass(null, { 9339 constructor: function() { 9340 this.excludedIDs = [ "DXCBtn" ]; 9341 this.pronouncerType = ASPx.AccessibilityPronouncerType.live; 9342 this.callbackQueue = []; 9343 this.Initialize(); 9344 }, 9345 Initialize: function() { 9346 var that = this; 9347 ASPx.attachToLoad(function() { 9348 ASPxClientControl.GetControlCollection().BeginCallback.AddHandler(that.OnBeginCallback, that); 9349 ASPxClientControl.GetControlCollection().EndCallback.AddHandler(that.OnEndCallback, that); 9350 }); 9351 }, 9352 OnBeginCallback: function(s, e) { 9353 var control = e.control; 9354 if(!control.allowRestoreFocusOnCallbacks()) 9355 return; 9356 control.accessibilityFocusTreeLine = this.getFocusTreeLine(control); 9357 var controlHasCallbackTreeLine = this.callbackQueueContainsTreeLine(control); 9358 this.pushTreeLineInfoIntoCallbackQueue(control); 9359 if(control.accessibilityFocusTreeLine && !controlHasCallbackTreeLine) 9360 control.SendMessageToAssistiveTechnology(this.getDefaultCallbackMessage()); 9361 }, 9362 OnEndCallback: function(s, e) { 9363 var control = e.control; 9364 if(!control.allowRestoreFocusOnCallbacks()) 9365 return; 9366 var treeLineInfo = this.shiftTreeLineInfoFromCallbackQueue(control); 9367 if(treeLineInfo.queueLength == 0) { 9368 if(!control.accessibilityFocusTreeLine && treeLineInfo.treeLine) 9369 control.accessibilityFocusTreeLine = treeLineInfo.treeLine; 9370 var focusElement = this.findFocusElement(control); 9371 var focusIsManagerByPopupwindow = this.isFocusManagedByActivePopupWindow(focusElement); 9372 var focusIsManagedByControl = control.shouldPreventFocusRestoringOnCallback && control.shouldPreventFocusRestoringOnCallback(); 9373 if(!focusIsManagerByPopupwindow && !focusIsManagedByControl) 9374 ASPx.AccessibilityUtils.SetFocusAccessible(focusElement); 9375 delete control.accessibilityFocusTreeLine; 9376 } 9377 }, 9378 pushTreeLineInfoIntoCallbackQueue: function(control) { 9379 var controlTreeLine = control.accessibilityFocusTreeLine ? control.accessibilityFocusTreeLine.slice(0) : null; 9380 if(!this.callbackQueue[control.name]) 9381 this.callbackQueue[control.name] = []; 9382 this.callbackQueue[control.name].push(controlTreeLine); 9383 }, 9384 shiftTreeLineInfoFromCallbackQueue: function(control) { 9385 var treeLineInfo = { queueLength: 0, treeLine: null }; 9386 var treeLines = this.callbackQueue[control.name]; 9387 if(treeLines && treeLines.length > 0) { 9388 treeLineInfo.treeLine = treeLines.shift(); 9389 var linesCount = treeLines.length; 9390 treeLineInfo.queueLength = linesCount; 9391 if(linesCount > 0 && !treeLines[0] && treeLineInfo.treeLine) 9392 treeLines[0] = treeLineInfo.treeLine.slice(0); 9393 } 9394 return treeLineInfo; 9395 }, 9396 callbackQueueContainsTreeLine: function(control) { 9397 var treeLines = this.callbackQueue[control.name]; 9398 if(!treeLines || treeLines.length == 0) 9399 return false; 9400 if(treeLines[treeLines.length - 1]) 9401 return true; 9402 return false; 9403 }, 9404 getDefaultCallbackMessage: function() { 9405 return ASPx.AccessibilitySR.DefaultCallbackMessage; 9406 }, 9407 isFocusManagedByActivePopupWindow: function(focusElement) { 9408 var popupControl = this.getActivePopupControl(); 9409 if(!popupControl || popupControl.accessibleFocusElement) 9410 return false; 9411 this.initializePopupAccessibleFocusElement(popupControl, focusElement); 9412 return popupControl.setFocusOnCallback; 9413 }, 9414 getActivePopupControl: function() { 9415 var activePopupWindow = ASPx.GetPopupControlCollection && ASPx.GetPopupControlCollection().GetCurrentActiveWindowElement(); 9416 if(!activePopupWindow) 9417 return null; 9418 var popupInfo = ASPx.GetPopupControlCollection().GetPopupWindowFromID(activePopupWindow.id); 9419 return popupInfo.popupControl; 9420 }, 9421 initializePopupAccessibleFocusElement: function(popupControl, focusElement) { 9422 if(popupControl.setFocusOnCallback) 9423 popupControl.accessibleFocusElement = focusElement; 9424 else { 9425 var parentControl = popupControl.GetParentControl(); 9426 if(parentControl && parentControl.GetMainElement()) 9427 popupControl.accessibleFocusElement = ASPx.FindFirstChildActionElement(parentControl.GetMainElement()); 9428 } 9429 }, 9430 getFocusTreeLine: function(control) { 9431 var element = ASPx.GetActiveElement(); 9432 if(!ASPx.IsExistsElement(element)) 9433 return null; 9434 var mainElement = control.GetMainElement(); 9435 if(!ASPx.GetIsParent(mainElement, element)) { 9436 var treeInfo = this.findFocusedControlElement(mainElement, element); 9437 element = treeInfo.focusElement; 9438 mainElement = treeInfo.rootElement; 9439 } 9440 return this.getTreeLineCore(mainElement, element); 9441 }, 9442 getTreeLineCore: function(mainElement, element) { 9443 if(!element) return null; 9444 treeLine = [ ]; 9445 while(element) { 9446 treeLine.push({
9447 id: element.id, 9448 tagName: element.tagName, 9449 index: ASPx.Data.ArrayIndexOf(element.parentNode.childNodes, element) 9450 }); 9451 if(element === mainElement || element === document.body) 9452 break; 9453 element = element.parentNode; 9454 } 9455 return treeLine; 9456 }, 9457 findFocusedControlElement: function(mainElement, activeElement) { 9458 var element = null; 9459 var parentElement = mainElement; 9460 var focusedEditor = ASPx.IsExists(ASPx.GetFocusedEditor) ? ASPx.GetFocusedEditor() : null; 9461 if(focusedEditor && ASPx.GetIsParent(mainElement, focusedEditor.GetMainElement())) 9462 element = focusedEditor.GetFocusableInputElement(); 9463 else { 9464 if(mainElement && activeElement) { 9465 var mainControl = ASPx.GetClientControlByElementID(mainElement.id); 9466 var parentControls = ASPx.GetParentClientControls(activeElement.id); 9467 for(var i = parentControls.length - 1; i > -1; i--) { 9468 if(mainControl.name == parentControls[i].name) { 9469 element = activeElement; 9470 var rootIndex = i > 0 ? i - 1 : i; 9471 parentElement = parentControls[rootIndex].GetMainElement(); 9472 if(!parentElement && parentControls[rootIndex].GetCurrentWindowElement) 9473 parentElement = parentControls[rootIndex].GetCurrentWindowElement(); 9474 break; 9475 } 9476 } 9477 } 9478 } 9479 return { focusElement: element, rootElement: parentElement }; 9480 }, 9481 findFocusElement: function(control) { 9482 if(!control.accessibilityFocusTreeLine) 9483 return; 9484 var treeLine = control.accessibilityFocusTreeLine.slice(0); 9485 var focusElementParent = this.findFocusElementParentById(treeLine); 9486 if(!focusElementParent) 9487 return; 9488 return this.findFocusElementFromDOMTree(treeLine, focusElementParent); 9489 }, 9490 findFocusElementParentById: function(treeLine) { 9491 for(var i = 0; i < treeLine.length; i++) { 9492 var id = treeLine[i].id; 9493 if(!this.isValidId(id)) 9494 continue; 9495 var element = document.getElementById(id); 9496 if(element) { 9497 treeLine.splice(i, treeLine.length - i); 9498 treeLine.reverse(); 9499 return element; 9500 } 9501 } 9502 return null; 9503 }, 9504 findFocusElementFromDOMTree: function(treeLine, focusElementParent) { 9505 var element = focusElementParent; 9506 for(var i = 0; i < treeLine.length; i++) { 9507 var info = treeLine[i]; 9508 if(info.index >= element.childNodes.length) { 9509 element = element.childNodes.length > 0 ? element.childNodes[element.childNodes.length - 1] : null; 9510 return this.findNeighbourFocusElement(element, focusElementParent); 9511 } 9512 var child = element.childNodes[info.index]; 9513 if(child.tagName !== info.tagName) 9514 return this.findNeighbourFocusElement(child, focusElementParent); 9515 element = child; 9516 } 9517 return element; 9518 }, 9519 findNeighbourFocusElement: function(element, focusElementParent) { 9520 ASPx.ActionElementsCache.BeginUsage(); 9521 var result = this.findNeighbourFocusElementCore(element, focusElementParent); 9522 ASPx.ActionElementsCache.EndUsage(); 9523 return result; 9524 }, 9525 findNeighbourFocusElementCore: function(element, focusElementParent) { 9526 if(!element || !element.parentNode) return null; 9527 var neighbours = element.parentNode.childNodes; 9528 var indices = this.calcLeftRightIndices(ASPx.Data.ArrayIndexOf(neighbours, element), neighbours.length); 9529 for(var i = 0; i < indices.length; i++) { 9530 var index = indices[i]; 9531 var actionElement = ASPx.FindFirstChildActionElement(neighbours[index]); 9532 if(actionElement) 9533 return actionElement; 9534 } 9535 if(element === focusElementParent) 9536 return null; 9537 return this.findNeighbourFocusElement(element.parentNode, focusElementParent); 9538 }, 9539 calcLeftRightIndices: function(startIndex, count) { 9540 var indices = [ ]; 9541 var incSides = [ 0, 0 ]; 9542 var index = startIndex; 9543 for(var i = 0; i < count; i++) { 9544 indices.push(index); 9545 var even = i % 2 === 0; 9546 var nextIndex = this.calcNextIndex(startIndex, count, incSides, even); 9547 if(nextIndex < 0) 9548 nextIndex = this.calcNextIndex(startIndex, count, incSides, !even); 9549 index = nextIndex; 9550 } 9551 return indices; 9552 }, 9553 calcNextIndex: function(startIndex, count, incSides, even) { 9554 var sideIndex = even ? 0 : 1; 9555 var inc = incSides[sideIndex]; 9556 inc += even ? -1 : 1; 9557 var nextIndex = startIndex + inc; 9558 if(nextIndex >= 0 && nextIndex < count) { 9559 incSides[sideIndex] = inc; 9560 return nextIndex; 9561 } 9562 return -1; 9563 }, 9564 isValidId: function(id) { 9565 return id && !this.isExcludedId(id); 9566 }, 9567 isExcludedId: function(id) { 9568 var result = false; 9569 for(var i = 0; i < this.excludedIDs.length; i++) { 9570 if(id.indexOf(this.excludedIDs[i]) > -1) { 9571 result = true; 9572 break; 9573 } 9574 } 9575 return result; 9576 } 9577}); 9578var EventStorage = ASPx.CreateClass(null, { 9579 constructor: function() { 9580 this.bag = { }; 9581 }, 9582 Save: function(e, data, overwrite) { 9583 var key = this.getEventKey(e); 9584 if(this.bag.hasOwnProperty(key) && !overwrite) 9585 return; 9586 this.bag[key] = data; 9587 window.setTimeout(function() { delete this.bag[key]; }.aspxBind(this), 100); 9588 }, 9589 Load: function(e) { 9590 var key = this.getEventKey(e); 9591 return this.bag[key]; 9592 }, 9593 getEventKey: function(e) { 9594 if(ASPx.IsExists(e.timeStamp)) 9595 return e.timeStamp.toString(); 9596 var eventSource = ASPx.Evt.GetEventSource(e); 9597 var type = e.type.toString(); 9598 return eventSource ? type + "_" + eventSource.uniqueID.toString() : type; 9599 } 9600}); 9601ASPx.RestoreFocusHelper = new RestoreFocusHelper(); 9602EventStorage.Instance = null; 9603EventStorage.getInstance = function() { 9604 if(!EventStorage.Instance) 9605 EventStorage.Instance = new EventStorage(); 9606 return EventStorage.Instance; 9607}; 9608var GetGlobalObject = function(objectName) { 9609 var fields = objectName.split('.'); 9610 var obj = window[fields[0]]; 9611 for(var i = 1;
9611 obj && i < fields.length; i++) { 9612 obj = obj[fields[i]]; 9613 } 9614 return obj; 9615}; 9616var GetExternalScriptProcessor = function() { 9617 return ASPx.ExternalScriptProcessor ? ASPx.ExternalScriptProcessor.getInstance() : null; 9618}; 9619var SAVED_WIDTH_ATTR = "data-dx-ripple-saved-width"; 9620var RIPPLE_FIXED_ROW_ATTR = "data-dx-ripple-locked"; 9621var READ_ONLY_COMBOBOX_MARKER_CSS_CLASS = "dxICBReadonlyMarker"; 9622var ThemesWithRipple = ['Material']; 9623var RippleHelper = { 9624 rippleTargetClassName: "dxRippleTarget", 9625 rippleTargetExternalClassName: "dxRippleTargetExternal", 9626 rippleContainerClassName: "dxRippleContainer", 9627 rippleClassName: "dxRipple", 9628 touchRadius: -1, 9629 isMobileExternalRipple: null, 9630 zoom: 1, 9631 Init: function() { 9632 if(this.getIsRippleFunctionalityEnabled()) { 9633 setTimeout(function() { 9634 this.calcTouchRadius(); 9635 }.aspxBind(this), 0); 9636 } 9637 }, 9638 calcTouchRadius: function() { 9639 var testBlock = document.createElement("DIV"); 9640 ASPx.SetStyles(testBlock, { 9641 height: "1in", 9642 width: "1in", 9643 left: "-100%", 9644 top: "-100%", 9645 position: "absolute" 9646 }); 9647 document.body.appendChild(testBlock); 9648 this.touchRadius = (1.8 / 2.54) * Math.max(testBlock.offsetWidth, testBlock.offsetHeight); 9649 document.body.removeChild(testBlock); 9650 }, 9651 isRippleFunctionalityEnabled: null, 9652 checkRippleFunctionality: function() { 9653 if(ASPx.Browser.Safari && ASPx.Browser.Version <= 5.1) 9654 return false; 9655 for(var i = 0; i < ThemesWithRipple.length; i++) { 9656 var firstRippleThemeElement = document.querySelector("[class*='_" + ThemesWithRipple[i] + "']"); 9657 if(firstRippleThemeElement) 9658 return true; 9659 } 9660 return false; 9661 }, 9662 ReInit: function() { 9663 this.isRippleFunctionalityEnabled = null; 9664 this.Init(); 9665 }, 9666 onDocumentMouseDown: function(evt) { 9667 if(RippleHelper.getIsRippleFunctionalityEnabled()) 9668 RippleHelper.processMouseDown(evt); 9669 }, 9670 getIsRippleFunctionalityEnabled: function() { 9671 if(!ASPx.IsExists(this.isRippleFunctionalityEnabled)) 9672 this.isRippleFunctionalityEnabled = this.checkRippleFunctionality(); 9673 return this.isRippleFunctionalityEnabled; 9674 }, 9675 createTargetInfo: function(target) { 9676 return { 9677 x: ASPx.GetAbsoluteX(target), 9678 y: ASPx.GetAbsoluteY(target), 9679 width: target.offsetWidth, 9680 height: target.offsetHeight, 9681 classNames: ASPx.GetClassNameList(target), 9682 getTarget: function() { return target; }, 9683 getRect: function() { return {x: this.x, y: this.y, width: this.width, height: this.height }; } 9684 }; 9685 }, 9686 createEventInfo: function(evt) { 9687 return { x: this.getEventX(evt), y: this.getEventY(evt) }; 9688 }, 9689 processMouseDown: function(evt) { 9690 var evtSource = ASPx.Evt.GetEventSource(evt); 9691 var rippleTarget = this.getRippleTargetElement(evtSource); 9692 if(this.needToProcessRipple(rippleTarget, evtSource)) 9693 this.processRipple(this.createTargetInfo(rippleTarget), this.createEventInfo(evt)); 9694 }, 9695 getRippleTargetElement: function(evtSource) { 9696 if(this.hasRippleMarker(evtSource)) 9697 return evtSource; 9698 if(evtSource.tagName && evtSource.tagName.toLowerCase() == "input" && ASPx.ElementContainsCssClass(evtSource, "dxTI")) { 9699 var elements = ASPx.GetChildElementNodesByPredicate(evtSource.parentNode.parentNode, function(element) { 9700 return this.hasRippleMarker(element); 9701 }.aspxBind(this)); 9702 return elements && elements[0]; 9703 } 9704 return ASPx.GetParent(evtSource, function(element) { 9705 return this.hasRippleMarker(element); 9706 }.aspxBind(this)); 9707 }, 9708 hasRippleMarker: function(element) { 9709 if(!ASPx.IsExistsElement(element)) 9710 return false; 9711 var computedStyles = window.getComputedStyle(element, ":before"); 9712 if(ASPx.IsExists(computedStyles)) { 9713 var content = computedStyles.getPropertyValue("content"); 9714 if(content.indexOf(this.rippleTargetExternalClassName) > -1) { 9715 ASPx.AddClassNameToElement(element, this.rippleTargetExternalClassName); 9716 return true; 9717 } 9718 return content.indexOf(this.rippleTargetClassName) > -1; 9719 } 9720 return false; 9721 }, 9722 needToProcessRipple: function(rippleTarget, evtSource) { 9723 if(!rippleTarget || !ASPx.AnimationUtils) 9724 return false; 9725 var isClearButton = ASPx.ElementContainsCssClass(rippleTarget, "dxeButton") && rippleTarget.id && rippleTarget.id.indexOf("B-100") !== -1; 9726 var isEmptyCalendarDay = ASPx.ElementContainsCssClass(rippleTarget, "dxeCalendarDay") && ASPx.Str.Trim(rippleTarget.textContent) == ""; 9727 var isReadonly = ASPx.ElementContainsCssClass(rippleTarget, READ_ONLY_COMBOBOX_MARKER_CSS_CLASS); 9728 var tempFixDisable = ASPx.ElementContainsCssClass(rippleTarget, "dxSwitcher") && ASPx.Browser.MacOSMobilePlatform; 9729 var rippleIsForbidden = isReadonly || isClearButton || isEmptyCalendarDay || ASPx.GetParentByPartialClassName(rippleTarget, "Disabled") || 9730 ASPx.ElementContainsCssClass(rippleTarget, "dxgvBatchEditCell") || ASPx.ElementContainsCssClass(rippleTarget, "dxcvEditForm") || 9731 ASPx.GetParentByPartialClassName(evtSource, "dxcvFocusedCell") || tempFixDisable; 9732 return !rippleIsForbidden; 9733 }, 9734 hasBothOverflow: function(style) { 9735 return style.overflow == "scroll" || style.overflow == "auto" || style.overflow == "hidden"; 9736 }, 9737 hasOverflowX: function(style) { 9738 return style.overflowX == "scroll" || style.overflowX == "auto" || style.overflowX == "hidden"; 9739 }, 9740 hasOverflowY: function(style) { 9741 return style.overflowY == "scroll" || style.overflowY == "auto" || style.overflowY == "hidden"; 9742 }, 9743 getExternalRippleContainerSize: function(targetRect) { 9744 if(ASPx.Browser.MobileUI) { 9745 var origTouchRadius = this.getOriginTouchRadius(); 9746 if(origTouchRadius < targetRect.width || origTouchRadius < targetRect.height) 9747 origTouchRadius = Math.max(targetRect.width, targetRect.height); 9748 return {x: targetRect.x + (targetRect.width - origTouchRadius) / 2, y: targetRect.y + (targetRect.height - origTouchRadius) / 2, width: origTouchRadius, height: origTouchRadius }; 9749 } 9750 var result = { x: 0, y: 0, width: 0, height: 0 }; 9751 var diff = targetRect.width - targetRect.height; 9752 if(diff > 0) { 9753 result.x = targetRect.x; 9754 result.y = targetRect.y - diff / 2; 9755 result.width = targetRect.width; 9756 result.height = targetRect.width; 9757 } else { 9758 result.x = targetRect.x + diff / 2; 9759 result.y = targetRect.y; 9760 result.width = targetRect.height; 9761 result.height = targetRect.height; 9762 } 9763 return result; 9764 }, 9765 getInternalContainerSize: function(targetInfo) { 9766 var parentWithOverflow = RippleHelper.getParentWithOverflow(targetInfo.getTarget()); 9767 if(!ASPx.IsExists(parentWithOverflow)) 9768 return targetInfo; 9769 var parentWithOverflowStyle = ASPx.GetCurrentStyle(parentWithOverflow); 9770 var bothOverflow = this.hasBothOverflow(parentWithOverflowStyle); 9771 var overflowX = this.hasOverflowX(parentWithOverflowStyle); 9772 var overflowY = this.hasOverflowY(parentWithOverflowStyle); 9773 var parentRect = { 9774 x: ASPx.GetAbsoluteX(parentWithOverflow), 9775 y: ASPx.GetAbsoluteY(parentWithOverflow), 9776 width: parentWithOverflow.offsetWidth, 9777 height: parentWithOverflow.offsetHeight 9778 }; 9779 return this.getInternalContainerSizeCore(targetInfo, parentRect, bothOverflow, overflowX, overflowY); 9780 }, 9781 getInternalContainerSizeCore: function(targetRect, parentRect, bothOverflow, overflowX, overflowY) { 9782 var result = {}; 9783 ASPx.Data.MergeHashTables(result, targetRect); 9784 if(bothOverflow || overflowX) { 9785 result.x = targetRect.x < parentRect.x ? parentRect.x : targetRect.x; 9786 if(targetRect.x + targetRect.width > parentRect.x + parentRect.width) 9787 result.width = parentRect.x + parentRect.width - targetRect.x; 9788 if(parentRect.x > targetRect.x) 9789 result.width -= (parentRect.x - targetRect.x); 9790 } 9791 if(bothOverflow || overflowY) { 9792 result.y = targetRect.y < parentRect.y ? parentRect.y : targetRect.y; 9793 if(targetRect.y + targetRect.height > parentRect.y + parentRect.height) 9794 result.height = parentRect.y + parentRect.height - targetRect.y; 9795 if(parentRect.y > targetRect.y) 9796 result.height -= (parentRect.y - targetRect.y); 9797 } 9798 return result; 9799 }, 9800 calculateRippleContainerSize: function(targetInfo, isExternalRipple) { 9801 return isExternalRipple ? this.getExternalRippleContainerSize(targetInfo) : this.getInternalContainerSize(targetInfo); 9802 }, 9803 getParentWithOverflow: function(rippleTarget) { 9804 var result = ASPx.GetParent(rippleTarget, function(element) { 9805 var elementStyle = ASPx.GetCurrentStyle(element); 9806 return this.hasBothOverflow(elementStyle) || this.hasOverflowX(elementStyle) || this.hasOverflowY(elementStyle); 9807 }.aspxBind(this)); 9808 return result; 9809 }, 9810 getDuration: function(targetInfo) { 9811 return this.IsExternalRipple(targetInfo) || ASPx.Browser.MobileUI ? 650 : 450; 9812 }, 9813 createRippleTransition: function(container, rippleElement, radius, targetInfo) { 9814 var rippleSize = 2 * radius; 9815 var transitionEndIsAborted = true; 9816 var transitionProperties = { 9817 width: { from: 0, to: rippleSize, transition: ASPx.AnimationConstants.Transitions.RIPPLE, propName: "width", unit: "px" }, 9818 height: { from: 0, to: rippleSize, transition: ASPx.AnimationConstants.Transitions.RIPPLE, propName: "height", unit: "px" }, 9819 marginLeft: { from: 0, to: -rippleSize / 2, transition: ASPx.AnimationConstants.Transitions.RIPPLE, propName: "marginLeft", unit: "px" }, 9820 marginTop: { from: 0, to: -rippleSize / 2, transition: ASPx.AnimationConstants.Transitions.RIPPLE, propName: "marginTop", unit: "px" }, 9821 opacity: { from: 1, to: 0.05, transition: ASPx.AnimationConstants.Transitions.RIPPLE, propName: "o
9821pacity", unit: "%" } 9822 }; 9823 var rippleTransition = ASPx.AnimationUtils.createMultipleAnimationTransition(rippleElement, { 9824 transition: ASPx.AnimationConstants.Transitions.RIPPLE, 9825 duration: this.getDuration(targetInfo), 9826 onComplete: function() { 9827 this.RemoveRippleContainer(container.parentElement); 9828 transitionEndIsAborted = false; 9829 }.bind(this) 9830 }); 9831 rippleTransition.Start(transitionProperties); 9832 window.setTimeout(function() { 9833 if(transitionEndIsAborted) 9834 this.RemoveRippleContainer(container.parentElement); 9835 }.bind(this), 500); 9836 }, 9837 calculateRadius: function(isExternalRipple, posX, posY, containerRect) { 9838 var radius = -1; 9839 if(isExternalRipple) { 9840 if(ASPx.Browser.MobileUI) 9841 radius = this.getOriginTouchRadius() / 2; 9842 else 9843 radius = Math.max(containerRect.height, containerRect.width); 9844 } else { 9845 var width1 = posX - containerRect.x; 9846 var width2 = containerRect.width - width1; 9847 var height1 = posY - containerRect.y; 9848 var height2 = containerRect.height - height1; 9849 var rippleWidth = Math.max(width1, width2); 9850 var rippleHeight = Math.max(height1, height2); 9851 radius = Math.sqrt(Math.pow(rippleHeight, 2) + Math.pow(rippleWidth, 2)); 9852 } 9853 return radius; 9854 }, 9855 createRippleElement: function(container, rippleCenter) { 9856 var rippleElement = document.createElement("DIV"); 9857 rippleElement.className = this.rippleClassName; 9858 container.appendChild(rippleElement); 9859 ASPxClientUtils.SetAbsoluteX(rippleElement, rippleCenter.x); 9860 ASPxClientUtils.SetAbsoluteY(rippleElement, rippleCenter.y); 9861 return rippleElement; 9862 }, 9863 processRipple: function(targetInfo, eventInfo) { 9864 this.initRippleProcess(); 9865 var isExternalRipple = this.IsExternalRipple(targetInfo); 9866 var rippleCenter = this.getRippleCenter(targetInfo.getRect(), eventInfo, isExternalRipple); 9867 var container = this.createRippleContainer(targetInfo, isExternalRipple); 9868 var rippleElement = this.createRippleElement(container, rippleCenter); 9869 var radius = this.calculateRadius(isExternalRipple, rippleCenter.x, rippleCenter.y, this.getElementRect(container)); 9870 this.createRippleTransition(container, rippleElement, radius, targetInfo); 9871 }, 9872 initRippleProcess: function() { 9873 this.isMobileExternalRipple = null; 9874 this.zoom = screen.width / window.innerWidth; 9875 }, 9876 getRippleCenter: function(targetInfo, eventInfo, isExternalRipple) { 9877 var posX = 0; 9878 var posY = 0; 9879 if(isExternalRipple) { 9880 posX = targetInfo.x + targetInfo.width / 2; 9881 posY = targetInfo.y + targetInfo.height / 2; 9882 } else { 9883 posX = eventInfo.x; 9884 posY = eventInfo.y; 9885 } 9886 return {x: posX, y: posY}; 9887 }, 9888 createRippleContainer: function(targetInfo, isExternalRipple) { 9889 var containerParent = targetInfo.getTarget(); 9890 if(!containerParent) 9891 return; 9892 var containerTagName = containerParent.tagName == "TR" ? "TD" : "DIV"; 9893 var container = document.createElement(containerTagName); 9894 container.className = this.rippleContainerClassName; 9895 if(containerParent.parentNode && containerParent.tagName == "IMG") 9896 containerParent = containerParent.parentNode; 9897 if(this.isARowInFixedLayoutTable(containerParent)) 9898 this.lockFixedLayoutTableSizes(containerParent); 9899 containerParent.appendChild(container); 9900 if(isExternalRipple) 9901 container.style.borderRadius = "50%"; 9902 var containerRect = this.calculateRippleContainerSize(targetInfo, isExternalRipple); 9903 this.assignContainerSettings(container, containerRect); 9904 return container; 9905 }, 9906 isARowInFixedLayoutTable: function(containerParent) { 9907 if(containerParent.tagName !== "TR") 9908 return false; 9909 var parentTable = this.getParentTable(containerParent); 9910 return parentTable && ASPx.GetCurrentStyle(parentTable)["table-layout"] === "fixed"; 9911 }, 9912 processFirstRowOfFixedTable: function(containerRow, rowAction, cellAction) { 9913 var firstRow = this.getFirstRow(containerRow); 9914 rowAction(firstRow); 9915 var cells = ASPx.Data.CollectionToArray(firstRow.cells); 9916 cells.forEach(cellAction); 9917 }, 9918 getParentTable: function(element) { 9919 var parentTable = element; 9920 while(parentTable && parentTable.tagName !== "TABLE") 9921 parentTable = parentTable.parentElement; 9922 return parentTable; 9923 }, 9924 lockFixedLayoutTableSizes: function(containerRow) { 9925 var firstRow = this.getFirstRow(containerRow); 9926 if(this.incLockCount(firstRow) === 1) { 9927 var cells = ASPx.Data.CollectionToArray(firstRow.cells); 9928 var widths = cells.map(function(cell) { return cell.style.width; }); 9929 var computedWidths = cells.map(function(cell) { 9930 if(ASPx.Browser.IE && ASPx.ElementHasCssClass(cell, "dxeCM")) 9931 return cell.offsetWidth + "px"; 9932 return window.getComputedStyle(cell).width; 9933 }); 9934 var fixWidth = function(cell, i) { 9935 if(ASPx.Attr.IsExistsAttribute(cell, SAVED_WIDTH_ATTR)) 9936 return; 9937 if(widths[i]) 9938 ASPx.Attr.SetAttribute(cell, SAVED_WIDTH_ATTR, widths[i]); 9939 cell.style.width = computedWidths[i]; 9940 };
9941 cells.forEach(fixWidth); 9942 } 9943 }, 9944 unlockFixedLayoutTableSizes: function(containerRow) { 9945 var firstRow = this.getFirstRow(containerRow); 9946 if(this.decLockCount(firstRow) === 0) { 9947 var cells = ASPx.Data.CollectionToArray(firstRow.cells); 9948 var restoreState = function(cell) { 9949 if(ASPx.Attr.IsExistsAttribute(cell, SAVED_WIDTH_ATTR)) { 9950 cell.style.width = ASPx.Attr.GetAttribute(cell, SAVED_WIDTH_ATTR); 9951 ASPx.Attr.RemoveAttribute(cell, SAVED_WIDTH_ATTR); 9952 } else { 9953 cell.style.width = null; 9954 } 9955 }; 9956 cells.forEach(restoreState); 9957 } 9958 }, 9959 getFirstRow: function(containerRow) { return ASPx.GetChildByTagName(containerRow.parentElement, "TR", 0); }, 9960 incLockCount: function(elem) { return this.changeLockCount(elem, 1); }, 9961 decLockCount: function(elem) { return this.changeLockCount(elem, -1); }, 9962 changeLockCount: function(elem, diff) { 9963 var lockCounter = this.getLockCount(elem); 9964 lockCounter += diff; 9965 lockCounter = Math.max(0, lockCounter); 9966 if(lockCounter === 0) 9967 ASPx.Attr.RemoveAttribute(elem, RIPPLE_FIXED_ROW_ATTR); 9968 else 9969 ASPx.Attr.SetAttribute(elem, RIPPLE_FIXED_ROW_ATTR, lockCounter); 9970 return lockCounter; 9971 }, 9972 getLockCount: function(lockElement) { 9973 var attrValue = ASPx.Attr.GetAttribute(lockElement, RIPPLE_FIXED_ROW_ATTR); 9974 return parseInt(attrValue) || 0; 9975 }, 9976 assignContainerSettings: function(container, containerRect) { 9977 var properties = { 9978 height: containerRect.height, 9979 width: containerRect.width, 9980 left: ASPx.PrepareClientPosForElement(containerRect.x, container, true), 9981 top: ASPx.PrepareClientPosForElement(containerRect.y, container, false) 9982 }; 9983 if(ASPx.Browser.MobileUI) 9984 ASPx.Data.MergeHashTables(properties, {marginTop: 0, marginLeft: 0 }); 9985 ASPx.SetStyles(container, properties, ASPx.Browser.MobileUI); 9986 }, 9987 IsExternalRipple: function(targetInfo) { 9988 var hasExternalRippleClassName = ASPx.ElementContainsCssClass(targetInfo.getTarget(), this.rippleTargetExternalClassName); 9989 if(!ASPx.Browser.MobileUI) 9990 return hasExternalRippleClassName; 9991 return hasExternalRippleClassName || this.IsMobileExternalRipple(targetInfo); 9992 }, 9993 IsMobileExternalRipple: function(targetInfo) { 9994 if(this.isMobileExternalRipple == null) { 9995 var originTouchRadius = this.getOriginTouchRadius(); 9996 this.isMobileExternalRipple = ASPx.Browser.MobileUI && targetInfo.width < originTouchRadius && targetInfo.height < originTouchRadius; 9997 } 9998 return this.isMobileExternalRipple; 9999 }, 10000 RemoveRippleContainer: function(element) { 10001 if(!element) 10002 return; 10003 var childs = ASPx.GetChildNodesByClassName(element, this.rippleContainerClassName); 10004 var rippleContainer = childs.length > 0 ? childs[0] : null; 10005 if(rippleContainer != null) { 10006 var containerParent = rippleContainer.parentNode; 10007 containerParent.removeChild(rippleContainer); 10008 if(this.isARowInFixedLayoutTable(containerParent)) 10009 this.unlockFixedLayoutTableSizes(containerParent); 10010 } 10011 }, 10012 getEventX: function(evt) { 10013 return ASPxClientUtils.GetEventX(evt); 10014 }, 10015 getEventY: function(evt) { 10016 return ASPxClientUtils.GetEventY(evt); 10017 }, 10018 getOriginTouchRadius: function() { 10019 return this.touchRadius / this.zoom; 10020 }, 10021 getElementRect: function(element) { 10022 return { x: ASPx.GetAbsoluteX(element), y: ASPx.GetAbsoluteY(element), width: element.offsetWidth, height: element.offsetHeight }; 10023 } 10024}; 10025var AccessibilitySR = { 10026 AddStringResources: function(stringResourcesObj) { 10027 if(stringResourcesObj) { 10028 for(var key in stringResourcesObj) 10029 if(stringResourcesObj.hasOwnProperty(key)) 10030 this[key] = stringResourcesObj[key]; 10031 } 10032 } 10033}; 10034ASPx.CollectionBase = CollectionBase; 10035ASPx.FunctionIsInCallstack = _aspxFunctionIsInCallstack; 10036ASPx.RaisePostHandlerOnPost = aspxRaisePostHandlerOnPost; 10037ASPx.GetPostHandler = aspxGetPostHandler; 10038ASPx.ProcessScriptsAndLinks = _aspxProcessScriptsAndLinks; 10039ASPx.InitializeLinks = _aspxInitializeLinks; 10040ASPx.InitializeScripts = _aspxInitializeScripts; 10041ASPx.RunStartupScripts = _aspxRunStartupScripts; 10042ASPx.IsStartupScriptsRunning = _aspxIsStartupScriptsRunning; 10043ASPx.AddScriptsRestartHandler = _aspxAddScriptsRestartHandler; 10044ASPx.GetFocusedElement = _aspxGetFocusedElement; 10045ASPx.GetDomObserver = _aspxGetDomObserver;
10046ASPx.CacheHelper = CacheHelper; 10047ASPx.ControlTree = ControlTree; 10048ASPx.ControlAdjuster = ControlAdjuster; 10049ASPx.GetControlAdjuster = GetControlAdjuster; 10050ASPx.ControlCallbackHandlersQueue = ControlCallbackHandlersQueue; 10051ASPx.ResourceManager = ResourceManager; 10052ASPx.UpdateWatcherHelper = UpdateWatcherHelper; 10053ASPx.EventStorage = EventStorage; 10054ASPx.GetGlobalObject = GetGlobalObject; 10055ASPx.GetExternalScriptProcessor = GetExternalScriptProcessor; 10056ASPx.CheckBoxCheckState = CheckBoxCheckState; 10057ASPx.CheckBoxInputKey = CheckBoxInputKey; 10058ASPx.CheckableElementStateController = CheckableElementStateController; 10059ASPx.CheckableElementHelper = CheckableElementHelper; 10060ASPx.CheckBoxInternal = CheckBoxInternal; 10061ASPx.CheckBoxInternalCollection = CheckBoxInternalCollection; 10062ASPx.ControlCallbackQueueHelper = ControlCallbackQueueHelper; 10063ASPx.FocusedStyleDecoration = FocusedStyleDecoration; 10064ASPx.EditorStyleDecoration = EditorStyleDecoration; 10065ASPx.TextEditorStyleDecoration = TextEditorStyleDecoration; 10066ASPx.AccessibilitySR = AccessibilitySR; 10067ASPx.KbdHelper = KbdHelper; 10068ASPx.AccessKeysHelper = AccessKeysHelper; 10069ASPx.AccessKey = AccessKey; 10070ASPx.IFrameHelper = IFrameHelper; 10071ASPx.Ident = Ident; 10072ASPx.TouchUIHelper = TouchUIHelper; 10073ASPx.ControlUpdateWatcher = ControlUpdateWatcher; 10074ASPx.ControlTabIndexManager = ControlTabIndexManager; 10075ASPx.AccessibilityHelperBase = AccessibilityHelperBase; 10076ASPx.RippleHelper = RippleHelper; 10077ASPx.ThemesWithRipple = ThemesWithRipple; 10078window.ASPxClientEvent = ASPxClientEvent; 10079window.ASPxClientEventArgs = ASPxClientEventArgs; 10080window.ASPxClientCancelEventArgs = ASPxClientCancelEventArgs; 10081window.ASPxClientProcessingModeEventArgs = ASPxClientProcessingModeEventArgs; 10082window.ASPxClientProcessingModeCancelEventArgs = ASPxClientProcessingModeCancelEventArgs; 10083ASPx.Evt.AttachEventToDocument(TouchUIHelper.touchMouseDownEventName, RippleHelper.onDocumentMouseDown); 10084ASPx.classesScriptParsed = true; 10085})(ASPx, { GCCheckInterval: 5000 }); 10086 10087(function () { 10088ASPx.StateItemsExist = false; 10089ASPx.FocusedItemKind = "FocusedStateItem"; 10090ASPx.HoverItemKind = "HoverStateItem"; 10091ASPx.PressedItemKind = "PressedStateItem"; 10092ASPx.SelectedItemKind = "SelectedStateItem"; 10093ASPx.DisabledItemKind = "DisabledStateItem"; 10094ASPx.ReadOnlyItemKind = "ReadOnlyStateItem"; 10095ASPx.CachedStatePrefix = "cached"; 10096ASPxStateItem = ASPx.CreateClass(null, { 10097 constructor: function(name, classNames, cssTexts, postfixes, imageObjs, imagePostfixes, kind, disableApplyingStyleToLink){ 10098 this.name = name; 10099 this.classNames = classNames; 10100 this.customClassNames = []; 10101 this.resultClassNames = []; 10102 this.cssTexts = cssTexts; 10103 this.postfixes = postfixes; 10104 this.imageObjs = imageObjs; 10105 this.imagePostfixes = imagePostfixes; 10106 this.kind = kind; 10107 this.classNamePostfix = kind.substr(0, 1).toLowerCase(); 10108 this.enabled = true; 10109 this.needRefreshBetweenElements = false; 10110 this.elements = null; 10111 this.images = null; 10112 this.links = []; 10113 this.linkColor = null; 10114 this.linkTextDecoration = null; 10115 this.disableApplyingStyleToLink = !!disableApplyingStyleToLink; 10116 }, 10117 GetCssText: function(index){ 10118 if(ASPx.IsExists(this.cssTexts[index])) 10119 return this.cssTexts[index]; 10120 return this.cssTexts[0]; 10121 }, 10122 CreateStyleRule: function(index){ 10123 if(this.GetCssText(index) == "") return ""; 10124 var styleSheet = ASPx.GetCurrentStyleSheet(); 10125 if(styleSheet) 10126 return ASPx.CreateImportantStyleRule(styleSheet, this.GetCssText(index), this.classNamePostfix); 10127 return ""; 10128 }, 10129 GetClassName: function(index){ 10130 if(ASPx.IsExists(this.classNames[index])) 10131 return this.classNames[index]; 10132 return this.classNames[0]; 10133 }, 10134 GetResultClassName: function(index){ 10135 if(!ASPx.IsExists(this.resultClassNames[index])) { 10136 if(!ASPx.IsExists(this.customClassNames[index])) 10137 this.customClassNames[index] = this.CreateStyleRule(index); 10138 if(this.GetClassName(index) != "" && this.customClassNames[index] != "") 10139 this.resultClassNames[index] = this.GetClassName(index) + " " + this.customClassNames[index]; 10140 else if(this.GetClassName(index) != "") 10141 this.resultClassNames[index] = this.GetClassName(index); 10142 else if(this.customClassNames[index] != "") 10143 this.resultClassNames[index] = this.customClassNames[index]; 10144 else 10145 this.resultClassNames[index] = ""; 10146 } 10147 return this.resultClassNames[index]; 10148 }, 10149 GetElements: function(element){ 10150 if(!this.elements || !ASPx.IsValidElements(this.elements)){ 10151 if(this.postfixes && this.postfixes.length > 0){ 10152 this.elements = [ ]; 10153 var parentNode = element.parentNode; 10154 if(parentNode){
10155 for(var i = 0; i < this.postfixes.length; i++){ 10156 var id = this.name + this.postfixes[i]; 10157 this.elements[i] = ASPx.GetChildById(parentNode, id); 10158 if(!this.elements[i]) 10159 this.elements[i] = ASPx.GetElementById(id); 10160 } 10161 } 10162 } 10163 else 10164 this.elements = [element]; 10165 } 10166 return this.elements; 10167 }, 10168 GetImages: function(element){ 10169 if(!this.images || !ASPx.IsValidElements(this.images)){ 10170 this.images = [ ]; 10171 if(this.imagePostfixes && this.imagePostfixes.length > 0){ 10172 var elements = this.GetElements(element); 10173 for(var i = 0; i < this.imagePostfixes.length; i++){ 10174 var id = this.name + this.imagePostfixes[i]; 10175 for(var j = 0; j < elements.length; j++){ 10176 if(!elements[j]) continue; 10177 if(elements[j].id == id) 10178 this.images[i] = elements[j]; 10179 else 10180 this.images[i] = ASPx.GetChildById(elements[j], id); 10181 if(this.images[i]) 10182 break; 10183 } 10184 } 10185 } 10186 } 10187 return this.images; 10188 }, 10189 Apply: function(element){ 10190 if(!this.enabled) return; 10191 try{ 10192 this.ApplyStyle(element); 10193 if(this.imageObjs && this.imageObjs.length > 0) 10194 this.ApplyImage(element); 10195 if(ASPx.Browser.IE && ASPx.Browser.MajorVersion >= 11 && ASPx.Browser.PlaformMajorVersion < 10) 10196 this.ForceRedrawAppearance(element); 10197 } 10198 catch(e){ 10199 } 10200 }, 10201 ApplyStyle: function(element){ 10202 var elements = this.GetElements(element); 10203 for(var i = 0; i < elements.length; i++){ 10204 if(!elements[i]) continue; 10205 if(this.GetResultClassName(i) != "") { 10206 var className = elements[i].className.replace(this.GetResultClassName(i), ""); 10207 elements[i].className = ASPx.Str.Trim(className) + " " + this.GetResultClassName(i); 10208 } 10209 if(!ASPx.Browser.Opera || ASPx.Browser.Version >= 9) 10210 this.ApplyStyleToLinks(elements, i); 10211 } 10212 }, 10213 ApplyStyleToLinks: function(elements, index){ 10214 if(this.disableApplyingStyleToLink) 10215 return; 10216 if(!ASPx.IsValidElements(this.links[index])) 10217 this.links[index] = ASPx.GetNodesByTagName(elements[index], "A"); 10218 for(var i = 0; i < this.links[index].length; i++) 10219 this.ApplyStyleToLinkElement(this.links[index][i], index); 10220 }, 10221 ApplyStyleToLinkElement: function(link, index){ 10222 if(this.GetLinkColor(index) != "") 10223 ASPx.Attr.ChangeAttributeExtended(link.style, "color", link, "saved" + this.kind + "Color", this.GetLinkColor(index)); 10224 if(this.GetLinkTextDecoration(index) != "") 10225 ASPx.Attr.ChangeAttributeExtended(link.style, "textDecoration", link, "saved" + this.kind + "TextDecoration", this.GetLinkTextDecoration(index)); 10226 }, 10227 ApplyImage: function(element){ 10228 var images = this.GetImages(element); 10229 for(var i = 0; i < images.length; i++){ 10230 if(!images[i] || !this.imageObjs[i]) continue; 10231 var useSpriteImage = typeof(this.imageObjs[i]) != "string"; 10232 var newUrl = "", newCssClass = "", newBackground = ""; 10233 if(useSpriteImage){ 10234 newUrl = ASPx.EmptyImageUrl; 10235 if(this.imageObjs[i].spriteCssClass) 10236 newCssClass = this.imageObjs[i].spriteCssClass;
10237 if(this.imageObjs[i].spriteBackground) 10238 newBackground = this.imageObjs[i].spriteBackground; 10239 } 10240 else{ 10241 newUrl = this.imageObjs[i]; 10242 if(ASPx.Attr.IsExistsAttribute(images[i].style, "background")) 10243 newBackground = " "; 10244 } 10245 if(newUrl != "") 10246 ASPx.Attr.ChangeAttributeExtended(images[i], "src", images[i], "saved" + this.kind + "Src", newUrl); 10247 if(newCssClass != "") 10248 this.ApplyImageClassName(images[i], newCssClass); 10249 if(newBackground != ""){ 10250 if(ASPx.Browser.WebKitFamily) { 10251 var savedBackground = ASPx.Attr.GetAttribute(images[i].style, "background"); 10252 if(!useSpriteImage) 10253 savedBackground += " " + images[i].style["backgroundPosition"]; 10254 ASPx.Attr.SetAttribute(images[i], "saved" + this.kind + "Background", savedBackground); 10255 ASPx.Attr.SetAttribute(images[i].style, "background", newBackground); 10256 } 10257 else 10258 ASPx.Attr.ChangeAttributeExtended(images[i].style, "background", images[i], "saved" + this.kind + "Background", newBackground); 10259 } 10260 } 10261 }, 10262 ApplyImageClassName: function(element, newClassName){ 10263 if(ASPx.Attr.GetAttribute(element, "saved" + this.kind + "ClassName")) 10264 this.CancelImageClassName(element); 10265 var className = element.className; 10266 ASPx.Attr.SetAttribute(element, "saved" + this.kind + "ClassName", className); 10267 element.className = className + " " + newClassName; 10268 }, 10269 Cancel: function(element){ 10270 if(!this.enabled) return; 10271 try{ 10272 if(this.imageObjs && this.imageObjs.length > 0) 10273 this.CancelImage(element); 10274 this.CancelStyle(element); 10275 } 10276 catch(e){ 10277 } 10278 }, 10279 CancelStyle: function(element){ 10280 var elements = this.GetElements(element); 10281 for(var i = 0; i < elements.length; i++){ 10282 if(!elements[i]) continue; 10283 if(this.GetResultClassName(i) != "") { 10284 var className = ASPx.Str.Trim(elements[i].className.replace(this.GetResultClassName(i), "")); 10285 elements[i].className = className; 10286 } 10287 if(!ASPx.Browser.Opera || ASPx.Browser.Version >= 9) 10288 this.CancelStyleFromLinks(elements, i); 10289 } 10290 }, 10291 CancelStyleFromLinks: function(elements, index){ 10292 if(this.disableApplyingStyleToLink) 10293 return; 10294 if(!ASPx.IsValidElements(this.links[index])) 10295 this.links[index] = ASPx.GetNodesByTagName(elements[index], "A"); 10296 for(var i = 0; i < this.links[index].length; i++) 10297 this.CancelStyleFromLinkElement(this.links[index][i], index); 10298 }, 10299 CancelStyleFromLinkElement: function(link, index){ 10300 if(this.GetLinkColor(index) != "") 10301 ASPx.Attr.RestoreAttributeExtended(link.style, "color", link, "saved" + this.kind + "Color"); 10302 if(this.GetLinkTextDecoration(index) != "") 10303 ASPx.Attr.RestoreAttributeExtended(link.style, "textDecoration", link, "saved" + this.kind + "TextDecoration"); 10304 }, 10305 CancelImage: function(element){ 10306 var images = this.GetImages(element); 10307 for(var i = 0; i < images.length; i++){ 10308 if(!images[i] || !this.imageObjs[i]) continue; 10309 ASPx.Attr.RestoreAttributeExtended(images[i], "src", images[i], "saved" + this.kind + "Src"); 10310 this.CancelImageClassName(images[i]); 10311 ASPx.Attr.RestoreAttributeExtended(images[i].style, "background", images[i], "saved" + this.kind + "Background"); 10312 } 10313 }, 10314 CancelImageClassName: function(element){ 10315 var savedClassName = ASPx.Attr.GetAttribute(element, "saved" + this.kind + "ClassName"); 10316 if(ASPx.IsExists(savedClassName)) { 10317 element.className = savedClassName; 10318 ASPx.Attr.RemoveAttribute(element, "saved" + this.kind + "ClassName"); 10319 } 10320 }, 10321 Clone: function(){ 10322 return new ASPxStateItem(this.name, this.classNames, this.cssTexts, this.postfixes, 10323 this.imageObjs, this.imagePostfixes, this.kind, this.disableApplyingStyleToLink); 10324 }, 10325 IsChildElement: function(element){ 10326 if(element != null){ 10327 var elements = this.GetElements(element); 10328 for(var i = 0; i < elements.length; i++){ 10329 if(!elements[i]) continue; 10330 if(ASPx.GetIsParent(elements[i], element)) 10331 return true; 10332 } 10333 } 10334 return false; 10335 }, 10336 ForceRedrawAppearance: function(element) { 10337 if(!aspxGetStateController().IsForceRedrawAppearanceLocked()) { 10338 var value = element.style.opacity; 10339 element.style.opacity = "0.7777"; 10340 var dummy = element.offsetWidth; 10341 element.style.opacity = value; 10342 } 10343 }, 10344 GetLinkColor: function(index){ 10345 if(!ASPx.IsExists(this.linkColor)){ 10346 var rule = ASPx.GetStyleSheetRules(this.customClassNames[index]); 10347 this.linkColor = rule ? rule.style.color : null; 10348 if(!ASPx.IsExists(this.linkColor)){ 10349 var rule = ASPx.GetStyleSheetRules(this.GetClassName(index)); 10350 this.linkColor = rule ? rule.style.color : null; 10351 } 10352 if(this.linkColor == null) 10353 this.linkColor = ""; 10354 } 10355 return this.linkColor; 10356 }, 10357 GetLinkTextDecoration: function(index){ 10358 if(!ASPx.IsExists(this.linkTextDecoration)){ 10359 var rule = ASPx.GetStyleSheetRules(this.customClassNames[index]); 10360 this.linkTextDecoration = rule ? rule.style.textDecoration : null; 10361 if(!ASPx.IsExists(this.linkTextDecoration)){ 10362 var rule = ASPx.GetStyleSheetRules(this.GetClassName(index)); 10363 this.linkTextDecoration = rule ? rule.style.textDecoration : null; 10364 } 10365 if(this.linkTextDecoration == null) 10366 this.linkTextDecoration = ""; 10367 } 10368 return this.linkTextDecoration; 10369 } 10370}); 10371ASPxClientStateEventArgs = ASPx.CreateClass(null, { 10372 constructor: function(item, element){ 10373 this.item = item; 10374 this.element = element; 10375 this.toElement = null; 10376 this.fromElement = null; 10377 this.htmlEvent = null; 10378 } 10379}); 10380ASPxStateController = ASPx.CreateClass(null, { 10381 constructor: function(){ 10382 this.focusedItems = { }; 10383 this.hoverItems = { }; 10384 this.pressedItems = { }; 10385 this.selectedItems = { }; 10386 this.disabledItems = {}; 10387 this.readOnlyItems = {}; 10388 this.disabledScheme = {}; 10389 this.currentFocusedElement = null; 10390 this.currentFocusedItemName = null; 10391 this.currentHoverElement = null; 10392 this.currentHoverItemName = null; 10393 this.currentPressedElement = null; 10394 this.currentPressedItemName = null; 10395 this.savedCurrentPressedElement = null; 10396 this.savedCurrentMouseMoveSrcElement = null; 10397 this.forceRedrawAppearanceLockCount = 0; 10398 this.stateItemType = ASPxStateItem; 10399 this.AfterSetFocusedState = new ASPxClientEvent(); 10400 this.AfterClearFocusedState = new ASPxClientEvent(); 10401 this.AfterSetHoverState = new ASPxClientEvent(); 10402 this.AfterClearHoverState = new ASPxClientEvent(); 10403 this.AfterSetPressedState = new ASPxClientEvent(); 10404 this.AfterClearPressedState = new ASPxClientEvent(); 10405 this.AfterDisabled = new ASPxClientEvent(); 10406 this.AfterEnabled = new ASPxClientEvent(); 10407 this.BeforeSetFocusedState = new ASPxClientEvent(); 10408 this.BeforeClearFocusedState = new ASPxClientEvent(); 10409 this.BeforeSetHoverState = new ASPxClientEvent(); 10410 this.BeforeClearHoverState = new ASPxClientEvent(); 10411 this.BeforeSetPressedState = new ASPxClientEvent(); 10412 this.BeforeClearPressedState = new ASPxClientEvent(); 10413 this.BeforeDisabled = new ASPxClientEvent(); 10414 this.BeforeEnabled = new ASPxClientEvent(); 10415 this.FocusedItemKeyDown = new ASPxClientEvent(); 10416 }, 10417 AddHoverItem: function(name, classNames, cssTexts, postfixes, imageObjs, imagePostfixes, disableApplyingStyleToLink){ 10418 this.AddItem(this.hoverItems, name, classNames, cssTexts, postfixes, imageObjs, imagePostfixes, ASPx.HoverItemKind, disableApplyingStyleToLink); 10419 this.AddItem(this.focusedItems, name, classNames, cssTexts, postfixes, imageObjs, imagePostfixes, ASPx.FocusedItemKind, disableApplyingStyleToLink); 10420 }, 10421 AddPressedItem: function(name, classNames, cssTexts, postfixes, imageObjs, imagePostfixes, disableApplyingStyleToLink){ 10422 this.AddItem(this.pressedItems, name, classNames, cssTexts, postfixes, imageObjs, imagePostfixes, ASPx.PressedItemKind, disableApplyingStyleToLink); 10423 }, 10424 AddSelectedItem: function(name, classNames, cssTexts, postfixes, imageObjs, imagePostfixes, disableApplyingStyleToLink){ 10425 this.AddItem(this.selectedItems, name, classNames, cssTexts, postfixes, imageObjs, imagePostfixes, ASPx.SelectedItemKind, disableApplyingStyleToLink); 10426 }, 10427 AddDisabledItem: function (name, classNames, cssTexts, postfixes, imageObjs, imagePostfixes, disableApplyingStyleToLink, rootId) { 10428 this.AddItem(this.disabledItems, name, classNames, cssTexts, postfixes, imageObjs, imagePostfixes, 10429 ASPx.DisabledItemKind, disableApplyingStyleToLink, this.addIdToDisabledItemScheme, rootId); 10430 }, 10431 AddReadOnlyItem: function(name, classNames, cssTexts, postfixes, imageObjs, imagePostfixes, disableApplyingStyleToLink) { 10432 this.AddItem(this.readOnlyItems, name, classNames, cssTexts, postfixes, imageObjs, imagePostfixes, ASPx.ReadOnlyItemKind, disableApplyingStyleToLink); 10433 }, 10434 addIdToDisabledItemScheme: function(rootId, childId) { 10435 if (!rootId) 10436 return; 10437 if (!this.disabledScheme[rootId]) 10438 this.disabledScheme[rootId] = [rootId];
10439 if (childId && (rootId != childId) && ASPx.Data.ArrayIndexOf(this.disabledScheme[rootId], childId) == -1) 10440 this.disabledScheme[rootId].push(childId); 10441 }, 10442 removeIdFromDisabledItemScheme: function(rootId, childId) { 10443 if (!rootId || !this.disabledScheme[rootId]) 10444 return; 10445 ASPx.Data.ArrayRemove(this.disabledScheme[rootId], childId); 10446 if (this.disabledScheme[rootId].length == 0) 10447 delete this.disabledScheme[rootId]; 10448 }, 10449 AddItem: function (items, name, classNames, cssTexts, postfixes, imageObjs, imagePostfixes, kind, disableApplyingStyleToLink, onAdd, rootId) { 10450 var type = this.getStateItemType(); 10451 var stateItem = new type(name, classNames, cssTexts, postfixes, imageObjs, imagePostfixes, kind, disableApplyingStyleToLink); 10452 if (postfixes && postfixes.length > 0) { 10453 for (var i = 0; i < postfixes.length; i++) { 10454 items[name + postfixes[i]] = stateItem; 10455 if (onAdd) 10456 onAdd.call(this, rootId, name + postfixes[i]); 10457 } 10458 } 10459 else { 10460 if (onAdd) 10461 onAdd.call(this, rootId, name); 10462 items[name] = stateItem; 10463 } 10464 ASPx.StateItemsExist = true; 10465 }, 10466 getStateItemType: function () { return this.stateItemType; }, 10467 withCustomStateItemType: function (newType, callback) { 10468 this.stateItemType = newType; 10469 callback(this); 10470 this.stateItemType = ASPxStateItem; 10471 }, 10472 RemoveHoverItem: function(name, postfixes){ 10473 this.RemoveItem(this.hoverItems, name, postfixes); 10474 this.RemoveItem(this.focusedItems, name, postfixes); 10475 }, 10476 RemovePressedItem: function(name, postfixes){ 10477 this.RemoveItem(this.pressedItems, name, postfixes); 10478 }, 10479 RemoveSelectedItem: function(name, postfixes){ 10480 this.RemoveItem(this.selectedItems, name, postfixes); 10481 }, 10482 RemoveDisabledItem: function (name, postfixes, rootId) { 10483 this.RemoveItem(this.disabledItems, name, postfixes, this.removeIdFromDisabledItemScheme, rootId); 10484 }, 10485 RemoveReadOnlyItem: function(name, postfixes) { 10486 this.RemoveItem(this.readOnlyItems, name, postfixes); 10487 }, 10488 RemoveItem: function (items, name, postfixes, onRemove, rootId) { 10489 if (postfixes && postfixes.length > 0) { 10490 for (var i = 0; i < postfixes.length; i++) { 10491 delete items[name + postfixes[i]]; 10492 if (onRemove) 10493 onRemove.call(this, rootId, name + postfixes[i]); 10494 } 10495 } 10496 else { 10497 delete items[name]; 10498 if (onRemove) 10499 onRemove.call(this, rootId, name); 10500 } 10501 }, 10502 RemoveDisposedItems: function(){ 10503 this.RemoveDisposedItemsByType(this.hoverItems); 10504 this.RemoveDisposedItemsByType(this.pressedItems); 10505 this.RemoveDisposedItemsByType(this.focusedItems); 10506 this.RemoveDisposedItemsByType(this.selectedItems); 10507 this.RemoveDisposedItemsByType(this.disabledItems); 10508 this.RemoveDisposedItemsByType(this.disabledScheme); 10509 this.RemoveDisposedItemsByType(this.readOnlyItems); 10510 }, 10511 RemoveDisposedItemsByType: function(items){ 10512 for(var key in items) { 10513 if(items.hasOwnProperty(key)) { 10514 var item = items[key]; 10515 var element = document.getElementById(key); 10516 if(!element || !ASPx.IsValidElement(element)) 10517 delete items[key]; 10518 try { 10519 if(item && item.elements) { 10520 for(var i = 0; i < item.elements.length; i++) { 10521 if(!ASPx.IsValidElements(item.links[i])) 10522 item.links[i] = null; 10523 } 10524 } 10525 } 10526 catch(e) { 10527 } 10528 } 10529 } 10530 }, 10531 GetFocusedElement: function(srcElement){ 10532 return this.GetItemElement(srcElement, this.focusedItems, ASPx.FocusedItemKind); 10533 }, 10534 GetHoverElement: function(srcElement){ 10535 return this.GetItemElement(srcElement, this.hoverItems, ASPx.HoverItemKind); 10536 }, 10537 GetPressedElement: function(srcElement){ 10538 return this.GetItemElement(srcElement, this.pressedItems, ASPx.PressedItemKind); 10539 }, 10540 GetSelectedElement: function(srcElement){ 10541 return this.GetItemElement(srcElement, this.selectedItems, ASPx.SelectedItemKind); 10542 }, 10543 GetDisabledElement: function(srcElement){ 10544 return this.GetItemElement(srcElement, this.disabledItems, ASPx.DisabledItemKind); 10545 }, 10546 GetReadOnlyElement: function(srcElement) { 10547 return this.GetItemElement(srcElement, this.readOnlyItems, ASPx.ReadOnlyItemKind); 10548 }, 10549 GetItemElement: function(srcElement, items, kind){ 10550 if(srcElement && srcElement[ASPx.CachedStatePrefix + kind]){ 10551 var cachedElement = srcElement[ASPx.CachedStatePrefix + kind]; 10552 if(cachedElement != ASPx.EmptyObject) 10553 return cachedElement; 10554 return null; 10555 } 10556 var element = srcElement; 10557 while(element != null) {
10558 var item = items[element.id]; 10559 if(item){ 10560 this.CacheItemElement(srcElement, kind, element); 10561 element[kind] = item; 10562 return element; 10563 } 10564 element = element.parentNode; 10565 } 10566 this.CacheItemElement(srcElement, kind, ASPx.EmptyObject); 10567 return null; 10568 }, 10569 CacheItemElement: function(srcElement, kind, value){ 10570 if(srcElement && !srcElement[ASPx.CachedStatePrefix + kind]) 10571 srcElement[ASPx.CachedStatePrefix + kind] = value; 10572 }, 10573 DoSetFocusedState: function(element, fromElement){ 10574 var item = element[ASPx.FocusedItemKind]; 10575 if(item){ 10576 var args = new ASPxClientStateEventArgs(item, element); 10577 args.fromElement = fromElement; 10578 this.BeforeSetFocusedState.FireEvent(this, args); 10579 item.Apply(element); 10580 this.AfterSetFocusedState.FireEvent(this, args); 10581 } 10582 }, 10583 DoClearFocusedState: function(element, toElement){ 10584 var item = element[ASPx.FocusedItemKind]; 10585 if(item){ 10586 var args = new ASPxClientStateEventArgs(item, element); 10587 args.toElement = toElement; 10588 this.BeforeClearFocusedState.FireEvent(this, args); 10589 item.Cancel(element); 10590 this.AfterClearFocusedState.FireEvent(this, args); 10591 } 10592 }, 10593 DoSetHoverState: function(element, fromElement){ 10594 var item = element[ASPx.HoverItemKind]; 10595 if(item){ 10596 var args = new ASPxClientStateEventArgs(item, element); 10597 args.fromElement = fromElement; 10598 this.BeforeSetHoverState.FireEvent(this, args); 10599 item.Apply(element); 10600 this.AfterSetHoverState.FireEvent(this, args); 10601 } 10602 }, 10603 DoClearHoverState: function(element, toElement){ 10604 var item = element[ASPx.HoverItemKind]; 10605 if(item){ 10606 var args = new ASPxClientStateEventArgs(item, element); 10607 args.toElement = toElement; 10608 this.BeforeClearHoverState.FireEvent(this, args); 10609 item.Cancel(element); 10610 this.AfterClearHoverState.FireEvent(this, args); 10611 } 10612 }, 10613 DoSetPressedState: function(element){ 10614 var item = element[ASPx.PressedItemKind]; 10615 if(item){ 10616 var args = new ASPxClientStateEventArgs(item, element); 10617 this.BeforeSetPressedState.FireEvent(this, args); 10618 item.Apply(element); 10619 this.AfterSetPressedState.FireEvent(this, args); 10620 } 10621 }, 10622 DoClearPressedState: function(element){ 10623 var item = element[ASPx.PressedItemKind]; 10624 if(item){ 10625 var args = new ASPxClientStateEventArgs(item, element); 10626 this.BeforeClearPressedState.FireEvent(this, args); 10627 item.Cancel(element); 10628 this.AfterClearPressedState.FireEvent(this, args); 10629 } 10630 }, 10631 SetCurrentFocusedElement: function(element){ 10632 if(this.currentFocusedElement && !ASPx.IsValidElement(this.currentFocusedElement)){ 10633 this.currentFocusedElement = null; 10634 this.currentFocusedItemName = ""; 10635 } 10636 if(this.currentFocusedElement != element){ 10637 var oldCurrentFocusedElement = this.currentFocusedElement; 10638 var item = (element != null) ? element[ASPx.FocusedItemKind] : null; 10639 var itemName = (item != null) ? item.name : ""; 10640 if(this.currentFocusedItemName != itemName){ 10641 if(this.currentHoverItemName != "") 10642 this.SetCurrentHoverElement(null); 10643 if(this.currentFocusedElement != null) 10644 this.DoClearFocusedState(this.currentFocusedElement, element); 10645 this.currentFocusedElement = element; 10646 item = (element != null) ? element[ASPx.FocusedItemKind] : null; 10647 this.currentFocusedItemName = (item != null) ? item.name : ""; 10648 if(this.currentFocusedElement != null) 10649 this.DoSetFocusedState(this.currentFocusedElement, oldCurrentFocusedElement); 10650 } 10651 } 10652 }, 10653 SetCurrentHoverElement: function(element){ 10654 if(this.currentHoverElement && !ASPx.IsValidElement(this.currentHoverElement)){ 10655 this.currentHoverElement = null; 10656 this.currentHoverItemName = ""; 10657 } 10658 var item = (element != null) ? element[ASPx.HoverItemKind] : null; 10659 if(item && !item.enabled) { 10660 element = this.GetItemElement(element.parentNode, this.hoverItems, ASPx.HoverItemKind); 10661 item = (element != null) ? element[ASPx.HoverItemKind] : null; 10662 } 10663 if(this.currentHoverElement != element){ 10664 var oldCurrentHoverElement = this.currentHoverElement, 10665 itemName = (item != null) ? item.name : ""; 10666 if(this.currentHoverItemName != itemName || (item != null && item.needRefreshBetweenElements)){ 10667 if(this.currentHoverElement != null) 10668 this.DoClearHoverState(this.currentHoverElement, element); 10669 item = (element != null) ? element[ASPx.HoverItemKind] : null; 10670 if(item == null || item.enabled){ 10671 this.currentHoverElement = element; 10672 this.currentHoverItemName = (item != null) ? item.name : ""; 10673 if(this.currentHoverElement != null) 10674 this.DoSetHoverState(this.currentHoverElement, oldCurrentHoverElement); 10675 } 10676 } 10677 } 10678 }, 10679 SetCurrentPressedElement: function(element){ 10680 if(this.currentPressedElement && !ASPx.IsValidElement(this.currentPressedElement)){ 10681 this.currentPressedElement = null; 10682 this.currentPressedItemName = ""; 10683 } 10684 if(this.currentPressedElement != element){ 10685 if(this.currentPressedElement != null) 10686 this.DoClearPressedState(this.currentPressedElement); 10687 var item = (element != null) ? element[ASPx.PressedItemKind] : null; 10688 if(item == null || item.enabled){ 10689 this.currentPressedElement = element; 10690 this.currentPressedItemName = (item != null) ? item.name : ""; 10691 if(this.currentPressedElement != null) 10692 this.DoSetPressedState(this.currentPressedElement); 10693 } 10694 } 10695 }, 10696 SetCurrentFocusedElementBySrcElement: function(srcElement){ 10697 var element = this.GetFocusedElement(srcElement); 10698 this.SetCurrentFocusedElement(element); 10699 }, 10700 SetCurrentHoverElementBySrcElement: function(srcElement){ 10701 var element = this.GetHoverElement(srcElement); 10702 this.SetCurrentHoverElement(element); 10703 }, 10704 SetCurrentPressedElementBySrcElement: function(srcElement){ 10705 var element = this.GetPressedElement(srcElement); 10706 this.SetCurrentPressedElement(element); 10707 }, 10708 SetPressedElement: function (element) { 10709 this.SetCurrentHoverElement(null); 10710 this.SetCurrentPressedElementBySrcElement(element); 10711 this.savedCurrentPressedElement = this.currentPressedElement; 10712 }, 10713 SelectElement: function (element) { 10714 var item = element[ASPx.SelectedItemKind]; 10715 if(item) 10716 item.Apply(element); 10717 }, 10718 SelectElementBySrcElement: function(srcElement){ 10719 var element = this.GetSelectedElement(srcElement); 10720 if(element != null) this.SelectElement(element); 10721 }, 10722 DeselectElement: function(element){ 10723 var item = element[ASPx.SelectedItemKind]; 10724 if(item) 10725 item.Cancel(element); 10726 }, 10727 DeselectElementBySrcElement: function(srcElement){ 10728 var element = this.GetSelectedElement(srcElement); 10729 if(element != null) this.DeselectElement(element); 10730 }, 10731 SetElementEnabled: function(element, enable){ 10732 if(enable) 10733 this.EnableElement(element); 10734 else 10735 this.DisableElement(element); 10736 }, 10737 SetElementReadOnly: function(element, readOnly) { 10738 var element = this.GetReadOnlyElement(element); 10739 if (element != null) { 10740 var item = element[ASPx.ReadOnlyItemKind]; 10741 if(item) { 10742 if(readOnly) { 10743 if(item.name == this.currentPressedItemName) 10744 this.SetCurrentPressedElement(null); 10745 if(item.name == this.currentHoverItemName) 10746 this.SetCurrentHoverElement(null); 10747 } 10748 if(readOnly) 10749 item.Apply(element); 10750 else 10751 item.Cancel(element); 10752 } 10753 } 10754 }, 10755 SetElementWithChildNodesEnabled: function (parentName, enabled) { 10756 var procFunct = (enabled ? this.EnableElement : this.DisableElement); 10757 var childItems = this.disabledScheme[parentName]; 10758 if (childItems && childItems.length > 0) 10759 for (var i = 0; i < childItems.length; i++) { 10760 procFunct.call(this, document.getElementById(childItems[i])); 10761 } 10762 }, 10763 DisableElement: function (element) { 10764 var element = this.GetDisabledElement(element); 10765 if(element != null) { 10766 var item = element[ASPx.DisabledItemKind]; 10767 if(item){ 10768 var args = new ASPxClientStateEventArgs(item, element); 10769 this.BeforeDisabled.FireEvent(this, args); 10770 if(item.name == this.currentPressedItemName) 10771 this.SetCurrentPressedElement(null); 10772 if(item.name == this.currentHoverItemName) 10773 this.SetCurrentHoverElement(null); 10774 item.Apply(element); 10775 this.SetMouseStateItemsEnabled(item.name, item.postfixes, false); 10776 this.AfterDisabled.FireEvent(this, args); 10777 } 10778 } 10779 }, 10780 EnableElement: function(element){ 10781 var element = this.GetDisabledElement(element); 10782 if(element != null) { 10783 var item = element[ASPx.DisabledItemKind]; 10784 if(item){ 10785 var args = new ASPxClientStateEventArgs(item, element); 10786 this.BeforeEnabled.FireEvent(this, args); 10787 item.Cancel(element); 10788 this.SetMouseStateItemsEnabled(item.name, item.postfixes, true); 10789 this.AfterEnabled.FireEvent(this, args); 10790 } 10791 } 10792 }, 10793 SetMouseStateItemsEnabled: function(name, postfixes, enabled){ 10794 if(postfixes && postfixes.length > 0){ 10795 for(var i = 0; i < postfixes.length; i ++){ 10796 this.SetItemsEnabled(this.hoverItems, name + postfixes[i], enabled); 10797 this.SetItemsEnabled(this.pressedItems, name + postfixes[i], enabled); 10798 this.SetItemsEnabled(this.focusedItems, name + postfixes[i], enabled); 10799 } 10800 } 10801 else{ 10802 this.SetItemsEnabled(this.hoverItems, name, enabled); 10803 this.SetItemsEnabled(this.pressedItems, name, enabled); 10804 this.SetItemsEnabled(this.focusedItems, name, enabled); 10805 } 10806 }, 10807 SetItemsEnabled: function(items, name, enabled){ 10808 if(items[name]) 10809 items[name].enabled = enabled; 10810 }, 10811 OnFocusMove: function(evt){ 10812 var element = ASPx.Evt.GetEventSource(evt); 10813 aspxGetStateController().SetCurrentFocusedElementBySrcElement(element); 10814 }, 10815 OnMouseMove: function(evt, checkElementChanged){ 10816 var srcElement = ASPx.Evt.GetEventSource(evt); 10817 if(checkElementChanged && srcElement == this.savedCurrentMouseMoveSrcElement) return; 10818 this.savedCurrentMouseMoveSrcElement = srcElement; 10819 if(ASPx.Browser.IE && !ASPx.Evt.IsLeftButtonPressed(evt) && this.savedCurrentPressedElement != null) 10820 this.ClearSavedCurrentPressedElement(); 10821 if(this.savedCurrentPressedElement == null) 10822 this.SetCurrentHoverElementBySrcElement(srcElement); 10823 else{ 10824 var element = this.GetPressedElement(srcElement); 10825 if(element != this.currentPressedElement){ 10826 if(element == this.savedCurrentPressedElement) 10827 this.SetCurrentPressedElement(this.savedCurrentPressedElement); 10828 else 10829 this.SetCurrentPressedElement(null); 10830 } 10831 } 10832 }, 10833 OnMouseDown: function(evt){ 10834 if(!ASPx.Evt.IsLeftButtonPressed(evt)) return; 10835 var srcElement = ASPx.Evt.GetEventSource(evt); 10836 this.OnMouseDownOnElement(srcElement); 10837 }, 10838 OnMouseDownOnElement: function (element) { 10839 if(this.GetPressedElement(element) == null) return; 10840 this.SetPressedElement(element); 10841 }, 10842 OnMouseUp: function(evt){ 10843 var srcElement = ASPx.Evt.GetEventSource(evt); 10844 this.OnMouseUpOnElement(srcElement); 10845 }, 10846 OnMouseUpOnElement: function(element){ 10847 if(this.savedCurrentPressedElement == null) return; 10848 this.ClearSavedCurrentPressedElement(); 10849 this.SetCurrentHoverElementBySrcElement(element); 10850 }, 10851 OnMouseOver: function(evt){ 10852 var element = ASPx.Evt.GetEventSource(evt); 10853 if(element && element.tagName == "IFRAME") 10854 this.OnMouseMove(evt, true); 10855 }, 10856 OnKeyDown: function(evt){ 10857 var element = this.GetFocusedElement(ASPx.Evt.GetEventSource(evt)); 10858 if(element != null && element == this.currentFocusedElement) { 10859 var item = element[ASPx.FocusedItemKind]; 10860 if(item){ 10861 var args = new ASPxClientStateEventArgs(item, element); 10862 args.htmlEvent = evt; 10863 this.FocusedItemKeyDown.FireEvent(this, args); 10864 } 10865 } 10866 }, 10867 OnKeyUpOnElement: function(evt) { 10868 if(this.savedCurrentPressedElement != null && ASPx.Evt.IsActionKeyPressed(evt)) 10869 this.ClearSavedCurrentPressedElement(); 10870 }, 10871 OnSelectStart: function(evt){ 10872 if(this.savedCurrentPressedElement) { 10873 ASPx.Selection.Clear(); 10874 return false; 10875 } 10876 }, 10877 ClearSavedCurrentPressedElement: function() { 10878 this.savedCurrentPressedElement = null; 10879 this.SetCurrentPressedElement(null); 10880 }, 10881 ClearCache: function(srcElement, kind) { 10882 if(srcElement[ASPx.CachedStatePrefix + kind]) 10883 srcElement[ASPx.CachedStatePrefix + kind] = null; 10884 }, 10885 ClearElementCache: function(srcElement) { 10886 this.ClearCache(srcElement, ASPx.FocusedItemKind); 10887 this.ClearCache(srcElement, ASPx.HoverItemKind); 10888 this.ClearCache(srcElement, ASPx.PressedItemKind); 10889 this.ClearCache(srcElement, ASPx.SelectedItemKind); 10890 this.ClearCache(srcElement, ASPx.DisabledItemKind); 10891 }, 10892 LockForceRedrawAppearance: function() { 10893 this.forceRedrawAppearanceLockCount++; 10894 }, 10895 UnlockForceRedrawAppearance: function() { 10896 this.forceRedrawAppearanceLockCount--; 10897 }, 10898 IsForceRedrawAppearanceLocked: function() { 10899 return this.forceRedrawAppearanceLockCount > 0; 10900 } 10901}); 10902var stateController = null; 10903function aspxGetStateController(){ 10904 if(stateController == null) 10905 stateController = new ASPxStateController(); 10906 return stateController; 10907} 10908function aspxAddStateItems(method, namePrefix, classes, disableApplyingStyleToLink){ 10909 for(var i = 0; i < classes.length; i ++){ 10910 for(var j = 0; j < classes[i][2].length; j ++) { 10911 var name = namePrefix; 10912 if(classes[i][2][j]) 10913 name += "_" + classes[i][2][j]; 10914 var postfixes = classes[i][3] || null; 10915 var imageObjs = (classes[i][4] && classes[i][4][j]) || null; 10916 var imagePostfixes = classes[i][5] || null; 10917 method.call(aspxGetStateController(), name, classes[i][0], classes[i][1], postfixes, imageObjs, imagePostfixes, disableApplyingStyleToLink, namePrefix); 10918 } 10919 } 10920} 10921ASPx.AddHoverItems = function(namePrefix, classes, disableApplyingStyleToLink){ 10922 aspxAddStateItems(aspxGetStateController().AddHoverItem, namePrefix, classes, disableApplyingStyleToLink); 10923}; 10924ASPx.AddPressedItems = function(namePrefix, classes, disableApplyingStyleToLink){ 10925 aspxAddStateItems(aspxGetStateController().AddPressedItem, namePrefix, classes, disableApplyingStyleToLink); 10926}; 10927ASPx.AddSelectedItems = function(namePrefix, classes, disableApplyingStyleToLink){ 10928 aspxAddStateItems(aspxGetStateController().AddSelectedItem, namePrefix, classes, disableApplyingStyleToLink); 10929}; 10930ASPx.AddDisabledItems = function(namePrefix, classes, disableApplyingStyleToLink){ 10931 aspxAddStateItems(aspxGetStateController().AddDisabledItem, namePrefix, classes, disableApplyingStyleToLink); 10932}; 10933ASPx.AddReadOnlyItems = function(namePrefix, classes, disableApplyingStyleToLink) { 10934 aspxAddStateItems(aspxGetStateController().AddReadOnlyItem, namePrefix, classes, disableApplyingStyleToLink); 10935}; 10936function aspxRemoveStateItems(method, namePrefix, classes){ 10937 for(var i = 0; i < classes.length; i ++){ 10938 for(var j = 0; j < classes[i][0].length; j ++) { 10939 var name = namePrefix; 10940 if(classes[i][0][j]) 10941 name += "_" + classes[i][0][j]; 10942 method.call(aspxGetStateController(), name, classes[i][1], namePrefix); 10943 } 10944 } 10945} 10946ASPx.RemoveHoverItems = function(namePrefix, classes){ 10947 aspxRemoveStateItems(aspxGetStateController().RemoveHoverItem, namePrefix, classes); 10948}; 10949ASPx.RemovePressedItems = function(namePrefix, classes){ 10950 aspxRemoveStateItems(aspxGetStateController().RemovePressedItem, namePrefix, classes); 10951}; 10952ASPx.RemoveSelectedItems = function(namePrefix, classes){ 10953 aspxRemoveStateItems(aspxGetStateController().RemoveSelectedItem, namePrefix, classes); 10954}; 10955ASPx.RemoveDisabledItems = function(namePrefix, classes){ 10956 aspxRemoveStateItems(aspxGetStateController().RemoveDisabledItem, namePrefix, classes); 10957}; 10958ASPx.RemoveReadOnlyItems = function(namePrefix, classes) { 10959 aspxRemoveStateItems(aspxGetStateController().RemoveReadOnlyItem, namePrefix, classes); 10960}; 10961ASPx.AddAfterClearFocusedState = function(handler){ 10962 aspxGetStateController().AfterClearFocusedState.AddHandler(handler); 10963};
10964ASPx.AddAfterSetFocusedState = function(handler){ 10965 aspxGetStateController().AfterSetFocusedState.AddHandler(handler); 10966}; 10967ASPx.AddAfterClearHoverState = function(handler){ 10968 aspxGetStateController().AfterClearHoverState.AddHandler(handler); 10969}; 10970ASPx.AddAfterSetHoverState = function(handler){ 10971 aspxGetStateController().AfterSetHoverState.AddHandler(handler); 10972}; 10973ASPx.AddAfterClearPressedState = function(handler){ 10974 aspxGetStateController().AfterClearPressedState.AddHandler(handler); 10975}; 10976ASPx.AddAfterSetPressedState = function(handler){ 10977 aspxGetStateController().AfterSetPressedState.AddHandler(handler); 10978}; 10979ASPx.AddAfterDisabled = function(handler){ 10980 aspxGetStateController().AfterDisabled.AddHandler(handler); 10981}; 10982ASPx.AddAfterEnabled = function(handler){ 10983 aspxGetStateController().AfterEnabled.AddHandler(handler); 10984}; 10985ASPx.AddBeforeClearFocusedState = function(handler){ 10986 aspxGetStateController().BeforeClearFocusedState.AddHandler(handler); 10987}; 10988ASPx.AddBeforeSetFocusedState = function(handler){ 10989 aspxGetStateController().BeforeSetFocusedState.AddHandler(handler); 10990}; 10991ASPx.AddBeforeClearHoverState = function(handler){ 10992 aspxGetStateController().BeforeClearHoverState.AddHandler(handler); 10993}; 10994ASPx.AddBeforeSetHoverState = function(handler){ 10995 aspxGetStateController().BeforeSetHoverState.AddHandler(handler); 10996}; 10997ASPx.AddBeforeClearPressedState = function(handler){ 10998 aspxGetStateController().BeforeClearPressedState.AddHandler(handler); 10999}; 11000ASPx.AddBeforeSetPressedState = function(handler){ 11001 aspxGetStateController().BeforeSetPressedState.AddHandler(handler); 11002}; 11003ASPx.AddBeforeDisabled = function(handler){ 11004 aspxGetStateController().BeforeDisabled.AddHandler(handler); 11005}; 11006ASPx.AddBeforeEnabled = function(handler){ 11007 aspxGetStateController().BeforeEnabled.AddHandler(handler); 11008}; 11009ASPx.AddFocusedItemKeyDown = function(handler){ 11010 aspxGetStateController().FocusedItemKeyDown.AddHandler(handler); 11011}; 11012ASPx.SetHoverState = function(element){ 11013 aspxGetStateController().SetCurrentHoverElementBySrcElement(element); 11014}; 11015ASPx.ClearHoverState = function(evt){ 11016 aspxGetStateController().SetCurrentHoverElementBySrcElement(null); 11017}; 11018ASPx.UpdateHoverState = function(evt){ 11019 aspxGetStateController().OnMouseMove(evt, false); 11020}; 11021ASPx.SetFocusedState = function(element){ 11022 aspxGetStateController().SetCurrentFocusedElementBySrcElement(element); 11023}; 11024ASPx.ClearFocusedState = function(evt){ 11025 aspxGetStateController().SetCurrentFocusedElementBySrcElement(null); 11026}; 11027ASPx.UpdateFocusedState = function(evt){ 11028 aspxGetStateController().OnFocusMove(evt); 11029}; 11030ASPx.AccessibilityMarkerClass = "dxalink"; 11031ASPx.AssignAccessibilityEventsToChildrenLinks = function(container, clearFocusedStateOnMouseOut){ 11032 var links = ASPx.GetNodesByPartialClassName(container, ASPx.AccessibilityMarkerClass); 11033 for(var i = 0; i < links.length; i++) 11034 ASPx.AssignAccessibilityEventsToLink(links[i], clearFocusedStateOnMouseOut); 11035}; 11036ASPx.AssignAccessibilityEventsToLink = function(link, clearFocusedStateOnMouseOut) { 11037 if(!ASPx.ElementContainsCssClass(link, ASPx.AccessibilityMarkerClass)) 11038 return; 11039 ASPx.AssignAccessibilityEventsToLinkCore(link, clearFocusedStateOnMouseOut); 11040}; 11041ASPx.AssignAccessibilityEventsToLinkCore = function (link, clearFocusedStateOnMouseOut) { 11042 ASPx.Evt.AttachEventToElement(link, "focus", function (e) { ASPx.UpdateFocusedState(e); }); 11043 var clearFocusedStateHandler = function (e) { ASPx.ClearFocusedState(e); }; 11044 ASPx.Evt.AttachEventToElement(link, "blur", clearFocusedStateHandler); 11045 if(clearFocusedStateOnMouseOut) 11046 ASPx.Evt.AttachEventToElement(link, "mouseout", clearFocusedStateHandler); 11047}; 11048ASPx.Evt.AttachEventToDocument("mousemove", function(evt) { 11049 if(ASPx.classesScriptParsed && ASPx.StateItemsExist) 11050 aspxGetStateController().OnMouseMove(evt, true); 11051}); 11052ASPx.Evt.AttachEventToDocument(ASPx.TouchUIHelper.touchMouseDownEventName, function(evt) { 11053 if(ASPx.classesScriptParsed && ASPx.StateItemsExist) 11054 aspxGetStateController().OnMouseDown(evt); 11055}); 11056ASPx.Evt.AttachEventToDocument(ASPx.TouchUIHelper.touchMouseUpEventName, function(evt) { 11057 if(ASPx.classesScriptParsed && ASPx.StateItemsExist) 11058 aspxGetStateController().OnMouseUp(evt); 11059}); 11060ASPx.Evt.AttachEventToDocument("mouseover", function(evt) { 11061 if(ASPx.classesScriptParsed && ASPx.StateItemsExist) 11062 aspxGetStateController().OnMouseOver(evt); 11063}); 11064ASPx.Evt.AttachEventToDocument("keydown", function(evt) { 11065 if(ASPx.classesScriptParsed && ASPx.StateItemsExist) 11066 aspxGetStateController().OnKeyDown(evt); 11067}); 11068ASPx.Evt.AttachEventToDocument("selectstart", function(evt) { 11069 if(ASPx.classesScriptParsed && ASPx.StateItemsExist) 11070 return aspxGetStateController().OnSelectStart(evt); 11071}); 11072ASPx.GetStateController = aspxGetStateController;
11073ASPx.StateItem = ASPxStateItem; 11074})(); 11075(function () { 11076 var ASPx = window.ASPx || {}; 11077 ASPx.ASPxImageLoad = {}; 11078 ASPx.ASPxImageLoad.dxDefaultLoadingImageCssClass = "dxe-loadingImage"; 11079 ASPx.ASPxImageLoad.dxDefaultLoadingImageCssClassRegexp = new RegExp("dx\\w+-loadingImage"); 11080 ASPx.ASPxImageLoad.OnLoad = function (image, customLoadingImage, isOldIE, customBackgroundImageUrl) { 11081 image.dxCustomBackgroundImageUrl = ""; 11082 image.dxShowLoadingImage = true; 11083 image.dxCustomLoadingImage = customLoadingImage; 11084 if (customBackgroundImageUrl != "") 11085 image.dxCustomBackgroundImageUrl = "url('" + customBackgroundImageUrl + "')"; 11086 ASPx.ASPxImageLoad.prepareImageBackground(image, isOldIE); 11087 ASPx.ASPxImageLoad.removeHandlers(image); 11088 image.className = image.className.replace(ASPx.ASPxImageLoad.dxDefaultLoadingImageCssClassRegexp, ""); 11089 }; 11090 ASPx.ASPxImageLoad.removeASPxImageBackground = function (image, isOldIE) { 11091 if (isOldIE) 11092 image.style.removeAttribute("background-image"); 11093 else 11094 image.style.backgroundImage = ""; 11095 }; 11096 ASPx.ASPxImageLoad.prepareImageBackground = function (image, isOldIE) { 11097 ASPx.ASPxImageLoad.removeASPxImageBackground(image, isOldIE); 11098 if (image.dxCustomBackgroundImageUrl != "") 11099 image.style.backgroundImage = image.dxCustomBackgroundImageUrl; 11100 }; 11101 ASPx.ASPxImageLoad.removeHandlers = function (image) { 11102 image.removeAttribute("onload"); 11103 image.removeAttribute("onabort"); 11104 image.removeAttribute("onerror"); 11105 }; 11106 window.ASPx = ASPx; 11107})(); 11108(function() { 11109var CheckingScriptObjectCommand = ASPx.CreateClass(null, { 11110 constructor: function(scriptName, markerObjectName) { 11111 this.scriptName = scriptName; 11112 this.markerObjectName = markerObjectName; 11113 this.isExisted = false; 11114 }, 11115 Run: function() { 11116 var markerObj = this.GetMarkerObject(); 11117 this.isExisted = !!markerObj; 11118 if(this.isExisted) 11119 markerObj.DXPatched = true; 11120 }, 11121 GetErrorMessage: function() { 11122 return this.GetErrorMessageCore(true); 11123 }, 11124 GetErrorMessageCore: function(isScriptRequired){ 11125 var markerObj = this.GetMarkerObject(); 11126 if(this.isExisted && markerObj && markerObj.DXPatched || !isScriptRequired && !markerObj) 11127 return null; 11128 if(isScriptRequired && !this.GetMarkerObject()){ 11129 if(this.isExisted) 11130 return this.scriptName + " script was attached but has been overridden."; 11131 else 11132 return this.scriptName + " script was not attached."; 11133 } 11134 if(!this.isExisted) 11135 return this.scriptName + " script was attached after DevExpress scripts."; 11136 return this.scriptName + " script was attached multiple times and mixed up with DevExpress scripts."; 11137 }, 11138 GetMarkerObject: function() { 11139 return ASPx.GetGlobalObject(this.markerObjectName); 11140 } 11141}); 11142var PatchScriptCommand = ASPx.CreateClass(CheckingScriptObjectCommand, { 11143 constructor: function(scriptName, markerObjectName, patchMethod, required) { 11144 this.constructor.prototype.constructor.call(this, scriptName, markerObjectName); 11145 this.required = required; 11146 this.patchMethod = patchMethod; 11147 }, 11148 Run: function() { 11149 CheckingScriptObjectCommand.prototype.Run.call(this); 11150 if(this.isExisted) 11151 this.patchMethod(); 11152 }, 11153 GetErrorMessage: function() { 11154 return this.GetErrorMessageCore(this.required); 11155 } 11156});
11157var ExternalScriptProcessor = ASPx.CreateClass(null, { 11158 constructor: function() { 11159 this.commands = {}; 11160 }, 11161 Process: function(scriptName, markerObjectName, patchMethod, required) { 11162 var newCommand = this.CreateCommand(scriptName, markerObjectName, patchMethod, !!required); 11163 var oldCommand = this.commands[markerObjectName]; 11164 if(oldCommand) { 11165 if(!oldCommand.patchMethod && !newCommand.patchMethod) 11166 newCommand = null; 11167 else if(newCommand.patchMethod && (!oldCommand.patchMethod || oldCommand.required)) 11168 newCommand.required = true; 11169 else if(oldCommand.patchMethod && !newCommand.patchMethod) { 11170 oldCommand.required = true; 11171 newCommand = null; 11172 } 11173 } 11174 if(newCommand) { 11175 this.commands[markerObjectName] = newCommand; 11176 newCommand.Run(); 11177 } 11178 }, 11179 CreateCommand: function(scriptName, markerObjectName, patchMethod, required) { 11180 if(patchMethod) 11181 return new PatchScriptCommand(scriptName, markerObjectName, patchMethod, required); 11182 return new CheckingScriptObjectCommand(scriptName, markerObjectName); 11183 }, 11184 ShowErrorMessages: function() { 11185 var messages = this.GetErrorMessages(); 11186 var console = window.console; 11187 if(!messages.length || !console || !ASPx.IsFunction(console.error)) 11188 return; 11189 for(var i = 0; i < messages.length; i++) { 11190 console.error(messages[i]); 11191 } 11192 ASPx.ShowKBErrorMessage("Please check the correctness of script registration on the page. For details, see ", "T272309"); 11193 }, 11194 GetErrorMessages: function() { 11195 var messages = []; 11196 for (var key in this.commands) { 11197 if (this.commands.hasOwnProperty(key)) { 11198 var message = this.commands[key].GetErrorMessage(); 11199 if (message) 11200 messages.push(message); 11201 } 11202 } 11203 return messages; 11204 } 11205}); 11206ExternalScriptProcessor.Instance = null; 11207ExternalScriptProcessor.getInstance = function() { 11208 if(!ExternalScriptProcessor.Instance) 11209 ExternalScriptProcessor.Instance = new ExternalScriptProcessor(); 11210 return ExternalScriptProcessor.Instance; 11211}; 11212ASPx.ExternalScriptProcessor = ExternalScriptProcessor; 11213})(); 11214(function module(ASPx) { 11215ASPx.modules.Controls = module; 11216var ASPxClientBeginCallbackEventArgs = ASPx.CreateClass(ASPxClientEventArgs, { 11217 constructor: function(command){ 11218 this.constructor.prototype.constructor.call(this); 11219 this.command = command; 11220 } 11221}); 11222var ASPxClientGlobalBeginCallbackEventArgs = ASPx.CreateClass(ASPxClientBeginCallbackEventArgs, { 11223 constructor: function(control, command){ 11224 this.constructor.prototype.constructor.call(this, command); 11225 this.control = control; 11226 } 11227}); 11228var ASPxClientEndCallbackEventArgs = ASPx.CreateClass(ASPxClientEventArgs, { 11229 constructor: function(command){ 11230 this.constructor.prototype.constructor.call(this); 11231 this.command = command; 11232 } 11233}); 11234var ASPxClientGlobalEndCallbackEventArgs = ASPx.CreateClass(ASPxClientEndCallbackEventArgs, { 11235 constructor: function(control){ 11236 this.constructor.prototype.constructor.call(this); 11237 this.control = control; 11238 } 11239}); 11240var ASPxClientCustomDataCallbackEventArgs = ASPx.CreateClass(ASPxClientEventArgs, { 11241 constructor: function(result) { 11242 this.constructor.prototype.constructor.call(this); 11243 this.result = result; 11244 } 11245}); 11246var ASPxClientCallbackErrorEventArgs = ASPx.CreateClass(ASPxClientEventArgs, { 11247 constructor: function (message, callbackId) { 11248 this.constructor.prototype.constructor.call(this); 11249 this.message = message; 11250 this.handled = false; 11251 this.callbackId = callbackId; 11252 } 11253}); 11254var ASPxClientGlobalCallbackErrorEventArgs = ASPx.CreateClass(ASPxClientCallbackErrorEventArgs, { 11255 constructor: function (control, message, callbackId) { 11256 this.constructor.prototype.constructor.call(this, message, callbackId); 11257 this.control = control; 11258 } 11259}); 11260var ASPxClientValidationCompletedEventArgs = ASPx.CreateClass(ASPxClientEventArgs, { 11261 constructor: function (container, validationGroup, invisibleControlsValidated, isValid, firstInvalidControl, firstVisibleInvalidControl) { 11262 this.constructor.prototype.constructor.call(this); 11263 this.container = container; 11264 this.validationGroup = validationGroup; 11265 this.invisibleControlsValidated = invisibleControlsValidated; 11266 this.isValid = isValid; 11267 this.firstInvalidControl = firstInvalidControl;
11268 this.firstVisibleInvalidControl = firstVisibleInvalidControl; 11269 } 11270}); 11271var ASPxClientControlsInitializedEventArgs = ASPx.CreateClass(ASPxClientEventArgs, { 11272 constructor: function(isCallback) { 11273 this.isCallback = isCallback; 11274 } 11275}); 11276var ASPxClientControlBeforePronounceEventArgs = ASPx.CreateClass(ASPxClientEventArgs, { 11277 constructor: function(messageParts, control){ 11278 this.constructor.prototype.constructor.call(this); 11279 this.messageParts = messageParts; 11280 this.control = control; 11281 } 11282}); 11283var ASPxClientControlUnloadEventArgs = ASPx.CreateClass(ASPxClientEventArgs, { 11284 constructor: function(control){ 11285 this.constructor.prototype.constructor.call(this); 11286 this.control = control; 11287 } 11288}); 11289var ASPxClientEndFocusEventArgs = ASPx.CreateClass(ASPxClientEventArgs, { 11290 constructor: function(item) { 11291 this.constructor.prototype.constructor.call(this); 11292 this.item = item; 11293 } 11294}); 11295var ASPxClientItemFocusedEventArgs = ASPx.CreateClass(ASPxClientEventArgs, { 11296 constructor: function(item) { 11297 this.constructor.prototype.constructor.call(this); 11298 this.item = item; 11299 } 11300}); 11301var BeforeInitCallbackEventArgs = ASPx.CreateClass(ASPxClientEventArgs, { 11302 constructor: function(callbackOwnerID){ 11303 this.constructor.prototype.constructor.call(this); 11304 this.callbackOwnerID = callbackOwnerID; 11305 } 11306}); 11307var ASPxClientBrowserWindowResizedInternalEventArgs = ASPx.CreateClass(ASPxClientEventArgs, { 11308 constructor: function(eventInfo) { 11309 this.constructor.prototype.constructor.call(this); 11310 this.htmlEvent = eventInfo.htmlEvent; 11311 this.windowClientWidth = eventInfo.wndWidth; 11312 this.windowClientHeigth = eventInfo.wndHeight; 11313 this.previousWindowClientWidth = eventInfo.prevWndWidth; 11314 this.previousWindowClientHeight = eventInfo.prevWndHeight; 11315 this.virtualKeyboardShownOnAndroid = eventInfo.virtualKeyboardShownOnAndroid; 11316 } 11317}); 11318ASPx.createControl = function(type, name, windowName, properties, events, setupMethod, data){ 11319 var globalName = windowName && windowName.length > 0 ? windowName : name; 11320 var dxo = new type(name); 11321 var haveWrapper = ASPx.Platform === "NETCORE" && dxo.createWrapper && !DevExpress.AspNetCore.Internal.BackwardCompatibility.useLegacyClientAPI; 11322 if(haveWrapper) { 11323 window[globalName] = dxo.createWrapper(); 11324 dxo.aspNetCoreWrapperInstance = window[globalName]; 11325 } 11326 else 11327 dxo.InitGlobalVariable(globalName); 11328 if(properties) 11329 dxo.SetProperties(properties); 11330 if(events) 11331 dxo.SetEvents(events); 11332 if(setupMethod) 11333 setupMethod.call(dxo); 11334 if(data) 11335 dxo.SetData(data); 11336 dxo.AfterCreate(); 11337}; 11338var ASPxClientControlBase = ASPx.CreateClass(null, { 11339 constructor: function(name){ 11340 this.name = name; 11341 this.uniqueID = name; 11342 this.globalName = name; 11343 this.stateObject = null; 11344 this.needEncodeState = true; 11345 this.encodeHtml = true; 11346 this.enabled = true; 11347 this.clientEnabled = true; 11348 this.savedClientEnabled = true; 11349 this.clientVisible = true; 11350 this.accessibilityCompliant = false; 11351 this.parseJSPropertiesOnCallbackError = false; 11352 this.autoPostBack = false; 11353 this.allowMultipleCallbacks = true; 11354 this.callBack = null; 11355 this.enableCallbackAnimation = false; 11356 this.enableSlideCallbackAnimation = false; 11357 this.slideAnimationDirection = null;
11358 this.beginCallbackAnimationProcessing = false; 11359 this.endCallbackAnimationProcessing = false; 11360 this.savedCallbackResult = null; 11361 this.savedCallbacks = null; 11362 this.isCallbackAnimationPrevented = false; 11363 this.lpDelay = 300; 11364 this.lpTimer = -1; 11365 this.requestCount = 0; 11366 this.enableSwipeGestures = false; 11367 this.disableSwipeGestures = false; 11368 this.supportGestures = false; 11369 this.repeatedGestureValue = 0; 11370 this.repeatedGestureCount = 0; 11371 this.isInitialized = false; 11372 this.initialFocused = false; 11373 this.leadingAfterInitCall = ASPxClientControl.LeadingAfterInitCallConsts.None; 11374 this.serverEvents = []; 11375 this.loadingPanelElement = null; 11376 this.loadingDivElement = null; 11377 this.hasPhantomLoadingElements = false; 11378 this.mainElement = null; 11379 this.touchUIMouseScroller = null; 11380 this.hiddenFields = {}; 11381 this.scPrefix = "dx"; 11382 this.callbackHandlersQueue = new ASPx.ControlCallbackHandlersQueue(this); 11383 this.callbackCommand = {}; 11384 this.currentCallbackID = -1; 11385 this.InitializeIntersectionObserversManager(); 11386 this.Init = new ASPxClientEvent(); 11387 this.BeginCallback = new ASPxClientEvent(); 11388 this.EndCallback = new ASPxClientEvent(); 11389 this.EndCallbackAnimationStart = new ASPxClientEvent(); 11390 this.CallbackError = new ASPxClientEvent(); 11391 this.CustomDataCallback = new ASPxClientEvent(); 11392 this.BeforePronounce = new ASPxClientEvent(); 11393 this.Unload = new ASPxClientEvent(); 11394 aspxGetControlCollection().Add(this); 11395 }, 11396 Initialize: function() { 11397 if(this.callBack != null) 11398 this.InitializeCallBackData(); 11399 if (this.useCallbackQueue()) 11400 this.callbackQueueHelper = new ASPx.ControlCallbackQueueHelper(this); 11401 ASPx.AccessibilityUtils.createAccessibleBackgrounds(this); 11402 if(this.accessibilityCompliant) 11403 ASPx.AccessibilityPronouncer.EnsureInitialize(); 11404 }, 11405 FinalizeInitialization: function() { }, 11406 InlineInitialize: function() { 11407 this.savedClientEnabled = this.clientEnabled; 11408 }, 11409 InitializeGestures: function() { 11410 if(this.isSwipeGesturesEnabled() && this.supportGestures) { 11411 ASPx.GesturesHelper.AddSwipeGestureHandler(this.name, 11412 function() { return this.GetCallbackAnimationElement(); }.aspxBind(this), 11413 function(evt) { return this.CanHandleGestureCore(evt); }.aspxBind(this), 11414 function(value) { return this.AllowStartGesture(value); }.aspxBind(this), 11415 function(value) { return this.StartGesture(); }.aspxBind(this), 11416 function(value) { return this.AllowExecuteGesture(value); }.aspxBind(this), 11417 function(value) { this.ExecuteGesture(value); }.aspxBind(this), 11418 function(value) { this.CancelGesture(value); }.aspxBind(this), 11419 this.GetDefaultanimationEngineType(), 11420 this.rtl 11421 ); 11422 if(ASPx.Browser.MSTouchUI) 11423 this.touchUIMouseScroller = ASPx.MouseScroller.Create( 11424 function() { return this.GetCallbackAnimationElement(); }.aspxBind(this), 11425 function() { return null; }, 11426 function() { return this.GetCallbackAnimationElement(); }.aspxBind(this), 11427 function(element) { return this.NeedPreventTouchUIMouseScrolling(element); }.aspxBind(this), 11428 true 11429 ); 11430 } 11431 }, 11432 isSwipeGesturesEnabled: function() { 11433 return !this.disableSwipeGestures && (this.enableSwipeGestures || ASPx.Browser.TouchUI); 11434 }, 11435 isSlideCallbackAnimationEnabled: function() { 11436 return this.enableSlideCallbackAnimation || this.isSwipeGesturesEnabled(); 11437 }, 11438 InitGlobalVariable: function(varName){ 11439 if(!window) return; 11440 this.globalName = varName; 11441 window[varName] = this; 11442 }, 11443 SetElementDisplay: function(element, value, checkCurrentStyle, makeInline) { 11444 ASPx.SetElementDisplay(element, value, checkCurrentStyle, makeInline); 11445 }, 11446 SetProperties: function(properties, obj){ 11447 if(!obj) obj = this; 11448 var isAspNetCoreWrapperInstanceExist = !!obj.aspNetCoreWrapperInstance; 11449 for(var name in properties){ 11450 if(!properties.hasOwnProperty(name)) continue; 11451 obj[name] = properties[name]; 11452 if(isAspNetCoreWrapperInstanceExist && name.indexOf("cp") === 0) 11453 obj.aspNetCoreWrapperInstance[name] = properties[name]; 11454 } 11455 }, 11456 SetEvents: function(events, obj){ 11457 if(!obj) obj = this; 11458 for(var name in events){ 11459 if(events.hasOwnProperty(name) && obj[name] && obj[name].AddHandler) 11460 obj[name].AddHandler(events[name]); 11461 } 11462 }, 11463 SetData: function(data){ 11464 }, 11465 useCallbackQueue: function(){ 11466 return false; 11467 }, 11468 NeedPreventTouchUIMouseScrolling: function(element) { 11469 return false; 11470 }, 11471 InitailizeFocus: function() { 11472 if(this.initialFocused && this.IsVisible()) 11473 this.Focus(); 11474 }, 11475 AfterCreate: function() { 11476 this.AddDefaultStateControllerItems();
11477 this.InlineInitialize(); 11478 this.InitializeGestures(); 11479 }, 11480 AfterInitialize: function() { 11481 this.initializeAriaDescriptor(); 11482 this.InitailizeFocus(); 11483 this.isInitialized = true; 11484 this.RaiseInit(); 11485 if(this.savedCallbacks) { 11486 for(var i = 0; i < this.savedCallbacks.length; i++) 11487 this.CreateCallbackInternal(this.savedCallbacks[i].arg, this.savedCallbacks[i].command, 11488 false, this.savedCallbacks[i].callbackInfo); 11489 this.savedCallbacks = null; 11490 } 11491 }, 11492 InitializeCallBackData: function() { 11493 }, 11494 AtlasPreInitialize: function() { 11495 }, 11496 AtlasInitialize: function() { 11497 }, 11498 IsDOMDisposed: function() { 11499 return !ASPx.IsExistsElement(this.GetMainElement()); 11500 }, 11501 initializeAriaDescriptor: function() { 11502 if(this.ariaDescription) { 11503 var descriptionObject = ASPx.Json.Eval(this.ariaDescription); 11504 if(descriptionObject) { 11505 this.ariaDescriptor = new AriaDescriptor(this, descriptionObject); 11506 this.applyAccessibilityAttributes(this.ariaDescriptor); 11507 } 11508 } 11509 }, 11510 applyAccessibilityAttributes: function() { }, 11511 setAriaDescription: function(selector, argsList) { 11512 if(this.ariaDescriptor) 11513 this.ariaDescriptor.setDescription(selector, argsList || [[]]); 11514 }, 11515 allowRestoreFocusOnCallbacks: function(){ 11516 return this.accessibilityCompliant; 11517 }, 11518 HtmlEncode: function(text) { 11519 return this.encodeHtml ? ASPx.Str.EncodeHtml(text) : text; 11520 }, 11521 IsServerEventAssigned: function(eventName){ 11522 return ASPx.Data.ArrayIndexOf(this.serverEvents, eventName) >= 0; 11523 }, 11524 OnPost: function(args){ 11525 this.SerializeStateHiddenField(); 11526 }, 11527 SerializeStateHiddenField: function() { 11528 this.UpdateStateObject(); 11529 if(this.stateObject != null) 11530 this.UpdateStateHiddenField(); 11531 }, 11532 OnPostFinalization: function(args){ 11533 }, 11534 UpdateStateObject: function(){ 11535 }, 11536 UpdateStateObjectWithObject: function(obj){ 11537 if(!obj) return; 11538 if(!this.stateObject) 11539 this.stateObject = { }; 11540 for(var key in obj) 11541 if(obj.hasOwnProperty(key)) 11542 this.stateObject[key] = obj[key]; 11543 }, 11544 UpdateStateHiddenField: function() { 11545 var stateHiddenField = this.GetStateHiddenField(); 11546 if(stateHiddenField) { 11547 var stateObjectStr = ASPx.Json.ToJson(this.stateObject, !this.needEncodeState); 11548 stateHiddenField.value = this.needEncodeState ? ASPx.Str.EncodeHtml(stateObjectStr) : stateObjectStr; 11549 } 11550 }, 11551 GetStateHiddenField: function() { 11552 return this.GetHiddenField(this.GetStateHiddenFieldName(), this.GetStateHiddenFieldID(), 11553 this.GetStateHiddenFieldParent(), this.GetStateHiddenFieldOrigin()); 11554 }, 11555 GetStateHiddenFieldName: function() { 11556 return this.uniqueID; 11557 }, 11558 GetStateHiddenFieldID: function() { 11559 return this.name + "_State"; 11560 }, 11561 GetStateHiddenFieldOrigin: function() { 11562 return this.GetMainElement(); 11563 }, 11564 GetStateHiddenFieldParent: function() { 11565 var element = this.GetStateHiddenFieldOrigin(); 11566 return element ? element.parentNode : null; 11567 }, 11568 GetHiddenField: function(name, id, parent, beforeElement) { 11569 var hiddenField = this.hiddenFields[id]; 11570 if(!hiddenField || !ASPx.IsValidElement(hiddenField)) { 11571 if(parent) { 11572 var existingHiddenField = ASPx.GetElementById(this.GetStateHiddenFieldID()); 11573 this.hiddenFields[id] = hiddenField = existingHiddenField || ASPx.CreateHiddenField(name, id); 11574 if(existingHiddenField) 11575 return existingHiddenField; 11576 if(beforeElement) 11577 parent.insertBefore(hiddenField, beforeElement); 11578 else 11579 parent.appendChild(hiddenField); 11580 } 11581 } 11582 return hiddenField; 11583 }, 11584 GetChildElement: function(idPostfix){ 11585 var mainElement = this.GetMainElement(); 11586 if(idPostfix.charAt && idPostfix.charAt(0) !== "_") 11587 idPostfix = "_" + idPostfix; 11588 return mainElement ? ASPx.CacheHelper.GetCachedChildById(this, mainElement, this.name + idPostfix) : null; 11589 }, 11590 getChildControl: function(idPostfix) { 11591 var result = null; 11592 var childControlId = this.getChildControlUniqueID(idPostfix); 11593 ASPx.GetControlCollection().ProcessControlsInContainer(this.GetMainElement(), function(control) { 11594 if(control.uniqueID == childControlId) 11595 result = control; 11596 }); 11597 return result; 11598 }, 11599 getChildControlUniqueID: function(idPostfix) { 11600 idPostfix = idPostfix.split("_").join("$"); 11601 if(idPostfix.charAt && idPostfix.charAt(0) !== "$") 11602 idPostfix = "$" + idPostfix; 11603 return this.uniqueID + idPostfix; 11604 }, 11605 getInnerControl: function(idPostfix) { 11606 var name = this.name + idPostfix; 11607 var result = window[name]; 11608 return result && Ident.IsASPxClientControl(result) 11609 ? result 11610 : null; 11611 }, 11612 GetParentForm: function(){ 11613 return ASPx.GetParentByTagName(this.GetMainElement(), "FORM"); 11614 }, 11615 GetMainElement: function(){ 11616 if(!ASPx.IsExistsElement(this.mainElement)) 11617 this.mainElement = ASPx.GetElementById(this.GetMainElementId()); 11618 return this.mainElement; 11619 }, 11620 GetMainElementId: function() { 11621 return this.name; 11622 }, 11623 IsLoadingContainerVisible: function(){ 11624 return this.IsVisible(); 11625 }, 11626 GetLoadingPanelElement: function(){ 11627 return ASPx.GetElementById(this.name + "_LP"); 11628 }, 11629 GetClonedLoadingPanel: function(){ 11630 return document.getElementById(this.GetLoadingPanelElement().id + "V"); 11631 }, 11632 CloneLoadingPanel: function(element, parent) { 11633 var clone = element.cloneNode(true);
11634 clone.id = element.id + "V"; 11635 parent.appendChild(clone); 11636 return clone; 11637 }, 11638 CreateLoadingPanelWithoutBordersInsideContainer: function(container) { 11639 var loadingPanel = this.CreateLoadingPanelInsideContainer(container, false, true, true); 11640 var contentStyle = ASPx.GetCurrentStyle(container); 11641 if(!loadingPanel || !contentStyle) 11642 return; 11643 var elements = [ ]; 11644 var table = (loadingPanel.tagName == "TABLE") ? loadingPanel : ASPx.GetNodeByTagName(loadingPanel, "TABLE", 0); 11645 if(table != null) 11646 elements.push(table); 11647 else 11648 elements.push(loadingPanel); 11649 var cells = ASPx.GetNodesByTagName(loadingPanel, "TD"); 11650 if(!cells) cells = [ ]; 11651 for(var i = 0; i < cells.length; i++) 11652 elements.push(cells[i]); 11653 for(var i = 0; i < elements.length; i++) { 11654 var el = elements[i]; 11655 el.style.backgroundColor = contentStyle.backgroundColor; 11656 ASPx.RemoveBordersAndShadows(el); 11657 } 11658 }, 11659 CreateLoadingPanelInsideContainer: function(parentElement, hideContent, collapseHeight, collapseWidth) { 11660 if(this.ShouldHideExistingLoadingElements()) 11661 this.HideLoadingPanel(); 11662 if(parentElement == null) 11663 return null; 11664 if(!this.IsLoadingContainerVisible()) { 11665 this.hasPhantomLoadingElements = true; 11666 return null; 11667 } 11668 var element = this.GetLoadingPanelElement(); 11669 if(element != null){ 11670 var width = collapseWidth ? 0 : ASPx.GetClearClientWidth(parentElement); 11671 var height = collapseHeight ? 0 : ASPx.GetClearClientHeight(parentElement); 11672 if(hideContent){ 11673 for(var i = parentElement.childNodes.length - 1; i > -1; i--){ 11674 if(parentElement.childNodes[i].style) 11675 parentElement.childNodes[i].style.display = "none"; 11676 else if(parentElement.childNodes[i].nodeType == 3) 11677 parentElement.removeChild(parentElement.childNodes[i]); 11678 } 11679 } 11680 else 11681 parentElement.innerHTML = ""; 11682 var table = document.createElement("TABLE"); 11683 parentElement.appendChild(table); 11684 table.border = 0; 11685 table.cellPadding = 0; 11686 table.cellSpacing = 0; 11687 ASPx.SetStyles(table, { 11688 width: (width > 0) ? width : "100%", 11689 height: (height > 0) ? height : "100%" 11690 }); 11691 var tbody = document.createElement("TBODY"); 11692 table.appendChild(tbody); 11693 var tr = document.createElement("TR"); 11694 tbody.appendChild(tr); 11695 var td = document.createElement("TD"); 11696 tr.appendChild(td); 11697 td.align = "center"; 11698 td.vAlign = "middle"; 11699 element = this.CloneLoadingPanel(element, td); 11700 ASPx.SetElementDisplay(element, true); 11701 this.loadingPanelElement = element; 11702 return element; 11703 } else 11704 parentElement.innerHTML = " "; 11705 return null; 11706 }, 11707 CreateLoadingPanelWithAbsolutePosition: function(parentElement, offsetElement) { 11708 if(this.ShouldHideExistingLoadingElements()) 11709 this.HideLoadingPanel(); 11710 if(parentElement == null) 11711 return null; 11712 if(!this.IsLoadingContainerVisible()) { 11713 this.hasPhantomLoadingElements = true; 11714 return null; 11715 } 11716 if(!offsetElement) 11717 offsetElement = parentElement; 11718 var element = this.GetLoadingPanelElement(); 11719 if(element != null) { 11720 element = this.CloneLoadingPanel(element, parentElement); 11721 ASPx.SetStyles(element, { 11722 position: "absolute" 11723 }); 11724 ASPx.SetElementDisplay(element, true); 11725 ASPx.Evt.AttachEventToElement(element, ASPx.Evt.GetMouseWheelEventName(), ASPx.Evt.PreventEvent); 11726 this.SetLoadingPanelLocation(offsetElement, element); 11727 this.loadingPanelElement = element; 11728 return element; 11729 } 11730 return null; 11731 }, 11732 CreateLoadingPanelInline: function(parentElement, centerInParent){ 11733 if(this.ShouldHideExistingLoadingElements()) 11734 this.HideLoadingPanel(); 11735 if(parentElement == null) 11736 return null; 11737 if(!this.IsLoadingContainerVisible()) { 11738 this.hasPhantomLoadingElements = true; 11739 return null; 11740 } 11741 var element = this.GetLoadingPanelElement(); 11742 if(element != null) { 11743 element = this.CloneLoadingPanel(element, parentElement); 11744 if(centerInParent){ 11745 ASPx.SetElementDisplay(element, true); 11746 parentElement.style.textAlign = "center"; 11747 } 11748 else 11749 ASPx.SetElementDisplay(element, true); 11750 this.loadingPanelElement = element; 11751 return element; 11752 } 11753 return null; 11754 }, 11755 ShowLoadingPanel: function() { 11756 }, 11757 ShowLoadingElements: function() { 11758 if(this.InCallback() || this.lpTimer > -1) return; 11759 this.ShowLoadingDiv();
11760 if(this.IsCallbackAnimationEnabled()) 11761 this.StartBeginCallbackAnimation(); 11762 else 11763 this.ShowLoadingElementsInternal(); 11764 }, 11765 ShowLoadingElementsInternal: function() { 11766 if(this.lpDelay > 0 && !this.IsCallbackAnimationEnabled()) 11767 this.lpTimer = window.setTimeout(function() { 11768 this.ShowLoadingPanelOnTimer(); 11769 }.aspxBind(this), this.lpDelay); 11770 else { 11771 this.RestoreLoadingDivOpacity(); 11772 this.ShowLoadingPanel(); 11773 } 11774 }, 11775 GetLoadingPanelOffsetElement: function (baseElement) { 11776 if(this.IsCallbackAnimationEnabled()) { 11777 var element = this.GetLoadingPanelCallbackAnimationOffsetElement(); 11778 if(element) { 11779 var container = typeof(ASPx.AnimationHelper) != "undefined" ? ASPx.AnimationHelper.findSlideAnimationContainer(element) : null; 11780 if(container) 11781 return container.parentNode.parentNode; 11782 else 11783 return element; 11784 } 11785 } 11786 return baseElement; 11787 }, 11788 GetLoadingPanelCallbackAnimationOffsetElement: function () { 11789 return this.GetCallbackAnimationElement(); 11790 }, 11791 IsCallbackAnimationEnabled: function () { 11792 return (this.enableCallbackAnimation || this.isSlideCallbackAnimationEnabled()) && !this.isCallbackAnimationPrevented; 11793 }, 11794 GetDefaultanimationEngineType: function() { 11795 return ASPx.AnimationEngineType.DEFAULT; 11796 },
11797 StartBeginCallbackAnimation: function () { 11798 this.beginCallbackAnimationProcessing = true; 11799 this.isCallbackFinished = false; 11800 var element = this.GetCallbackAnimationElement(); 11801 if (element && this.isSlideCallbackAnimationEnabled() && this.slideAnimationDirection) 11802 ASPx.AnimationHelper.slideOut(element, this.slideAnimationDirection, this.FinishBeginCallbackAnimation.aspxBind(this), this.GetDefaultanimationEngineType(), this.rtl); 11803 else if(element && this.enableCallbackAnimation) 11804 ASPx.AnimationHelper.fadeOut(element, this.FinishBeginCallbackAnimation.aspxBind(this), null, ASPx.AnimationEngineType.JS); 11805 else 11806 this.FinishBeginCallbackAnimation(); 11807 }, 11808 CancelBeginCallbackAnimation: function() { 11809 if(this.beginCallbackAnimationProcessing) { 11810 this.beginCallbackAnimationProcessing = false; 11811 var element = this.GetCallbackAnimationElement(); 11812 ASPx.AnimationHelper.cancelAnimation(element); 11813 } 11814 }, 11815 FinishBeginCallbackAnimation: function () { 11816 this.beginCallbackAnimationProcessing = false; 11817 if(!this.isCallbackFinished) 11818 this.ShowLoadingElementsInternal(); 11819 else { 11820 this.DoCallback(this.savedCallbackResult); 11821 this.savedCallbackResult = null; 11822 } 11823 },
11824 CheckBeginCallbackAnimationInProgress: function(callbackResult) { 11825 if(this.beginCallbackAnimationProcessing) { 11826 this.savedCallbackResult = callbackResult; 11827 this.isCallbackFinished = true; 11828 return true; 11829 } 11830 return false; 11831 }, 11832 StartEndCallbackAnimation: function () { 11833 this.HideLoadingPanel(); 11834 this.SetInitialLoadingDivOpacity(); 11835 this.RaiseEndCallbackAnimationStart(); 11836 this.endCallbackAnimationProcessing = true; 11837 var element = this.GetCallbackAnimationElement(); 11838 if(element && this.isSlideCallbackAnimationEnabled() && this.slideAnimationDirection) 11839 ASPx.AnimationHelper.slideIn(element, this.slideAnimationDirection, this.FinishEndCallbackAnimation.aspxBind(this), this.GetDefaultanimationEngineType(), this.rtl); 11840 else if(element && this.enableCallbackAnimation) 11841 ASPx.AnimationHelper.fadeIn(element, this.FinishEndCallbackAnimation.aspxBind(this), null, ASPx.AnimationEngineType.JS); 11842 else 11843 this.FinishEndCallbackAnimation(); 11844 this.slideAnimationDirection = null; 11845 }, 11846 FinishEndCallbackAnimation: function () { 11847 this.DoEndCallback(); 11848 this.endCallbackAnimationProcessing = false; 11849 this.CheckRepeatGesture(); 11850 }, 11851 CheckEndCallbackAnimationNeeded: function() { 11852 if(!this.endCallbackAnimationProcessing && this.requestCount == 1) { 11853 this.StartEndCallbackAnimation(); 11854 return true; 11855 } 11856 return false; 11857 }, 11858 PreventCallbackAnimation: function() { 11859 this.isCallbackAnimationPrevented = true; 11860 }, 11861 GetCallbackAnimationElement: function() { 11862 return null; 11863 }, 11864 AssignSlideAnimationDirectionByPagerArgument: function(arg, currentPageIndex) { 11865 this.slideAnimationDirection = null; 11866 if(this.isSlideCallbackAnimationEnabled() && typeof(ASPx.AnimationHelper) != "undefined") { 11867 if(arg == PagerCommands.Next || arg == PagerCommands.Last) 11868 this.slideAnimationDirection = ASPx.AnimationHelper.SLIDE_LEFT_DIRECTION; 11869 else if(arg == PagerCommands.First || arg == PagerCommands.Prev) 11870 this.slideAnimationDirection = ASPx.AnimationHelper.SLIDE_RIGHT_DIRECTION; 11871 else if(!isNaN(currentPageIndex) && arg.indexOf(PagerCommands.PageNumber) == 0) { 11872 var newPageIndex = parseInt(arg.substring(2)); 11873 if (!isNaN(newPageIndex)) { 11874 var leftDir = this.rtl ? ASPx.AnimationHelper.SLIDE_LEFT_DIRECTION : ASPx.AnimationHelper.SLIDE_RIGHT_DIRECTION; 11875 var rightDir = this.rtl ? ASPx.AnimationHelper.SLIDE_RIGHT_DIRECTION : ASPx.AnimationHelper.SLIDE_LEFT_DIRECTION; 11876 this.slideAnimationDirection = newPageIndex < currentPageIndex ? leftDir : rightDir; 11877 } 11878 } 11879 } 11880 }, 11881 TryShowPhantomLoadingElements: function () { 11882 if(this.hasPhantomLoadingElements && this.InCallback()) { 11883 this.hasPhantomLoadingElements = false; 11884 this.ShowLoadingDivAndPanel(); 11885 } 11886 }, 11887 ShowLoadingDivAndPanel: function () { 11888 this.ShowLoadingDiv(); 11889 this.RestoreLoadingDivOpacity(); 11890 this.ShowLoadingPanel(); 11891 }, 11892 HideLoadingElements: function() {
11893 this.CancelBeginCallbackAnimation(); 11894 this.HideLoadingPanel(); 11895 this.HideLoadingDiv(); 11896 }, 11897 ShowLoadingPanelOnTimer: function() { 11898 this.ClearLoadingPanelTimer(); 11899 if(!this.IsDOMDisposed()) { 11900 this.RestoreLoadingDivOpacity(); 11901 this.ShowLoadingPanel(); 11902 } 11903 }, 11904 ClearLoadingPanelTimer: function() { 11905 this.lpTimer = ASPx.Timer.ClearTimer(this.lpTimer); 11906 }, 11907 HideLoadingPanel: function() { 11908 this.ClearLoadingPanelTimer(); 11909 this.hasPhantomLoadingElements = false; 11910 if(ASPx.IsExistsElement(this.loadingPanelElement)) { 11911 ASPx.RemoveElement(this.loadingPanelElement); 11912 this.loadingPanelElement = null; 11913 } 11914 }, 11915 SetLoadingPanelLocation: function(offsetElement, loadingPanel, x, y, offsetX, offsetY) { 11916 if(!ASPx.IsExists(x) || !ASPx.IsExists(y)){ 11917 var x1 = ASPx.GetAbsoluteX(offsetElement); 11918 var y1 = ASPx.GetAbsoluteY(offsetElement); 11919 var x2 = x1; 11920 var y2 = y1; 11921 if(offsetElement == document.body) { 11922 x1 = 0; 11923 y1 = 0; 11924 x2 = ASPx.GetDocumentMaxClientWidth(); 11925 y2 = ASPx.GetDocumentMaxClientHeight(); 11926 } 11927 else{ 11928 x2 += offsetElement.offsetWidth; 11929 y2 += offsetElement.offsetHeight; 11930 } 11931 if(x1 < ASPx.GetDocumentScrollLeft()) 11932 x1 = ASPx.GetDocumentScrollLeft(); 11933 if(y1 < ASPx.GetDocumentScrollTop()) 11934 y1 = ASPx.GetDocumentScrollTop(); 11935 if(x2 > ASPx.GetDocumentScrollLeft() + ASPx.GetDocumentClientWidth()) 11936 x2 = ASPx.GetDocumentScrollLeft() + ASPx.GetDocumentClientWidth(); 11937 if(y2 > ASPx.GetDocumentScrollTop() + ASPx.GetDocumentClientHeight()) 11938 y2 = ASPx.GetDocumentScrollTop() + ASPx.GetDocumentClientHeight(); 11939 x = x1 + ((x2 - x1 - loadingPanel.offsetWidth) / 2); 11940 y = y1 + ((y2 - y1 - loadingPanel.offsetHeight) / 2); 11941 } 11942 if(ASPx.IsExists(offsetX) && ASPx.IsExists(offsetY)){ 11943 x += offsetX; 11944 y += offsetY; 11945 } 11946 x = ASPx.PrepareClientPosForElement(x, loadingPanel, true); 11947 y = ASPx.PrepareClientPosForElement(y, loadingPanel, false); 11948 if(ASPx.Browser.IE && ASPx.Browser.Version > 8) { 11949 x = Math.round(x); 11950 y = Math.round(y); 11951 } 11952 ASPx.SetStyles(loadingPanel, { left: x, top: y }); 11953 }, 11954 GetLoadingDiv: function(){ 11955 return ASPx.GetElementById(this.name + "_LD"); 11956 }, 11957 CreateLoadingDiv: function(parentElement, offsetElement){ 11958 if(this.ShouldHideExistingLoadingElements()) 11959 this.HideLoadingDiv(); 11960 if(parentElement == null) 11961 return null; 11962 if(!this.IsLoadingContainerVisible()) { 11963 this.hasPhantomLoadingElements = true; 11964 return null; 11965 } 11966 if(!offsetElement) 11967 offsetElement = parentElement; 11968 var div = this.GetLoadingDiv(); 11969 if(div != null){ 11970 div = div.cloneNode(true); 11971 parentElement.appendChild(div); 11972 ASPx.SetElementDisplay(div, true); 11973 ASPx.Evt.AttachEventToElement(div, ASPx.TouchUIHelper.touchMouseDownEventName, ASPx.Evt.PreventEvent); 11974 ASPx.Evt.AttachEventToElement(div, ASPx.TouchUIHelper.touchMouseMoveEventName, ASPx.Evt.PreventEvent); 11975 ASPx.Evt.AttachEventToElement(div, ASPx.TouchUIHelper.touchMouseUpEventName, ASPx.Evt.PreventEvent); 11976 ASPx.Evt.AttachEventToElement(div, ASPx.Evt.GetMouseWheelEventName(), ASPx.Evt.PreventEvent); 11977 this.SetLoadingDivBounds(offsetElement, div); 11978 this.loadingDivElement = div; 11979 this.SetInitialLoadingDivOpacity(); 11980 return div; 11981 } 11982 return null; 11983 }, 11984 SetInitialLoadingDivOpacity: function() { 11985 if(!this.loadingDivElement) return; 11986 ASPx.Attr.SaveStyleAttribute(this.loadingDivElement, "opacity"); 11987 ASPx.Attr.SaveStyleAttribute(this.loadingDivElement, "filter"); 11988 ASPx.SetElementOpacity(this.loadingDivElement, 0.01); 11989 }, 11990 RestoreLoadingDivOpacity: function() { 11991 if(!this.loadingDivElement) return; 11992 ASPx.Attr.RestoreStyleAttribute(this.loadingDivElement, "opacity"); 11993 ASPx.Attr.RestoreStyleAttribute(this.loadingDivElement, "filter"); 11994 }, 11995 SetLoadingDivBounds: function(offsetElement, loadingDiv) { 11996 var absX = (offsetElement == document.body) ? 0 : ASPx.GetAbsoluteX(offsetElement); 11997 var absY = (offsetElement == document.body) ? 0 : ASPx.GetAbsoluteY(offsetElement); 11998 ASPx.SetStyles(loadingDiv, { 11999 left: ASPx.PrepareClientPosForElement(absX, loadingDiv, true), 12000 top: ASPx.PrepareClientPosForElement(absY, loadingDiv, false) 12001 }); 12002 var width = (offsetElement == document.body) ? ASPx.GetDocumentWidth() : offsetElement.offsetWidth; 12003 var height = (offsetElement == document.body) ? ASPx.GetDocumentHeight() : offsetElement.offsetHeight; 12004 if(height < 0) 12005 height = 0; 12006 ASPx.SetStyles(loadingDiv, { width: width, height: height });
12007 var correctedWidth = 2 * width - loadingDiv.offsetWidth; 12008 if(correctedWidth <= 0) correctedWidth = width; 12009 var correctedHeight = 2 * height - loadingDiv.offsetHeight; 12010 if(correctedHeight <= 0) correctedHeight = height; 12011 ASPx.SetStyles(loadingDiv, { width: correctedWidth, height: correctedHeight }); 12012 }, 12013 ShowLoadingDiv: function() { 12014 }, 12015 HideLoadingDiv: function() { 12016 this.hasPhantomLoadingElements = false; 12017 if(ASPx.IsExistsElement(this.loadingDivElement)){ 12018 ASPx.RemoveElement(this.loadingDivElement); 12019 this.loadingDivElement = null; 12020 } 12021 }, 12022 CanHandleGesture: function(evt) { 12023 return false; 12024 }, 12025 CanHandleGestureCore: function(evt) { 12026 var source = ASPx.Evt.GetEventSource(evt); 12027 if(ASPx.GetIsParent(this.loadingPanelElement, source) || ASPx.GetIsParent(this.loadingDivElement, source)) 12028 return true; 12029 var callbackAnimationElement = this.GetCallbackAnimationElement(); 12030 if(!callbackAnimationElement) 12031 return false; 12032 var animationContainer = ASPx.AnimationHelper.getSlideAnimationContainer(callbackAnimationElement, false, false); 12033 if(animationContainer && ASPx.GetIsParent(animationContainer, source) && !ASPx.GetIsParent(animationContainer.childNodes[0], source)) 12034 return true; 12035 return this.CanHandleGesture(evt); 12036 }, 12037 AllowStartGesture: function() {
12038 return !this.beginCallbackAnimationProcessing && !this.endCallbackAnimationProcessing; 12039 }, 12040 StartGesture: function() { 12041 }, 12042 AllowExecuteGesture: function(value) { 12043 return false; 12044 }, 12045 ExecuteGesture: function(value) { 12046 }, 12047 CancelGesture: function(value) { 12048 if(this.repeatedGestureCount === 0) { 12049 this.repeatedGestureValue = value; 12050 this.repeatedGestureCount = 1; 12051 } 12052 else { 12053 if(this.repeatedGestureValue * value > 0) 12054 this.repeatedGestureCount++; 12055 else 12056 this.repeatedGestureCount--; 12057 if(this.repeatedGestureCount === 0) 12058 this.repeatedGestureCount = 0; 12059 } 12060 }, 12061 CheckRepeatGesture: function() { 12062 if(this.repeatedGestureCount !== 0) { 12063 if(this.AllowExecuteGesture(this.repeatedGestureValue)) 12064 this.ExecuteGesture(this.repeatedGestureValue, this.repeatedGestureCount); 12065 this.repeatedGestureValue = 0; 12066 this.repeatedGestureCount = 0; 12067 } 12068 }, 12069 AllowExecutePagerGesture: function (pageIndex, pageCount, value) { 12070 if(pageIndex < 0) return false; 12071 if(pageCount <= 1) return false; 12072 if(value > 0 && pageIndex === 0) return false; 12073 if(value < 0 && pageIndex === pageCount - 1) return false; 12074 return true; 12075 }, 12076 ExecutePagerGesture: function(pageIndex, pageCount, value, count, method) { 12077 if(!count) count = 1; 12078 var pageIndex = pageIndex + (value < 0 ? count : -count); 12079 if(pageIndex < 0) pageIndex = 0; 12080 if(pageIndex > pageCount - 1) pageIndex = pageCount - 1; 12081 method(PagerCommands.PageNumber + pageIndex); 12082 }, 12083 RaiseInit: function(){ 12084 if(!this.Init.IsEmpty()){ 12085 var args = new ASPxClientEventArgs(); 12086 this.Init.FireEvent(this, args); 12087 } 12088 }, 12089 RaiseBeginCallbackInternal: function(command){ 12090 if(!this.BeginCallback.IsEmpty()){ 12091 var args = new ASPxClientBeginCallbackEventArgs(command); 12092 this.BeginCallback.FireEvent(this, args); 12093 } 12094 }, 12095 RaiseEndCallbackInternal: function(command) { 12096 if(!this.EndCallback.IsEmpty()){ 12097 var args = new ASPxClientEndCallbackEventArgs(command); 12098 this.EndCallback.FireEvent(this, args); 12099 } 12100 }, 12101 RaiseCallbackErrorInternal: function(message, callbackId) { 12102 if(!this.CallbackError.IsEmpty()) { 12103 var args = new ASPxClientCallbackErrorEventArgs(message, callbackId); 12104 this.CallbackError.FireEvent(this, args); 12105 if(args.handled) 12106 return { isHandled: true, errorMessage: args.message }; 12107 } 12108 }, 12109 RaiseBeginCallback: function(command){ 12110 this.RaiseBeginCallbackInternal(command); 12111 aspxGetControlCollection().RaiseBeginCallback(this, command); 12112 }, 12113 RaiseEndCallback: function(command){ 12114 this.RaiseEndCallbackInternal(command); 12115 aspxGetControlCollection().RaiseEndCallback(this, command); 12116 }, 12117 RaiseCallbackError: function (message, callbackId) { 12118 var result = this.RaiseCallbackErrorInternal(message, callbackId); 12119 if(!result) 12120 result = aspxGetControlCollection().RaiseCallbackError(this, message, callbackId); 12121 return result; 12122 }, 12123 RaiseEndCallbackAnimationStart: function(){ 12124 if(!this.EndCallbackAnimationStart.IsEmpty()){ 12125 var args = new ASPxClientEventArgs(); 12126 this.EndCallbackAnimationStart.FireEvent(this, args); 12127 } 12128 }, 12129 RaiseBeforePronounce: function(message) { 12130 var args = new ASPxClientControlBeforePronounceEventArgs(message, this); 12131 if(!this.BeforePronounce.IsEmpty()) 12132 this.BeforePronounce.FireEvent(this, args); 12133 return args; 12134 }, 12135 RaiseUnload: function() { 12136 var args = new ASPxClientControlUnloadEventArgs(this); 12137 if(!this.Unload.IsEmpty()) 12138 this.Unload.FireEvent(this, args); 12139 }, 12140 SendMessageToAssistiveTechnology: function(message) { 12141 if(!this.accessibilityCompliant) 12142 return; 12143 this.PronounceMessageInternal(message, ASPx.AccessibilityPronouncerType.live); 12144 }, 12145 PronounceMessageInternal: function(messageArg, type) { 12146 var message = messageArg; 12147 if(!ASPx.Ident.IsArray(messageArg)) 12148 message = [messageArg]; 12149 var args = this.RaiseBeforePronounce(message); 12150 ASPx.AccessibilityPronouncer.Pronounce(args, type); 12151 }, 12152 IsVisible: function() { 12153 var element = this.GetMainElement(); 12154 return ASPx.IsElementVisible(element); 12155 }, 12156 IsDisplayedElement: function(element) { 12157 while(element && element.tagName != "BODY") { 12158 if(!ASPx.GetElementDisplay(element)) 12159 return false; 12160 element = element.parentNode; 12161 } 12162 return true; 12163 }, 12164 IsDisplayed: function() { 12165 return this.IsDisplayedElement(this.GetMainElement()); 12166 }, 12167 IsHiddenElement: function(element) { 12168 return element && element.offsetWidth == 0 && element.offsetHeight == 0; 12169 }, 12170 IsHidden: function() { 12171 return this.IsHiddenElement(this.GetMainElement()); 12172 }, 12173 IsDisposed: function() { 12174 return this.disposed; 12175 }, 12176 GetParentControl: function() { 12177 var mainElement = this.getActualMainElement(); 12178 var popupPostfix = ASPx.PCWIdSuffix + "-1"; 12179 var result = null; 12180 ASPx.GetParent(mainElement, function(element) {
12181 if(element === mainElement || !element.id) 12182 return false; 12183 var controlName = element.id.replace(popupPostfix, ""); 12184 result = ASPx.GetControlCollection().Get(controlName); 12185 return !!result; 12186 }); 12187 return result; 12188 }, 12189 getActualMainElement: function() { return this.GetMainElement(); }, 12190 findParentByType: function (type) { 12191 var ctrl = this; 12192 while (ctrl) { 12193 var parent = ctrl.GetParentControl(); 12194 if (parent && parent instanceof type) 12195 return parent; 12196 ctrl = parent; 12197 } 12198 return null; 12199 }, 12200 Focus: function() { 12201 }, 12202 GetClientVisible: function(){ 12203 return this.GetVisible(); 12204 }, 12205 SetClientVisible: function(visible){ 12206 this.SetVisible(visible); 12207 }, 12208 GetVisible: function(){ 12209 return this.clientVisible; 12210 }, 12211 SetVisible: function(visible){ 12212 if(this.clientVisible != visible){ 12213 this.clientVisible = visible; 12214 ASPx.SetElementDisplay(this.GetMainElement(), visible); 12215 if(visible) { 12216 this.AdjustControl(); 12217 var mainElement = this.GetMainElement(); 12218 if(mainElement) 12219 aspxGetControlCollection().AdjustControls(mainElement); 12220 } 12221 } 12222 }, 12223 GetEnabled: function() { 12224 return this.clientEnabled; 12225 }, 12226 SetEnabled: function(enabled) { 12227 this.clientEnabled = enabled; 12228 if(ASPxClientControl.setEnabledLocked) 12229 return; 12230 else
12231 ASPxClientControl.setEnabledLocked = true; 12232 this.savedClientEnabled = enabled; 12233 aspxGetControlCollection().ProcessControlsInContainer(this.GetMainElement(), function(control) { 12234 if(ASPx.IsFunction(control.SetEnabled)) 12235 control.SetEnabled(enabled && control.savedClientEnabled); 12236 }); 12237 delete ASPxClientControl.setEnabledLocked; 12238 }, 12239 InCallback: function() { 12240 return this.requestCount > 0; 12241 }, 12242 DoBeginCallback: function(command) { 12243 this.RaiseBeginCallback(command || ""); 12244 aspxGetControlCollection().Before_WebForm_InitCallback(this.name); 12245 if(typeof(WebForm_InitCallback) != "undefined" && WebForm_InitCallback) { 12246 __theFormPostData = ""; 12247 __theFormPostCollection = [ ]; 12248 this.ClearPostBackEventInput("__EVENTTARGET"); 12249 this.ClearPostBackEventInput("__EVENTARGUMENT"); 12250 WebForm_InitCallback(); 12251 this.savedFormPostData = __theFormPostData; 12252 this.savedFormPostCollection = __theFormPostCollection; 12253 } 12254 }, 12255 ClearPostBackEventInput: function(id){ 12256 var element = ASPx.GetElementById(id); 12257 if(element != null) element.value = ""; 12258 }, 12259 PerformDataCallback: function(arg, handler) { 12260 this.CreateCustomDataCallback(arg, "", handler); 12261 }, 12262 sendCallbackViaQueue: function (prefix, arg, showLoadingPanel, context, handler, onBeforeSend) { 12263 if (!this.useCallbackQueue()) 12264 return false; 12265 var context = context || this; 12266 var token = this.callbackQueueHelper.sendCallback(ASPx.FormatCallbackArg(prefix, arg), context, handler || context.OnCallback, prefix, onBeforeSend); 12267 if (showLoadingPanel) 12268 this.callbackQueueHelper.showLoadingElements(); 12269 return token; 12270 }, 12271 CreateCallback: function (arg, command, handler) { 12272 var callbackInfo = this.CreateCallbackInfo(ASPx.CallbackType.Common, handler || null); 12273 var callbackID = this.CreateCallbackByInfo(arg, command, callbackInfo); 12274 return callbackID; 12275 }, 12276 CreateCustomDataCallback: function(arg, command, handler) { 12277 var callbackInfo = this.CreateCallbackInfo(ASPx.CallbackType.Data, handler); 12278 this.CreateCallbackByInfo(arg, command, callbackInfo); 12279 }, 12280 CreateCallbackByInfo: function(arg, command, callbackInfo) { 12281 if(!this.CanCreateCallback()) return; 12282 var callbackID; 12283 if(typeof(WebForm_DoCallback) != "undefined" && WebForm_DoCallback && ASPx.documentLoaded || ASPx.Platform === "NETCORE") 12284 callbackID = this.CreateCallbackInternal(arg, command, true, callbackInfo); 12285 else { 12286 if(!this.savedCallbacks) 12287 this.savedCallbacks = []; 12288 var callbackInfo = { arg: arg, command: command, callbackInfo: callbackInfo }; 12289 if(this.allowMultipleCallbacks) 12290 this.savedCallbacks.push(callbackInfo); 12291 else 12292 this.savedCallbacks[0] = callbackInfo; 12293 } 12294 return callbackID; 12295 }, 12296 CreateCallbackInternal: function(arg, command, viaTimer, callbackInfo) { 12297 var watcher = ASPx.ControlUpdateWatcher.getInstance(); 12298 if(watcher && !watcher.CanSendCallback(this, arg)) { 12299 this.CancelCallbackInternal(); 12300 return; 12301 } 12302 this.requestCount++; 12303 this.DoBeginCallback(command); 12304 if(typeof(arg) == "undefined") 12305 arg = ""; 12306 if(typeof(command) == "undefined") 12307 command = ""; 12308 var callbackID = this.SaveCallbackInfo(callbackInfo, command), 12309 customArgs = this.GetCustomCallbackArgs(); 12310 if(viaTimer) 12311 window.setTimeout(function() { this.CreateCallbackCoreWithCustomArgs(arg, command, callbackID, customArgs); }.aspxBind(this), 0); 12312 else 12313 this.CreateCallbackCoreWithCustomArgs(arg, command, callbackID, customArgs); 12314 return callbackID; 12315 }, 12316 CreateCallbackCoreWithCustomArgs: function(arg, command, callbackID, customArgs) { 12317 this.CreateCallbackCore(arg, command, callbackID); 12318 }, 12319 GetCustomCallbackArgs: function() { 12320 return {}; 12321 }, 12322 CancelCallbackInternal: function() { 12323 this.CancelCallbackCore(); 12324 this.HideLoadingElements(); 12325 }, 12326 CancelCallbackCore: function() { 12327 }, 12328 CreateCallbackCore: function(arg, command, callbackID) { 12329 var callBackMethod = this.GetCallbackMethod(command); 12330 __theFormPostData = this.savedFormPostData; 12331 __theFormPostCollection = this.savedFormPostCollection; 12332 callBackMethod.call(this, this.GetSerializedCallbackInfoByID(callbackID) + arg); 12333 }, 12334 GetCallbackMethod: function(command){ 12335 return this.callBack; 12336 }, 12337 CanCreateCallback: function() { 12338 return !this.InCallback() || (this.allowMultipleCallbacks && !this.beginCallbackA
12338nimationProcessing && !this.endCallbackAnimationProcessing); 12339 }, 12340 DoLoadCallbackScripts: function() { 12341 ASPx.ProcessScriptsAndLinks(this.name, true); 12342 }, 12343 DoEndCallback: function() { 12344 if(this.IsCallbackAnimationEnabled() && this.CheckEndCallbackAnimationNeeded()) 12345 return; 12346 this.requestCount--; 12347 if (this.requestCount < 1) 12348 this.callbackHandlersQueue.executeCallbacksHandlers(); 12349 if(this.HideLoadingPanelOnCallback() && this.requestCount < 1) 12350 this.HideLoadingElements(); 12351 if(this.isSwipeGesturesEnabled() && this.supportGestures) { 12352 ASPx.GesturesHelper.UpdateSwipeAnimationContainer(this.name); 12353 if(this.touchUIMouseScroller) 12354 this.touchUIMouseScroller.update(); 12355 } 12356 this.isCallbackAnimationPrevented = false; 12357 this.OnCallbackFinalized(); 12358 this.AssignEllipsisTooltips(); 12359 var command = this.GetCallbackCommand(); 12360 this.RaiseEndCallback(command); 12361 this.InitializeIntersectionObserversManager(); 12362 this.currentCallbackID = -1; 12363 }, 12364 DoFinalizeCallback: function() { 12365 }, 12366 OnCallbackFinalized: function() { 12367 }, 12368 AssignEllipsisTooltips: function() { }, 12369 GetCallbackCommand: function() { 12370 var result = ""; 12371 if(this.currentCallbackID != -1) { 12372 var command = this.callbackCommand[this.currentCallbackID]; 12373 if(command) 12374 result = command; 12375 } 12376 return result; 12377 }, 12378 HideLoadingPanelOnCallback: function() { 12379 return true; 12380 }, 12381 ShouldHideExistingLoadingElements: function() { 12382 return true; 12383 }, 12384 EvalCallbackResult: function(resultString){ 12385 return eval(resultString); 12386 }, 12387 ParseJSProperties: function(resultObj) { 12388 if(resultObj.cp) { 12389 for(var name in resultObj.cp) 12390 if(resultObj.cp.hasOwnProperty(name)) { 12391 this[name] = resultObj.cp[name]; 12392 if(this.aspNetCoreWrapperInstance) 12393 this.aspNetCoreWrapperInstance[name] = resultObj.cp[name]; 12394 } 12395 } 12396 }, 12397 DoCallback: function(result) { 12398 if(this.IsCallbackAnimationEnabled() && this.CheckBeginCallbackA
12398nimationInProgress(result)) 12399 return; 12400 result = ASPx.Str.Trim(result); 12401 if(result.indexOf(ASPx.CallbackResultPrefix) != 0) 12402 this.ProcessCallbackGeneralError(result, false); 12403 else { 12404 var resultObj = null; 12405 try { 12406 resultObj = this.EvalCallbackResult(result); 12407 } 12408 catch(e) { 12409 } 12410 if(resultObj) { 12411 this.currentCallbackID = resultObj.id; 12412 ASPx.CacheHelper.DropCache(this); 12413 if(resultObj.redirect) { 12414 this.ParseJSProperties(resultObj); 12415 ASPx.Url.Redirect(resultObj.redirect); 12416 } 12417 else if(ASPx.IsExists(resultObj.generalError)) { 12418 this.ProcessCallbackGeneralError(resultObj.generalError, true); 12419 } 12420 else { 12421 var errorObj = resultObj.error; 12422 if(errorObj) { 12423 if(this.parseJSPropertiesOnCallbackError) 12424 this.ParseJSProperties(resultObj); 12425 this.ProcessCallbackError(errorObj,resultObj.id); 12426 } else { 12427 this.ParseJSProperties(resultObj); 12428 var callbackInfo = this.DequeueCallbackInfo(resultObj.id); 12429 if(callbackInfo && callbackInfo.type == ASPx.CallbackType.Data) 12430 this.ProcessCustomDataCallback(resultObj.result, callbackInfo); 12431 else { 12432 if (this.useCallbackQueue() && this.callbackQueueHelper.getCallbackInfoById(resultObj.id)) 12433 this.callbackQueueHelper.processCallback(resultObj.result, resultObj.id); 12434 else { 12435 this.ProcessCallback(resultObj.result, resultObj.id); 12436 if(callbackInfo && callbackInfo.handler) { 12437 var handlerInfo = { handler: callbackInfo.handler, result: resultObj.result.data }; 12438 this.callbackHandlersQueue.addCallbackHandler(handlerInfo); 12439 } 12440 } 12441 } 12442 } 12443 } 12444 } 12445 } 12446 this.DoLoadCallbackScripts(); 12447 }, 12448 DoCallbackError: function(result) { 12449 this.HideLoadingElements(); 12450 this.ProcessCallbackGeneralError(result, false); 12451 }, 12452 DoControlClick: function(evt) { 12453 this.OnControlClick(ASPx.Evt.GetEventSource(evt), evt); 12454 }, 12455 ProcessCallback: function (result, callbackId) { 12456 this.OnCallback(result, callbackId); 12457 }, 12458 ProcessCustomDataCallback: function(result, callbackInfo) { 12459 if(callbackInfo.handler != null) 12460 callbackInfo.handler(this, result); 12461 this.RaiseCustomDataCallback(result); 12462 }, 12463 RaiseCustomDataCallback: function(result) { 12464 if(!this.CustomDataCallback.IsEmpty()) { 12465 var arg = new ASPxClientCustomDataCallbackEventArgs(result); 12466 this.CustomDataCallback.FireEvent(this, arg); 12467 } 12468 }, 12469 OnCallback: function(result) { 12470 }, 12471 CreateCallbackInfo: function(type, handler) { 12472 return { type: type, handler: handler }; 12473 }, 12474 GetSerializedCallbackInfoByID: function(callbackID) { 12475 return this.GetCallbackInfoByID(callbackID).type + callbackID + ASPx.CallbackSeparator; 12476 }, 12477 SaveCallbackInfo: function(info, command) { 12478 var callbacks = this.GetActiveCallbacksInfo(); 12479 var index = callbacks.indexOf(null); 12480 if(index === -1) 12481 index = callbacks.length; 12482 callbacks[index] = info; 12483 this.callbackCommand[index] = command; 12484 return index; 12485 }, 12486 GetActiveCallbacksInfo: function() { 12487 var persistentProperties = this.GetPersistentProperties(); 12488 if(!persistentProperties.activeCallbacks) 12489 persistentProperties.activeCallbacks = [ ]; 12490 return persistentProperties.activeCallbacks; 12491 }, 12492 GetPersistentProperties: function() { 12493 var storage = _aspxGetPersistentControlPropertiesStorage(); 12494 var persistentProperties = storage[this.name]; 12495 if(!persistentProperties) { 12496 persistentProperties = { }; 12497 storage[this.name] = persistentProperties; 12498 } 12499 return persistentProperties; 12500 }, 12501 GetCallbackInfoByID: function(callbackID) { 12502 return this.GetActiveCallbacksInfo()[callbackID]; 12503 }, 12504 DequeueCallbackInfo: function(index) { 12505 var activeCallbacksInfo = this.GetActiveCallbacksInfo(); 12506 if(index < 0 || index >= activeCallbacksInfo.length) 12507 return null; 12508 var result = activeCallbacksInfo[index]; 12509 activeCallbacksInfo[index] = null; 12510 return result; 12511 }, 12512 ProcessCallbackError: function (errorObj, callbackId) { 12513 var data = ASPx.IsExists(errorObj.data) ? errorObj.data : null; 12514 var result = this.RaiseCallbackError(errorObj.message, callbackId); 12515 if(result.isHandled) 12516 this.OnCallbackErrorAfterUserHandle(result.errorMessage, data); 12517 else 12518 this.OnCallbackError(result.errorMessage, data); 12519 }, 12520 OnCallbackError: function(errorMessage, data) { 12521 if(errorMessage) 12522 ASPx.ShowErrorAlert(errorMessage); 12523 }, 12524 OnCallbackErrorAfterUserHandle: function(errorMessage, data) { 12525 }, 12526 ProcessCallbackGeneralError: function(errorMessage, serverExceptionOnLastCallback) { 12527 this.serverExceptionOnLastCallback = serverExceptionOnLastCallback; 12528 var result = this.RaiseCallbackError(errorMessage); 12529 if(result.isHandled) 12530 this.OnCallbackGeneralErrorAfterUserHandle(result.errorMessage); 12531 else 12532 this.OnCallbackGeneralError(result.errorMessage); 12533 }, 12534 OnCallbackGeneralError: function(errorMessage) { 12535 this.OnCallbackError(errorMessage, null); 12536 }, 12537 OnCallbackGeneralErrorAfterUserHandle: function (errorMessage) { 12538 },
12539 SendPostBack: function(params, preventConvertToUpdatePanelCallback) { 12540 if(preventConvertToUpdatePanelCallback) 12541 this.sendMSAjaxCompatPostBack(params); 12542 else 12543 this.sendPostBackInternal(params); 12544 }, 12545 sendPostBackInternal: function(params) { 12546 if(typeof(__doPostBack) != "undefined") 12547 __doPostBack(this.uniqueID, params); 12548 else{ 12549 var form = this.GetParentForm(); 12550 if(form) form.submit(); 12551 } 12552 }, 12553 sendMSAjaxCompatPostBack: function(params) { 12554 var rm = ASPx.GetMSAjaxRequestManager(); 12555 var triggers = rm ? rm._postBackControlClientIDs : null; 12556 var needRegister = triggers && ASPx.Ident.IsArray(triggers) && ASPx.Data.ArrayIndexOf(triggers, this.name) == -1; 12557 if(needRegister) 12558 triggers.unshift(this.name); 12559 this.sendPostBackInternal(params); 12560 if(needRegister) 12561 triggers.shift(); 12562 }, 12563 IsValidInstance: function () { 12564 return aspxGetControlCollection().GetByName(this.name) === this; 12565 }, 12566 OnDispose: function() { 12567 var varName = this.globalName; 12568 if(varName && varName !== "" && window && window[varName] && window[varName] == this){ 12569 try{ 12570 delete window[varName]; 12571 } 12572 catch(e){ } 12573 } 12574 if(this.callbackQueueHelper) 12575 this.callbackQueueHelper.detachEvents(); 12576 if (!this.IsDisposed()) 12577 this.disposed = true; 12578 }, 12579 OnGlobalControlsInitialized: function(args) { 12580 }, 12581 OnGlobalBrowserWindowResized: function(args) { 12582 }, 12583 OnGlobalBeginCallback: function(args) { 12584 }, 12585 OnGlobalEndCallback: function(args) { 12586 }, 12587 OnGlobalCallbackError: function(args) { 12588 }, 12589 OnGlobalValidationCompleted: function(args) { 12590 }, 12591 AddDefaultStateControllerItems: function() { 12592 var states = this.scStates; 12593 if(!states) return; 12594 var postfix = this.scPostfix ? ("_" + this.scPostfix) : ""; 12595 var mainElementId = this.GetMainElementId(); 12596 if(states & 2) 12597 this.AddDefaultReadOnlyStateControllerItem(this.scPrefix + "ReadOnly" + postfix, mainElementId); 12598 if(states & 4) 12599 this.AddDefaultDisabledStateControllerItem(this.scPrefix + "Disabled" + postfix, mainElementId); 12600 }, 12601 AddDefaultReadOnlyStateControllerItem: function(cssClass, mainElementId) { throw "Not implemented"; }, 12602 AddDefaultDisabledStateControllerItem: function(cssClass, mainElementId) { throw "Not implemented"; }, 12603 DOMContentLoaded: function() { }, 12604 IsStateControllerEnabled: function() { return false; }, 12605 InitializeDOM: function() { 12606 var mainElement = this.GetMainElement(); 12607 if(mainElement) 12608 ASPx.SetElementInitializedFlag(mainElement); 12609 }, 12610 IsDOMInitialized: function() { 12611 var mainElement = this.GetMainElement(); 12612 return mainElement && ASPx.GetElementInitializedFlag(mainElement); 12613 }, 12614 AdjustControl: function(nestedCall) { }, 12615 OnBrowserWindowResizeInternal: function(e) { }, 12616 RegisterInControlTree: function(tree) { }, 12617 InitializeIntersectionObserversManager: function () { 12618 var elementToObserve = this.getElementToObserveVisibilityChange(); 12619 if(elementToObserve) { 12620 ASPx.IntersectionObserversManager.SubscribeElemensVisibilityChangeInBrowserWindow(elementToObserve, this.processVisibilityChanged.bind(this)); 12621 } 12622 }, 12623 getElementToObserveVisibilityChange: function () { }, 12624 processVisibilityChanged: function (visible) { } 12625}); 12626ASPxClientControlBase.Cast = function(obj) { 12627 if(typeof obj == "string") 12628 return window[obj]; 12629 return obj; 12630}; 12631var persistentControlPropertiesStorage = null; 12632function _aspxGetPersistentControlPropertiesStorage() { 12633 if(persistentControlPropertiesStorage == null) 12634 persistentControlPropertiesStorage = { }; 12635 return persistentControlPropertiesStorage; 12636} 12637var ELLIPSIS_MARKER_CLASS = "dx-ellipsis"; 12638var ELLIPSIS_TOOLTIP_MARKER_ATTR = "dxEllipsisTitle"; 12639var ASPxClientControl = ASPx.CreateClass(ASPxClientControlBase, { 12640 constructor: function(name){ 12641 this.constructor.prototype.constructor.call(this, name); 12642 this.rtl = false; 12643 this.enableEllipsis = false; 12644 this.isNative = false; 12645 this.isControlCollapsed = false; 12646 this.isInsideHierarchyAdjustment = false; 12647 this.controlOwner = null; 12648 this.adjustedSizes = { }; 12649 this.dialogContentHashTable = { }; 12650 this.renderIFrameForPopupElements = false; 12651 this.widthValueSetInPercentage = false; 12652 this.heightValueSetInPercentage = false; 12653 this.verticalAlignedElements = { }; 12654 this.wrappedTextContainers = { }; 12655 this.scrollPositionState = { }; 12656 this.sizingConfig = { 12657 allowSetWidth: true, 12658 allowSetHeight: true, 12659 correction : false, 12660 adjustControl : false, 12661 supportPercentHeight: false, 12662 supportAutoHeight: false 12663 }; 12664 this.percentSizeConfig = { 12665 width: -1, 12666 height: -1, 12667 markerWidth: -1, 12668 markerHeight: -1 12669 }; 12670 }, 12671 querySelector: function(selector) { return this.querySelectorAll(selector)[0] || null; }, 12672 querySelectorAll: function(selector) { 12673 return ASPx.CacheHelper.GetCachedElement(this, "querySelectorAll_" + selector, 12674 function() { return Array.prototype.slice.call(this.GetMainElement().querySelectorAll(selector)); }); 12675 }, 12676 createAccessKey: function (popupItem, getPopupElement, keyTipElement, key, onlyClick, manualStopProcessing) { 12677 return new ASPx.AccessKey(popupItem, getPopupElement, keyTipElement, key, onlyClick, manualStopProcessing); 12678 }, 12679 InlineInitialize: function() { 12680 this.InitializeDOM(); 12681 ASPxClientControlBase.prototype.InlineInitialize.call(this); 12682 }, 12683 AfterCreate: function() { 12684 ASPxClientControlBase.prototype.AfterCreate.call(this); 12685 if(!this.CanInitializeAdjustmentOnDOMContentLoaded() || ASPx.IsStartupScriptsRunning()) 12686 this.InitializeAdjustment(); 12687 }, 12688 DOMContentLoaded: function() { 12689 if(this.CanInitializeAdjustmentOnDOMContentLoaded()) 12690 this.InitializeAdjustment(); 12691 }, 12692 CanInitializeAdjustmentOnDOMContentLoaded: function() { 12693 return !ASPx.Browser.IE || ASPx.Browser.Version >= 10; 12694 }, 12695 InitializeAdjustment: function() { 12696 this.UpdateAdjustmentFlags(); 12697 this.AdjustControl(); 12698 }, 12699 AfterInitialize: function() { 12700 this.AdjustControl(); 12701 ASPxClientControlBase.prototype.AfterInitialize.call(this); 12702 }, 12703 IsStateControllerEnabled: function(){ 12704 return typeof(ASPx.GetStateController) != "undefined" && ASPx.GetStateController(); 12705 }, 12706 GetWidth: function() { 12707 return this.GetMainElement().offsetWidth; 12708 }, 12709 GetHeight: function() { 12710 return this.GetMainElement().offsetHeight; 12711 }, 12712 SetWidth: function(width) { 12713 if(this.sizingConfig.allowSetWidth)
12714 this.SetSizeCore("width", width, "GetWidth", false); 12715 }, 12716 SetHeight: function(height) { 12717 if(this.sizingConfig.allowSetHeight) 12718 this.SetSizeCore("height", height, "GetHeight", false); 12719 }, 12720 SetSizeCore: function(sizePropertyName, size, getFunctionName, corrected) { 12721 if(size < 0 || !this.GetMainElement()) 12722 return; 12723 this.GetMainElement().style[sizePropertyName] = size + "px"; 12724 this.UpdateAdjustmentFlags(sizePropertyName); 12725 if(this.sizingConfig.adjustControl) 12726 this.AdjustControl(true); 12727 if(this.sizingConfig.correction && !corrected) { 12728 var realSize = this[getFunctionName](); 12729 if(realSize != size) { 12730 var correctedSize = size - (realSize - size); 12731 this.SetSizeCore(sizePropertyName, correctedSize, getFunctionName, true); 12732 } 12733 } 12734 }, 12735 AdjustControl: function(nestedCall) { 12736 if(this.IsAdjustmentRequired() && (!ASPxClientControl.adjustControlLocked || nestedCall)) { 12737 ASPxClientControl.adjustControlLocked = true; 12738 try { 12739 if(!this.IsAdjustmentAllowed()) 12740 return; 12741 this.AdjustControlCore(); 12742 this.UpdateAdjustedSizes(); 12743 } 12744 finally { 12745 delete ASPxClientControl.adjustControlLocked; 12746 } 12747 } 12748 this.AssignEllipsisTooltips(); 12749 this.TryShowPhantomLoadingElements(); 12750 }, 12751 ResetControlAdjustment: function () { 12752 this.adjustedSizes = { }; 12753 }, 12754 UpdateAdjustmentFlags: function(sizeProperty) { 12755 var mainElement = this.GetMainElement(); 12756 if(mainElement) { 12757 var mainElementStyle = ASPx.GetCurrentStyle(mainElement); 12758 this.UpdatePercentSizeConfig([mainElementStyle.width, mainElement.style.width], [mainElementStyle.height, mainElement.style.height], sizeProperty); 12759 } 12760 }, 12761 UpdatePercentSizeConfig: function(widths, heights, modifyStyleProperty) { 12762 switch(modifyStyleProperty) { 12763 case "width": 12764 this.UpdatePercentWidthConfig(widths); 12765 break; 12766 case "height": 12767 this.UpdatePercentHeightConfig(heights); 12768 break; 12769 default: 12770 this.UpdatePercentWidthConfig(widths); 12771 this.UpdatePercentHeightConfig(heights); 12772 break; 12773 } 12774 this.ResetControlPercentMarkerSize(); 12775 }, 12776 UpdatePercentWidthConfig: function(widths) { 12777 this.widthValueSetInPercentage = false; 12778 for(var i = 0; i < widths.length; i++) { 12779 if(this.IsPercentageWidth(widths[i])) { 12780 this.percentSizeConfig.width = widths[i]; 12781 this.widthValueSetInPercentage = true; 12782 break; 12783 } 12784 } 12785 }, 12786 IsPercentageWidth: function(width) { return ASPx.IsPercentageSize(width); }, 12787 UpdatePercentHeightConfig: function(heights) { 12788 this.heightValueSetInPercentage = false; 12789 for(var i = 0; i < heights.length; i++) { 12790 if(ASPx.IsPercentageSize(heights[i])) { 12791 this.percentSizeConfig.height = heights[i]; 12792 this.heightValueSetInPercentage = true; 12793 break; 12794 } 12795 } 12796 }, 12797 GetAdjustedSizes: function() { 12798 var mainElement = this.GetMainElement(); 12799 if(mainElement) 12800 return { width: mainElement.offsetWidth, height: mainElement.offsetHeight }; 12801 return { width: 0, height: 0 }; 12802 }, 12803 IsAdjusted: function() { 12804 return (this.adjustedSizes.width && this.adjustedSizes.width > 0) && (this.adjustedSizes.height && this.adjustedSizes.height > 0); 12805 }, 12806 IsAdjustmentRequired: function() { 12807 if(!this.IsAdjusted()) 12808 return true; 12809 if(this.widthValueSetInPercentage) 12810 return true; 12811 if(this.heightValueSetInPercentage) 12812 return true; 12813 var sizes = this.GetAdjustedSizes(); 12814 for(var name in sizes){ 12815 if(this.adjustedSizes[name] !== sizes[name]) 12816 return true; 12817 } 12818 return false; 12819 }, 12820 IsAdjustmentAllowed: function() { 12821 var mainElement = this.GetMainElement(); 12822 return mainElement && this.IsDisplayed() && !this.IsHidden() && this.IsDOMInitialized(); 12823 }, 12824 UpdateAdjustedSizes: function() { 12825 var sizes = this.GetAdjustedSizes(); 12826 for(var name in sizes) 12827 if(sizes.hasOwnProperty(name)) 12828 this.adjustedSizes[name] = sizes[name]; 12829 }, 12830 AdjustControlCore: function() { 12831 }, 12832 AdjustAutoHeight: function() { 12833 }, 12834 IsControlCollapsed: function() { 12835 return this.isControlCollapsed; 12836 }, 12837 NeedCollapseControl: function() { 12838 return this.NeedCollapseControlCore() && this.IsAdjustmentRequired() && this.IsAdjustmentAllowed(); 12839 }, 12840 NeedCollapseControlCore: function() { 12841 return false; 12842 }, 12843 CollapseEditor: function() { 12844 }, 12845 CollapseControl: function() { 12846 this.SaveScrollPositions(); 12847 var mainElement = this.GetMainElement(), 12848 marker = this.GetControlPercentSizeMarker(); 12849 marker.style.height = this.heightValueSetInPercentage && this.sizingConfig.supp
12849ortPercentHeight 12850 ? this.percentSizeConfig.height 12851 : (mainElement.offsetHeight + "px"); 12852 mainElement.style.display = "none"; 12853 this.isControlCollapsed = true; 12854 }, 12855 ExpandControl: function() { 12856 var mainElement = this.GetMainElement(); 12857 mainElement.style.display = ""; 12858 this.GetControlPercentSizeMarker().style.height = "0px"; 12859 this.isControlCollapsed = false; 12860 this.RestoreScrollPositions(); 12861 }, 12862 CanCauseReadjustment: function() { 12863 return this.NeedCollapseControlCore(); 12864 }, 12865 IsExpandableByAdjustment: function() { 12866 return false; 12867 }, 12868 HasFixedPosition: function() { 12869 return false; 12870 }, 12871 SaveScrollPositions: function() { 12872 var mainElement = this.GetMainElement(); 12873 this.scrollPositionState.outer = ASPx.GetOuterScrollPosition(mainElement.parentNode); 12874 this.scrollPositionState.inner = ASPx.GetInnerScrollPositions(mainElement); 12875 }, 12876 RestoreScrollPositions: function() { 12877 ASPx.RestoreOuterScrollPosition(this.scrollPositionState.outer); 12878 ASPx.RestoreInnerScrollPositions(this.scrollPositionState.inner); 12879 }, 12880 GetControlPercentSizeMarker: function() { 12881 if(this.percentSizeMarker === undefined) { 12882 this.percentSizeMarker = ASPx.CreateHtmlElementFromString("<div style='height:0px;font-size:0px;line-height:0;width:100%;'></div>"); 12883 ASPx.InsertElementAfter(this.percentSizeMarker, this.GetMainElement()); 12884 } 12885 return this.percentSizeMarker; 12886 }, 12887 KeepControlPercentSizeMarker: function(needCollapse, needCalculateHeight) { 12888 var marker = this.GetControlPercentSizeMarker(), 12889 markerHeight; 12890 if(needCollapse) 12891 this.CollapseControl(); 12892 if(this.widthValueSetInPercentage && marker.style.width !== this.percentSizeConfig.width) 12893 marker.style.width = this.percentSizeConfig.width; 12894 if(needCalculateHeight) { 12895 if(this.IsControlCollapsed()) 12896 markerHeight = marker.style.height; 12897 marker.style.height = this.percentSizeConfig.height; 12898 } 12899 this.percentSizeConfig.markerWidth = marker.offsetWidth; 12900 if(needCalculateHeight) { 12901 this.percentSizeConfig.markerHeight = marker.offsetHeight; 12902 if(this.IsControlCollapsed()) 12903 marker.style.height = markerHeight; 12904 else 12905 marker.style.height = "0px"; 12906 } 12907 if(needCollapse) 12908 this.ExpandControl(); 12909 }, 12910 ResetControlPercentMarkerSize: function() { 12911 this.percentSizeConfig.markerWidth = -1; 12912 this.percentSizeConfig.markerHeight = -1; 12913 }, 12914 GetControlPercentMarkerSize: function(hideControl, force) { 12915 var needCalculateHeight = this.heightValueSetInPercentage && this.sizingConfig.supportPercentHeight; 12916 if(force || this.percentSizeConfig.markerWidth < 1 || (needCalculateHeight && this.percentSizeConfig.markerHeight < 1)) 12917 this.KeepControlPercentSizeMarker(hideControl && !this.IsControlCollapsed(), needCalculateHeight); 12918 return { 12919 width: this.percentSizeConfig.markerWidth, 12920 height: this.percentSizeConfig.markerHeight 12921 }; 12922 }, 12923 AssignEllipsisTooltips: function() { 12924 if(this.RequireAssignTooltips()) 12925 this.AssignEllipsisTooltipsCore(); 12926 }, 12927 AssignEllipsisTooltipsCore: function(rootElement, reassingExistingTooltips) { 12928 var requirePaddingManipulation = ASPx.Browser.IE || ASPx.Browser.Edge || ASPx.Browser.Firefox; 12929 rootElement = rootElement || this.GetMainElement(); 12930 var nodes = this.GetEllipsisNodes(rootElement); 12931 var nodeInfos = []; 12932 var nodesCount = nodes.length; 12933 for(var i = 0; i < nodesCount; i++) { 12934 var node = nodes[i]; 12935 var info = { node: node }; 12936 if(requirePaddingManipulation) { 12937 var style = ASPx.GetCurrentStyle(node); 12938 info.paddingLeft = node.style.paddingLeft; 12939 info.totalPadding = ASPx.GetLeftRightPaddings(node, style); 12940 } 12941 nodeInfos.push(info); 12942 } 12943 if(requirePaddingManipulation) { 12944 for(var i = 0; i < nodesCount; i++) { 12945 var info = nodeInfos[i]; 12946 ASPx.SetStyles(info.node, { paddingLeft: info.totalPadding }, true); 12947 } 12948 } 12949 for(var i = 0; i < nodesCount; i++) { 12950 var info = nodeInfos[i]; 12951 var node = info.node; 12952 info.isTextShortened = node.scrollWidth > node.clientWidth; 12953 info.hasTitle = ASPx.Attr.GetAttribute(node, "title") !== null; 12954 if(!info.hasTitle || reassingExistingTooltips) 12955 info.title = this.GetEllipsisTooltipText(node); 12956 } 12957 for(var i = 0; i < nodesCount; i++) { 12958 var info = nodeInfos[i]; 12959 var node = info.node; 12960 if(info.isTextShortened && info.title) { 12961 ASPx.Attr.SetAttribute(node, "title", info.title); 12962 ASPx.Attr.SetAttribute(node, ELLIPSIS_TOOLTIP_MARKER_ATTR, true); 12963 } 12964 if(!info.isTextShortened && info.hasTitle) 12965 ASPx.Attr.RemoveAttribute(node, "title"); 12966 } 12967 if(requirePaddingManipulation) { 12968 for(var i = 0; i < nodesCount; i++) { 12969 var info = nodeInfos[i]; 12970 var node = info.node; 12971 node.style.paddingLeft = info.paddingLeft; 12972 } 12973 } 12974 }, 12975 GetEllipsisNodes: function(element) { 12976 var ellipsibleNodes = ASPx.Data.CollectionToArray(ASPx.GetNodesByClassName(element, ELLIPSIS_MARKER_CLASS)); 12977 if(ASPx.ElementHasCssClass(element, ELLIPSIS_MARKER_CLASS)) 12978 ellipsibleNodes.push(element); 12979 return ellipsibleNodes.filter(function(node) { 12980 return !ASPx.Attr.IsExistsAttribute(node, "title") || ASPx.Attr.IsExistsAttribute(node, ELLIPSIS_TOOLTIP_MARKER_ATTR); 12981 }); 12982 }, 12983 GetEllipsisTooltipText: function(element) { 12984 return ASPx.GetInnerText(element); 12985 }, 12986 RequireAssignTooltips: function() { 12987 return this.enableEllipsis && !ASPx.Browser.MobileUI; 12988 }, 12989 RemoveEllipsisFromNode: function(node) { 12990 ASPx.RemoveClassNameFromElement(node, ELLIPSIS_MARKER_CLASS); 12991 this.RemoveEllipsisTooltip(node); 12992 }, 12993 RemoveEllipsisTooltip: function(node) { 12994 if(ASPx.Attr.IsExistsAttribute(node, ELLIPSIS_TOOLTIP_MARKER_ATTR)) { 12995 ASPx.Attr.RemoveAttribute(node, "title"); 12996 ASPx.Attr.RemoveAttribute(node, ELLIPSIS_TOOLTIP_MARKER_ATTR); 12997 } 12998 }, 12999 OnBrowserWindowResize: function(e) { 13000 }, 13001 OnBrowserWindowResizeInternal: function(e){
13002 if(this.BrowserWindowResizeSubscriber()) 13003 this.OnBrowserWindowResize(e); 13004 }, 13005 BrowserWindowResizeSubscriber: function() { 13006 return this.widthValueSetInPercentage || !this.IsAdjusted(); 13007 }, 13008 ShrinkWrappedText: function(getElements, key, reCorrect) { 13009 if(!ASPx.Browser.Safari) return; 13010 var elements = ASPx.CacheHelper.GetCachedElements(this, key, getElements, this.wrappedTextContainers); 13011 for(var i = 0; i < elements.length; i++) 13012 this.ShrinkWrappedTextInContainer(elements[i], reCorrect); 13013 }, 13014 ShrinkWrappedTextInContainer: function(container, reCorrect) { 13015 if(!ASPx.Browser.Safari || !container || (container.dxWrappedTextShrinked && !reCorrect) || container.offsetWidth === 0) return; 13016 ASPx.ShrinkWrappedTextInContainer(container); 13017 container.dxWrappedTextShrinked = true; 13018 }, 13019 CorrectWrappedText: function(getElements, key, reCorrect) { 13020 var elements = ASPx.CacheHelper.GetCachedElements(this, key, getElements, this.wrappedTextContainers); 13021 for(var i = 0; i < elements.length; i++) 13022 this.CorrectWrappedTextInContainer(elements[i], reCorrect); 13023 }, 13024 CorrectWrappedTextInContainer: function(container, reCorrect) { 13025 if(!container || (container.dxWrappedTextCorrected && !reCorrect) || container.offsetWidth === 0) return; 13026 ASPx.AdjustWrappedTextInContainer(container); 13027 container.dxWrappedTextCorrected = true; 13028 }, 13029 CorrectVerticalAlignment: function(alignMethod, getElements, key, reAlign) { 13030 var elements = ASPx.CacheHelper.GetCachedElements(this, key, getElements, this.verticalAlignedElements); 13031 for(var i = 0; i < elements.length; i++) 13032 this.CorrectElementVerticalAlignment(alignMethod, elements[i], reAlign); 13033 }, 13034 CorrectElementVerticalAlignment: function(alignMethod, element, reAlign) { 13035 if(!element || (element.dxVerticalAligned && !reAlign) || element.offsetHeight === 0) return; 13036 alignMethod(element); 13037 element.dxVerticalAligned = true; 13038 }, 13039 ClearVerticalAlignedElementsCache: function() { 13040 ASPx.CacheHelper.DropCache(this.verticalAlignedElements); 13041 }, 13042 ClearWrappedTextContainersCache: function() { 13043 ASPx.CacheHelper.DropCache(this.wrappedTextContainers); 13044 }, 13045 AdjustPagerControls: function() { 13046 if(typeof(ASPx.GetPagersCollection) != "undefined") 13047 ASPx.GetPagersCollection().AdjustControls(this.GetMainElement()); 13048 }, 13049 RegisterInControlTree: function(tree) { 13050 var mainElement = this.GetMainElement(); 13051 if(mainElement && mainElement.id) 13052 tree.createNode(mainElement.id, this); 13053 }, 13054 GetItemElementName: function(element) { 13055 var name = ""; 13056 if(element.id) 13057 name = element.id.substring(this.name.length + 1); 13058 return name; 13059 }, 13060 GetLinkElement: function(element) { 13061 if(element == null) return null; 13062 return (element.tagName == "A") ? element : ASPx.GetNodeByTagName(element, "A", 0); 13063 }, 13064 GetInternalHyperlinkElement: function(parentElement, index) { 13065 var element = ASPx.GetNodeByTagName(parentElement, "A", index); 13066 if(element == null) 13067 element = ASPx.GetNodeByTagName(parentElement, "SPAN", index); 13068 return element; 13069 }, 13070 OnControlClick: function(clickedElement, htmlEvent) { 13071 } 13072}); 13073ASPxClientControl.Cast = function(obj) { 13074 if(typeof obj == "string") 13075 return window[obj]; 13076 return obj; 13077}; 13078ASPxClientControl.AdjustControls = function(container, collapseControls){ 13079 aspxGetControlCollection().AdjustControls(container, collapseControls); 13080}; 13081ASPxClientControl.GetControlCollection = function(){ 13082 return aspxGetControlCollection(); 13083}; 13084ASPxClientControl.LeadingAfterInitCallConsts = { 13085 None: 0, 13086 Direct: 1, 13087 Reverse: 2 13088}; 13089var ASPxClientComponent = ASPx.CreateClass(ASPxClientControl, { 13090 constructor: function (name) { 13091 this.constructor.prototype.constructor.call(this, name); 13092 }, 13093 IsDOMDisposed: function() { 13094 return false; 13095 } 13096}); 13097var ASPxClientControlCollection = ASPx.CreateClass(ASPx.CollectionBase, { 13098 constructor: function(){ 13099 this.constructor.prototype.constructor.call(this); 13100 this.prevWndWidth = ""; 13101 this.prevWndHeight = ""; 13102 this.requestCountInternal = 0; 13103 this.BeforeInitCallback = new ASPxClientEvent(); 13104 this.ControlsInitialized = new ASPxClientEvent(); 13105 this.BrowserWindowResized = new ASPxClientEvent(); 13106 this.BrowserWindowResizedInternal = new ASPxClientEvent(); 13107 this.BeginCallback = new ASPxClientEvent(); 13108 this.EndCallback = new ASPxClientEvent(); 13109 this.CallbackError = new ASPxClientEvent(); 13110 this.ValidationCompleted = new ASPxClientEvent(); 13111 aspxGetControlCollectionCollection().Add(this); 13112 }, 13113 Add: function(element) { 13114 var existsElement = this.Get(element.name); 13115 if(existsElement && existsElement !== element) 13116 this.Remove(existsElement);
13117 ASPx.CollectionBase.prototype.Add.call(this, element.name, element); 13118 }, 13119 Remove: function(element) { 13120 if(element && element instanceof ASPxClientControl && !element.IsDisposed()) 13121 element.OnDispose(); 13122 ASPx.CollectionBase.prototype.Remove.call(this, element.name); 13123 }, 13124 GetGlobal: function(name) { 13125 var result = window[name]; 13126 return result && Ident.IsASPxClientControl(result) 13127 ? result 13128 : null; 13129 }, 13130 GetByName: function(name){ 13131 return this.Get(name) || this.GetGlobal(name); 13132 }, 13133 GetCollectionType: function(){ 13134 return ASPxClientControlCollection.BaseCollectionType; 13135 }, 13136 GetControlsByPredicate: function(predicate) { 13137 var result = []; 13138 this.ForEachControl(function(control) { 13139 if(!predicate || predicate(control)) 13140 result.push(control); 13141 }); 13142 return result; 13143 }, 13144 GetControlsByType: function(type) { 13145 return this.GetControlsByPredicate(function(control) { 13146 return type && (control instanceof type); 13147 }); 13148 }, 13149 ForEachControl: function(action, context) { 13150 context = context || this; 13151 this.elementsMap.forEachEntry(function(name, control) { 13152 if(Ident.IsASPxClientControl(control) && (!this.filterPredicate || this.filterPredicate(control))) 13153 return action.call(context, control); 13154 }, context); 13155 }, 13156 ProcessActionByPredicate: function(action, predicate) { 13157 try { 13158 this.filterPredicate = predicate; 13159 action(this); 13160 } 13161 finally { 13162 this.filterPredicate = null; 13163 } 13164 }, 13165 adjustControlsInternal: function(container, context, collapseControls, adjustFunc) { 13166 context = context || this; 13167 var func = function(control) { 13168 adjustFunc.call(context, control); 13169 }; 13170 ASPx.GetControlAdjuster().adjustControlsInHierarchy(this, func, container, collapseControls); 13171 }, 13172 AdjustControls: function(container, collapseControls) { 13173 container = container || null; 13174 window.setTimeout(function() { 13175 this.AdjustControlsCore(container, collapseControls); 13176 }.aspxBind(this), 0); 13177 }, 13178 AdjustControlsCore: function(container, collapseControls) { 13179 var adjustFunction = function(control) { control.AdjustControl(); }; 13180 this.adjustControlsInternal(container, this, collapseControls, adjustFunction); 13181 }, 13182 CollapseControls: function(container) { 13183 this.ProcessControlsInContainer(container, function(control) { 13184 if(control.isASPxClientEdit) 13185 control.CollapseEditor(); 13186 else if(!!window.ASPxClientRibbon && control instanceof ASPxClientRibbon) 13187 control.CollapseControl(); 13188 }); 13189 }, 13190 AtlasInitialize: function(isCallback) { 13191 this.ForEachControl(function(control) { 13192 control.AtlasPreInitialize(); 13193 }); 13194 ASPx.ProcessScriptsAndLinks("", isCallback); 13195 this.ForEachControl(function(control) { 13196 control.AtlasInitialize(); 13197 }); 13198 }, 13199 DOMContentLoaded: function() { 13200 this.ForEachControl(function(control){ 13201 control.DOMContentLoaded(); 13202 }); 13203 }, 13204 OnDocumentUnload: function() { 13205 this.ForEachControl(function(control) { 13206 control.RaiseUnload(); 13207 }); 13208 }, 13209 Initialize: function() { 13210 ASPx.GetPostHandler().Post.AddHandler( 13211 function(s, e) { this.OnPost(e); }.aspxBind(this) 13212 ); 13213 ASPx.GetPostHandler().PostFinalization.AddHandler( 13214 function(s, e) { this.OnPostFinalization(e); }.aspxBind(this) 13215 ); 13216 this.InitializeElements(false ); 13217 if(typeof(Sys) != "undefined" && typeof(Sys.Application) != "undefined") { 13218 var checkIsInitialized = function() { 13219 if(Sys.Application.get_isInitialized()) 13220 Sys.Application.add_load(aspxCAInit); 13221 else 13222 setTimeout(checkIsInitialized, 0); 13223 }; 13224 checkIsInitialized(); 13225 } 13226 this.InitWindowSizeCache(); 13227 }, 13228 FinalizeInitialization: function() { 13229 this.ForEachControl(function(control) { 13230 control.FinalizeInitialization(); 13231 }); 13232 }, 13233 InitializeElements: function(isCallback) { 13234 this.ForEachControl(function(control){ 13235 if(!control.isInitialized) 13236 control.Initialize(); 13237 }); 13238 this.AfterInitializeElementsLeadingCall(); 13239 this.AfterInitializeElements(); 13240 this.RaiseControlsInitialized(isCallback); 13241 }, 13242 AfterInitializeElementsLeadingCall: function() { 13243 var controls = {}; 13244 controls[ASPxClientControl.LeadingAfterInitCallConsts.Direct] = [];
13245 controls[ASPxClientControl.LeadingAfterInitCallConsts.Reverse] = []; 13246 this.ForEachControl(function(control) { 13247 if(control.leadingAfterInitCall != ASPxClientControl.LeadingAfterInitCallConsts.None && !control.isInitialized) 13248 controls[control.leadingAfterInitCall].push(control); 13249 }); 13250 var directInitControls = controls[ASPxClientControl.LeadingAfterInitCallConsts.Direct], 13251 reverseInitControls = controls[ASPxClientControl.LeadingAfterInitCallConsts.Reverse]; 13252 for(var i = 0, control; control = directInitControls[i]; i++) 13253 control.AfterInitialize(); 13254 for(var i = reverseInitControls.length - 1, control; control = reverseInitControls[i]; i--) 13255 control.AfterInitialize(); 13256 }, 13257 AfterInitializeElements: function() { 13258 this.ForEachControl(function(control) { 13259 if(control.leadingAfterInitCall == ASPxClientControl.LeadingAfterInitCallConsts.None && !control.isInitialized) 13260 control.AfterInitialize(); 13261 }); 13262 ASPx.RippleHelper.Init(); 13263 }, 13264 DoFinalizeCallback: function() { 13265 this.ForEachControl(function(control){ 13266 control.DoFinalizeCallback(); 13267 }); 13268 }, 13269 ProcessControlsInContainer: function(container, processFunc, filterFunc) { 13270 this.ForEachControl(function(control){ 13271 if((!filterFunc || filterFunc(control)) && (!container || this.IsControlInContainer(container, control))) 13272 processFunc(control); 13273 }); 13274 }, 13275 IsControlInContainer: function(container, control) { 13276 if(control.GetMainElement) { 13277 var mainElement = control.GetMainElement(); 13278 if(mainElement && (mainElement != container)) { 13279 if(ASPx.GetIsParent(container, mainElement)) 13280 return true; 13281 } 13282 } 13283 return false; 13284 }, 13285 RaiseControlsInitialized: function(isCallback) { 13286 if(typeof(isCallback) == "undefined") 13287 isCallback = true; 13288 var args = new ASPxClientControlsInitializedEventArgs(isCallback); 13289 if(!this.ControlsInitialized.IsEmpty()) 13290 this.ControlsInitialized.FireEvent(this, args); 13291 this.ForEachControl(function(control){ 13292 control.OnGlobalControlsInitialized(args); 13293 }); 13294 }, 13295 RaiseBrowserWindowResized: function() { 13296 var args = new ASPxClientEventArgs(); 13297 if(!this.BrowserWindowResized.IsEmpty()) 13298 this.BrowserWindowResized.FireEvent(this, args); 13299 this.ForEachControl(function(control){ 13300 control.OnGlobalBrowserWindowResized(args); 13301 }); 13302 }, 13303 RaiseBrowserWindowResizedInternal: function(eventInfo) { 13304 var args = new ASPxClientBrowserWindowResizedInternalEventArgs(eventInfo); 13305 if(!this.BrowserWindowResizedInternal.IsEmpty()) 13306 this.BrowserWindowResizedInternal.FireEvent(this, args); 13307 }, 13308 RaiseBeginCallback: function (control, command) { 13309 var args = new ASPxClientGlobalBeginCallbackEventArgs(control, command); 13310 if(!this.BeginCallback.IsEmpty()) 13311 this.BeginCallback.FireEvent(this, args); 13312 this.ForEachControl(function(control){ 13313 control.OnGlobalBeginCallback(args); 13314 }); 13315 this.IncrementRequestCount(); 13316 }, 13317 RaiseEndCallback: function (control) { 13318 var args = new ASPxClientGlobalEndCallbackEventArgs(control); 13319 if (!this.EndCallback.IsEmpty()) 13320 this.EndCallback.FireEvent(this, args); 13321 this.ForEachControl(function(control){ 13322 control.OnGlobalEndCallback(args); 13323 }); 13324 this.DecrementRequestCount(); 13325 }, 13326 InCallback: function() { 13327 return this.requestCountInternal > 0; 13328 }, 13329 RaiseCallbackError: function (control, message, callbackId) { 13330 var args = new ASPxClientGlobalCallbackErrorEventArgs(control, message, callbackId); 13331 if (!this.CallbackError.IsEmpty()) 13332 this.CallbackError.FireEvent(this, args); 13333 this.ForEachControl(function(control){ 13334 control.OnGlobalCallbackError(args); 13335 }); 13336 if(args.handled) 13337 return { isHandled: true, errorMessage: args.message }; 13338 return { isHandled: false, errorMessage: message }; 13339 }, 13340 RaiseValidationCompleted: function (container, validationGroup, invisibleControlsValidated, isValid, firstInvalidControl, firstVisibleInvalidControl) { 13341 var args = new ASPxClientValidationCompletedEventArgs(container, validationGroup, invisibleControlsValidated, isValid, firstInvalidControl, firstVisibleInvalidControl); 13342 if (!this.ValidationCompleted.IsEmpty()) 13343 this.ValidationCompleted.FireEvent(this, args); 13344 this.ForEachControl(function(control){ 13345 control.OnGlobalValidationCompleted(args); 13346 }); 13347 return args.isValid; 13348 }, 13349 Before_WebForm_InitCallback: function(callbackOwnerID){ 13350 var args = new BeforeInitCallbackEventArgs(callbackOwnerID); 13351 this.BeforeInitCallback.FireEvent(this, args); 13352 }, 13353 InitWindowSizeCache: function(){ 13354 this.prevWndWidth = ASPx.GetDocumentClientWidth(); 13355 this.prevWndHeight = ASPx.GetDocumentClientHeight(); 13356 }, 13357 OnBrowserWindowResize: function(evt){ 13358 var shouldIgnoreNestedEvents = ASPx.Browser.IE && ASPx.Browser.MajorVersion == 8; 13359 if(shouldIgnoreNestedEvents) { 13360 if(this.prevWndWidth === "" || this.prevWndHeight === "" || this.browserWindowResizeLocked) 13361 return; 13362 this.browserWindowResizeLocked = true; 13363 } 13364 this.OnBrowserWindowResizeCore(evt); 13365 if(shouldIgnoreNestedEvents) 13366 this.browserWindowResizeLocked = false; 13367 }, 13368 OnBrowserWindowResizeCore: function(htmlEvent){ 13369 var args = this.CreateOnBrowserWindowResizeEventArgs(htmlEvent); 13370 if(this.CalculateIsBrowserWindowSizeChanged()) { 13371 this.RaiseBrowserWindowResizedInternal(args); 13372 this.adjustControlsInternal(null, this, true, function(control) { 13373 if(control.IsDOMInitialized()) 13374 control.OnBrowserWindowResizeInternal(args); 13375 }); 13376 this.RaiseBrowserWindowResized(); 13377 } 13378 }, 13379 CreateOnBrowserWindowResizeEventArgs: function(htmlEvent) { 13380 return { 13381 htmlEvent: htmlEvent, 13382 wndWidth: ASPx.GetDocumentClientWidth(), 13383 wndHeight: ASPx.GetDocumentClientHeight(), 13384 prevWndWidth: this.prevWndWidth, 13385 prevWndHeight: this.prevWndHeight, 13386 virtualKeyboardShownOnAndroid: this.IsVirtualKeyboardShownOnAndroid() 13387 }; 13388 }, 13389 IsVirtualKeyboardShownOnAndroid: function() { 13390 if(!ASPx.Browser.AndroidMobilePlatform) 13391 return false; 13392 var documentClientWidth = ASPx.GetDocumentClientWidth(); 13393 var documentClientHeight = ASPx.GetDocumentClientHeight(); 13394 var isDocumentClientHeightChangedOnly = documentClientWidth === this.prevWndWidth && documentClientHeight !== this.prevWndHeight; 13395 return isDocumentClientHeightChangedOnly && this.IsElementSupportKeyboardInput(document.activeElement); 13396 },
13397 IsElementSupportKeyboardInput: function(element) { 13398 if(!element || !element.tagName) 13399 return false; 13400 var supportedKeyboardInputTagNames = ["INPUT", "TEXTAREA"]; 13401 return supportedKeyboardInputTagNames.indexOf(element.tagName) !== -1; 13402 }, 13403 CalculateIsBrowserWindowSizeChanged: function(){ 13404 var wndWidth = ASPx.GetDocumentClientWidth(); 13405 var wndHeight = ASPx.GetDocumentClientHeight(); 13406 var isBrowserWindowSizeChanged = (this.prevWndWidth != wndWidth) || (this.prevWndHeight != wndHeight); 13407 if(isBrowserWindowSizeChanged){ 13408 this.prevWndWidth = wndWidth; 13409 this.prevWndHeight = wndHeight; 13410 return true; 13411 } 13412 return false; 13413 }, 13414 OnPost: function(args){ 13415 this.ForEachControl(function(control) { 13416 control.OnPost(args); 13417 }, null); 13418 }, 13419 OnPostFinalization: function(args){ 13420 this.ForEachControl(function(control) { 13421 control.OnPostFinalization(args); 13422 }, null); 13423 }, 13424 IncrementRequestCount: function() { 13425 this.requestCountInternal++; 13426 }, 13427 DecrementRequestCount: function() { 13428 this.requestCountInternal--; 13429 }, 13430 ResetRequestCount: function() { 13431 this.requestCountInternal = 0; 13432 } 13433}); 13434ASPxClientControlCollection.BaseCollectionType = "Control"; 13435var controlCollection = null; 13436function aspxGetControlCollection(){ 13437 if(controlCollection == null) { 13438 controlCollection = new ASPxClientControlCollection(); 13439 if(ASPx.loadControlCollectionPreloadHandlers) 13440 ASPx.loadControlCollectionPreloadHandlers(controlCollection); 13441 } 13442 return controlCollection; 13443} 13444var ControlCollectionCollection = ASPx.CreateClass(ASPx.CollectionBase, { 13445 constructor: function(){ 13446 this.constructor.prototype.constructor.call(this); 13447 }, 13448 Add: function(element) { 13449 var key = element.GetCollectionType(); 13450 if(!key) throw "The collection type isn't specified."; 13451 if(this.Get(key)) throw "The collection with type='" + key + "' already exists."; 13452 ASPx.CollectionBase.prototype.Add.call(this, key, element); 13453 }, 13454 RemoveDisposedControls: function(){ 13455 var baseCollection = this.Get(ASPxClientControlCollection.BaseCollectionType); 13456 var disposedControls = []; 13457 baseCollection.elementsMap.forEachEntry(function(name, control) { 13458 if(!ASPx.Ident.IsASPxClientControl(control)) return; 13459 if(control.IsDOMDisposed()) 13460 disposedControls.push(control); 13461 }); 13462 this.RemoveControls(disposedControls); 13463 }, 13464 RemoveControls: function(controls){ 13465 for(var i = 0; i < controls.length; i++) { 13466 this.elementsMap.forEachEntry(function(key, collection) { 13467 if(ASPx.Ident.IsASPxClientCollection(collection)) 13468 collection.Remove(controls[i]); 13469 }); 13470 } 13471 } 13472}); 13473var controlCollectionCollection = null; 13474function aspxGetControlCollectionCollection(){ 13475 if(controlCollectionCollection == null) 13476 controlCollectionCollection = new ControlCollectionCollection(); 13477 return controlCollectionCollection; 13478} 13479var AriaDescriptionAttributes = { 13480 Role: "0", 13481 AriaLabel: "1", 13482 TabIndex: "2", 13483 AriaOwns: "3", 13484 AriaDescribedBy: "4", 13485 AriaDisabled: "5", 13486 AriaHasPopup: "6", 13487 AriaLevel: "7" 13488}; 13489var AriaDescriptor = ASPx.CreateClass(null, { 13490 constructor: function(ownerControl, description) { 13491 this.ownerControl = ownerControl; 13492 this.rootElement = ownerControl.GetMainElement(); 13493 this.description = description; 13494 }, 13495 setDescription: function(name, argList) { 13496 var description = this.findChildDescription(name); 13497 if(description) { 13498 var elements = name ? this.rootElement.querySelectorAll(this.getDescriptionSelector(description)) : [this.rootElement]; 13499 for(var i = 0; i < elements.length; i++) 13500 this.applyDescriptionToElement(elements[i], description, argList[i] || argList[0]); 13501 } 13502 }, 13503 getDescriptionName: function(description) { 13504 return description.n; 13505 }, 13506 getDescriptionSelector: function(description) { 13507 return description.s; 13508 }, 13509 findChildDescription: function(name) { 13510 if(name === this.getDescriptionName(this.description)) 13511 return this.description; 13512 var childCollection = this.description.c || []; 13513 for(var i = 0; i < childCollection.length; i++) { 13514 var childDescription = childCollection[i]; 13515 if(this.getDescriptionName(childDescription) === name) 13516 return childDescription; 13517 } 13518 return null; 13519 }, 13520 applyDescriptionToElement: function(element, description, args) { 13521 if(!description || !element) 13522 return; 13523 this.trySetAriaOwnsAttribute(element, description); 13524 this.trySetAriaDescribedByAttribute(element, description); 13525 this.trySetAttribute(element, description, AriaDescriptionAttributes.Role, "role"); 13526 this.trySetAttribute(element, description, AriaDescriptionAttributes.TabIndex, "tabindex"); 13527 this.trySetAttribute(element, description, AriaDescriptionAttributes.AriaLevel, "aria-level"); 13528 this.executeOnDescription(description, AriaDescriptionAttributes.AriaLabel, function(value) { 13529 ASPx.Attr.SetAttribute(element, "aria-label", ASPx.Str.ApplyReplacement(value, args
13529)); 13530 }); 13531 this.executeOnDescription(description, AriaDescriptionAttributes.AriaDisabled, function(value) { 13532 ASPx.Attr.SetAttribute(element, "aria-disabled", !!value); 13533 }); 13534 this.executeOnDescription(description, AriaDescriptionAttributes.AriaHasPopup, function(value) { 13535 ASPx.Attr.SetAttribute(element, "aria-haspopup", !!value); 13536 }); 13537 }, 13538 trySetAriaDescribedByAttribute: function(element, description) { 13539 this.executeOnDescription(description, AriaDescriptionAttributes.AriaDescribedBy, function(selectorInfo) { 13540 var descriptor = this.getNodesBySelector(element, selectorInfo.descriptorSelector)[0]; 13541 var target = this.getNodesBySelector(element, selectorInfo.targetSelector)[0]; 13542 if(!target || !descriptor) 13543 return; 13544 ASPx.Attr.SetAttribute(target, "aria-describedby", this.getNodeId(descriptor)); 13545 }); 13546 }, 13547 trySetAriaOwnsAttribute: function(element, description) { 13548 this.executeOnDescription(description, AriaDescriptionAttributes.AriaOwns, function(selector) { 13549 var ownedNodes = this.getNodesBySelector(element, selector); 13550 var ariaOwnsAttributeValue = ""; 13551 for(var i = 0; i < ownedNodes.length; i++) 13552 ariaOwnsAttributeValue += (this.getNodeId(ownedNodes[i]) + (i != ownedNodes.length - 1 ? " " : "")); 13553 ASPx.Attr.SetAttribute(element, "aria-owns", ariaOwnsAttributeValue); 13554 }); 13555 }, 13556 trySetAttribute: function(element, description, ariaAttribute, attributeName) { 13557 this.executeOnDescription(description, ariaAttribute, function(value) { 13558 ASPx.Attr.SetAttribute(element, attributeName, description[ariaAttribute]); 13559 }); 13560 }, 13561 executeOnDescription: function(description, ariaDescAttr, callback) { 13562 var descInfo = description[ariaDescAttr]; 13563 if(ASPx.IsExists(descInfo)) 13564 callback.aspxBind(this)(descInfo); 13565 }, 13566 getNodesBySelector: function(element, selector) { 13567 var id = element.id || ""; 13568 var childNodes = element.querySelectorAll("#" + this.getNodeId(element) + " > " + selector); 13569 ASPx.Attr.SetOrRemoveAttribute(element, "id", id); 13570 return childNodes; 13571 }, 13572 getNodeId: function(node) { 13573 if(!node.id) 13574 node.id = this.createRandomId(); 13575 return node.id; 13576 }, 13577 createRandomId: function() { 13578 return "r" + ASPx.CreateGuid(); 13579 } 13580}); 13581PagerCommands = { 13582 Next : "PBN", 13583 Prev : "PBP", 13584 Last : "PBL", 13585 First : "PBF", 13586 PageNumber : "PN", 13587 PageSize : "PSP" 13588}; 13589ASPx.callbackProcessed = false; 13590ASPx.Callback = function(result, context){ 13591 var collection = aspxGetControlCollection(); 13592 collection.DoFinalizeCallback(); 13593 var control = collection.Get(context); 13594 if(control != null) 13595 control.DoCallback(result); 13596 ASPx.RippleHelper.ReInit(); 13597 ASPx.callbackProcessed = true; 13598}; 13599ASPx.CallbackError = function(result, context){ 13600 var control = aspxGetControlCollection().Get(context); 13601 if(control != null) 13602 control.DoCallbackError(result, false); 13603 ASPx.callbackProcessed = true; 13604}; 13605ASPx.CClick = function(name, evt) { 13606 var control = aspxGetControlCollection().Get(name); 13607 if(control != null) control.DoControlClick(evt); 13608}; 13609function aspxCAInit() { 13610 var isAppInit = typeof(Sys$_Application$initialize) != "undefined" && 13611 ASPx.FunctionIsInCallstack(arguments.callee, Sys$_Application$initialize, 10 ); 13612 aspxGetControlCollection().AtlasInitialize(!isAppInit); 13613} 13614ASPx.Evt.AttachEventToElement(window, "resize", aspxGlobalWindowResize); 13615function aspxGlobalWindowResize(evt){ 13616 aspxGetControlCollection().OnBrowserWindowResize(evt); 13617} 13618ASPx.Evt.AttachEventToElement(window, "unload", aspxClassesUnload); 13619function aspxClassesUnload(evt) { 13620 aspxGetControlCollection().OnDocumentUnload(); 13621} 13622ASPx.attachToLoad(aspxClassesDOMContentLoaded); 13623function aspxClassesDOMContentLoaded(evt){ 13624 aspxGetControlCollection().DOMContentLoaded(); 13625} 13626ASPx.GetControlCollection = aspxGetControlCollection; 13627ASPx.GetControlCollectionCollection = aspxGetControlCollectionCollection; 13628ASPx.GetPersistentControlPropertiesStorage = _aspxGetPersistentControlPropertiesStorage; 13629ASPx.PagerCommands = PagerCommands; 13630ASPx.ELLIPSIS_MARKER_CLASS = ELLIPSIS_MARKER_CLASS; 13631window.ASPxClientBeginCallbackEventArgs = ASPxClientBeginCallbackEventArgs; 13632window.ASPxClientGlobalBeginCallbackEventArgs = ASPxClientGlobalBeginCallbackEventArgs; 13633window.ASPxClientEndCallbackEventArgs = ASPxClientEndCallbackEventArgs; 13634window.ASPxClientGlobalEndCallbackEventArgs = ASPxClientGlobalEndCallbackEventArgs; 13635window.ASPxClientCallbackErrorEventArgs = ASPxClientCallbackErrorEventArgs; 13636window.ASPxClientGlobalCallbackErrorEventArgs = ASPxClientGlobalCallbackErrorEventArgs; 13637window.ASPxClientCustomDataCallbackEventArgs = ASPxClientCustomDataCallbackEventArgs; 13638window.ASPxClientValidationCompletedEventArgs = ASPxClientValidationCompletedEventArgs; 13639window.ASPxClientControlsInitializedEventArgs = ASPxClientControlsInitializedEventArgs; 13640window.ASPxClientControlBeforePronounceEventArgs = ASPxClientControlBeforePronounceEventArgs; 13641window.ASPxClientControlUnloadEventArgs = ASPxClientControlUnloadEventArgs; 13642window.ASPxClientEndFocusEventArgs = ASPxClientEndFocusEventArgs; 13643window.ASPxClientItemFocusedEventArgs = ASPxClientItemFocusedEventArgs; 13644window.ASPxClientControlCollection = ASPxClientControlCollection; 13645window.ASPxClientControlBase = ASPxClientControlBase; 13646window.ASPxClientControl = ASPxClientControl; 13647window.ASPxClientComponent = ASPxClientComponent; 13648})(ASPx); 13649 13650(function () { 13651 var PositionAnimationTransition = ASPx.CreateClass(ASPx.AnimationTransitionBase, { 13652 constructor: function (element, options) { 13653 this.constructor.prototype.constructor.call(this, element, options); 13654 this.direction = options.direction; 13655 this.animationTransition = this.createAnimationTransition(); 13656 AnimationHelper.appendWKAnimationClassNameIfRequired(this.element); 13657 }, 13658 Start: function (to) { 13659 var from = this.GetValue(); 13660 if(ASPx.AnimationUtils.CanUseCssTransform()) { 13661 from = this.convertPosToCssTransformPos(from); 13662 to = this.convertPosToCssTransformPos(to); 13663 } 13664 this.animationTransition.Start(from, to); 13665 }, 13666 SetValue: function (value) { 13667 ASPx.AnimationUtils.SetTransformValue(this.element, value, this.direction == AnimationHelper.SLIDE_VERTICAL_DIRECTION); 13668 }, 13669 GetValue: function () { 13670 return ASPx.AnimationUtils.GetTransformValue(this.element, this.direction == AnimationHelper.SLIDE_VERTICAL_DIRECTION); 13671 }, 13672 createAnimationTransition: function () { 13673 var transition = ASPx.AnimationUtils.CanUseCssTransform() ? this.createTransformAnimationTransition() : this.createPositionAnimationTransition(); 13674 transition.transition = ASPx.AnimationConstants.Transitions.POW_EASE_OUT; 13675 return transition; 13676 }, 13677 createTransformAnimationTransition: function () { 13678 return ASPx.AnimationUtils.createCssAnimationTransition(this.element, { 13679 property: ASPx.AnimationUtils.CanUseCssTransform(), 13680 duration: this.duration, 13681 onComplete: this.onComplete 13682 }); 13683 }, 13684 createPositionAnimationTransition: function () { 13685 return AnimationHelper.createAnimationTransition(this.element, { 13686 property: this.direction == AnimationHelper.SLIDE_VERTICAL_DIRECTION ? "top" : "left", 13687 unit: "px", 13688 duration: this.duration, 13689 onComplete: this.onComplete 13690 }); 13691 }, 13692 convertPosToCssTransformPos: function (position) { 13693 return ASPx.AnimationUtils.GetTransformCssText(position, this.direction == AnimationHelper.SLIDE_VERTICAL_DIRECTION); 13694 } 13695 }); 13696 var AnimationHelper = { 13697 SLIDE_HORIZONTAL_DIRECTION: 0, 13698 SLIDE_VERTICAL_DIRECTION: 1, 13699 SLIDE_TOP_DIRECTION: 0, 13700 SLIDE_RIGHT_DIRECTION: 1, 13701 SLIDE_BOTTOM_DIRECTION: 2, 13702 SLIDE_LEFT_DIRECTION: 3, 13703 SLIDE_CONTAINER_CLASS: "dxAC", 13704 MAXIMUM_DEPTH: 3, 13705 createAnimationTransition: function (element, options) { 13706 if(options.onStep) 13707 options.animationEngineType = AnimationEngineType.JS; 13708 switch(options.animationEngineType) { 13709 case AnimationEngineType.JS: 13710 return ASPx.AnimationUtils.createJsAnimationTransition(element, options); 13711 case AnimationEngineType.CSS: 13712 return ASPx.AnimationUtils.createCssAnimationTransition(element, options); 13713 default: 13714 return ASPx.AnimationUtils.CanUseCssTransition() ? ASPx.AnimationUtils.createCssAnimationTransition(element, options) : 13715 ASPx.AnimationUtils.createJsAnimationTransition(element, options); 13716 } 13717 }, 13718 createMultipleAnimationTransition: function (element, options) { 13719 return ASPx.AnimationUtils.createMultipleAnimationTransition(element, options); 13720 }, 13721 createSimpleAnimationTransition: function (options) { 13722 return ASPx.AnimationUtils.createSimpleAnimationTransition(options); 13723 }, 13724 cancelAnimation: function (element) { 13725 ASPx.AnimationTransitionBase.Cancel(element); 13726 }, 13727 fadeIn: function(element, onComplete, duration, animationEngineType) { 13728 AnimationHelper.fadeTo(element, { 13729 from: 0, to: 1, 13730 onComplete: onComplete, 13731 animationEngineType: animationEngineType || AnimationEngineType.DEFAULT, 13732 duration: duration || ASPx.AnimationConstants.Durations.DEFAULT 13733 }); 13734 }, 13735 fadeOut: function(element, onComplete, duration, animationEngineType) { 13736 AnimationHelper.fadeTo(element, { 13737 from: ASPx.GetElementOpacity(element), to: 0, 13738 onComplete: onComplete, 13739 animationEngineType: animationEngineType || AnimationEngineType.DEFAULT, 13740 duration: duration || ASPx.AnimationConstants.Durations.DEFAULT 13741 }); 13742 }, 13743 fadeTo: function (element, options) { 13744 options.property = "opacity"; 13745 if(!options.duration) 13746 options.duration = ASPx.AnimationConstants.Durations.SHORT; 13747 var transition = AnimationHelper.createAnimationTransition(element, options); 13748 if(!ASPx.IsExists(options.from)) 13749 options.from = transition.GetValue(); 13750 transition.Start(options.from, options.to); 13751 }, 13752 slideIn: function (element, direction, onComplete, animationEngineType, rtl) { 13753 AnimationHelper.setOpacity(element, 1); 13754 var animationContainer = AnimationHelper.getSlideAnimationContainer(element, true, true); 13755 var pos = AnimationHelper.getSlideInStartPos(animationContainer, direction, rtl); 13756 var transition = AnimationHelper.createSlideTransition(animationContainer, direction, 13757 function (el) { 13758 AnimationHelper.resetSlideAnimationContainerSize(animationContainer); 13759 if(onComplete) 13760 onComplete(el); 13761 }, animationEngineType, rtl); 13762 transition.Start(pos, 0); 13763 }, 13764 slideOut: function (element, direction, onComplete, animationEngineType, rtl) { 13765 var animationContainer = AnimationHelper.getSlideAnimationContainer(element, true, true);
13766 var pos = AnimationHelper.getSlideOutFinishPos(animationContainer, direction, rtl); 13767 var transition = AnimationHelper.createSlideTransition(animationContainer, direction, 13768 function (el) { 13769 AnimationHelper.setOpacity(el.firstChild, 0); 13770 if(onComplete) 13771 onComplete(el); 13772 }, animationEngineType, rtl); 13773 transition.Start(pos); 13774 }, 13775 slideTo: function (element, options) { 13776 if(!ASPx.IsExists(options.direction)) 13777 options.direction = AnimationHelper.SLIDE_HORIZONTAL_DIRECTION; 13778 var transition = new PositionAnimationTransition(element, options); 13779 transition.Start(options.to); 13780 }, 13781 setOpacity: function (element, value) { 13782 ASPx.AnimationUtils.setOpacity(element, value); 13783 }, 13784 appendWKAnimationClassNameIfRequired: function (element) { 13785 if(ASPx.AnimationUtils.CanUseCssTransform() && ASPx.Browser.WebKitFamily && !ASPx.ElementHasCssClass(element, "dx-wbv")) 13786 element.className += " dx-wbv"; 13787 }, 13788 findSlideAnimationContainer: function (element) { 13789 var container = element; 13790 for(var i = 0; i < AnimationHelper.MAXIMUM_DEPTH; i++) { 13791 if(container.tagName == "BODY") 13792 return null; 13793 if(ASPx.ElementHasCssClass(container, AnimationHelper.SLIDE_CONTAINER_CLASS)) 13794 return container; 13795 container = container.parentNode; 13796 } 13797 return null; 13798 }, 13799 createSlideAnimationContainer: function (element) { 13800 var rootContainer = document.createElement("DIV"); 13801 ASPx.SetStyles(rootContainer, { 13802 className: AnimationHelper.SLIDE_CONTAINER_CLASS, 13803 overflow: "hidden" 13804 }); 13805 var elementContainer = document.createElement("DIV"); 13806 rootContainer.appendChild(elementContainer); 13807 var parentNode = element.parentNode; 13808 parentNode.insertBefore(rootContainer, element); 13809 elementContainer.appendChild(element); 13810 return rootContainer; 13811 }, 13812 getSlideAnimationContainer: function (element, create, fixSize) { 13813 if(!element) return; 13814 var width = element.offsetWidth; 13815 var height = element.offsetHeight; 13816 var container; 13817 if(element.className == AnimationHelper.SLIDE_CONTAINER_CLASS) 13818 container = element; 13819 if(!container) 13820 container = AnimationHelper.findSlideAnimationContainer(element); 13821 if(!container && create) 13822 container = AnimationHelper.createSlideAnimationContainer(element); 13823 if(container && fixSize) { 13824 ASPx.SetStyles(container, { 13825 width: width, height: height 13826 }); 13827 ASPx.SetStyles(container.firstChild, { 13828 width: width, height: height 13829 }); 13830 } 13831 return container; 13832 }, 13833 resetSlideAnimationContainerSize: function (container) { 13834 ASPx.SetStyles(container, { 13835 width: "", height: "" 13836 }); 13837 ASPx.SetStyles(container.firstChild, { 13838 width: "", height: "" 13839 }); 13840 }, 13841 getModifyProperty: function (direction, rtl) { 13842 if(direction == AnimationHelper.SLIDE_TOP_DIRECTION || direction == AnimationHelper.SLIDE_BOTTOM_DIRECTION) 13843 return "marginTop"; 13844 return rtl ? "margin-right" : "margin-left"; 13845 }, 13846 createSlideTransition: function (animationContainer, direction, complete, animationEngineType, rtl) { 13847 if(rtl == undefined) 13848 rtl = false; 13849 return AnimationHelper.createAnimationTransition(animationContainer.firstChild, { 13850 unit: "px", 13851 property: AnimationHelper.getModifyProperty(direction, rtl), 13852 onComplete: complete, 13853 animationEngineType: animationEngineType 13854 }); 13855 }, 13856 getSlideInStartPos: function (animationContainer, direction, rtl) { 13857 var dir = rtl ? -1 : 1; 13858 switch (direction) { 13859 case AnimationHelper.SLIDE_TOP_DIRECTION: 13860 return animationContainer.offsetHeight; 13861 case AnimationHelper.SLIDE_LEFT_DIRECTION: 13862 return animationContainer.offsetWidth * dir; 13863 case AnimationHelper.SLIDE_RIGHT_DIRECTION: 13864 return -animationContainer.offsetWidth * dir; 13865 case AnimationHelper.SLIDE_BOTTOM_DIRECTION: 13866 return -animationContainer.offsetHeight; 13867 } 13868 }, 13869 getSlideOutFinishPos: function (animationContainer, direction, rtl) { 13870 var dir = rtl ? -1 : 1; 13871 switch (direction) { 13872 case AnimationHelper.SLIDE_TOP_DIRECTION: 13873 return -animationContainer.offsetHeight; 13874 case AnimationHelper.SLIDE_LEFT_DIRECTION: 13875 return -animationContainer.offsetWidth * dir; 13876 case AnimationHelper.SLIDE_RIGHT_DIRECTION: 13877 return animationContainer.offsetWidth * dir; 13878 case AnimationHelper.SLIDE_BOTTOM_DIRECTION: 13879 return animationContainer.offsetHeight; 13880 } 13881 } 13882 }; 13883 var GestureHandler = ASPx.CreateClass(null, { 13884 constructor: function (getAnimationElement, canHandle, allowStart) { 13885 this.getAnimationElement = getAnimationElement; 13886 this.canHandle = canHandle; 13887 this.allowStart = allowStart; 13888 this.startMousePosX = 0; 13889 this.startMousePosY = 0; 13890 this.startTime = null; 13891 this.isEventsPrevented = false; 13892 this.savedElements = []; 13893 }, 13894 OnSelectStart: function(evt) { 13895 ASPx.Evt.PreventEvent(evt); 13896 }, 13897 OnDragStart: function(evt) { 13898 ASPx.Evt.PreventEvent(evt); 13899 }, 13900 OnMouseDown: function (evt) { 13901 this.startMousePosX = ASPx.Evt.GetEventX(evt); 13902 this.startMousePosY = ASPx.Evt.GetEventY(evt); 13903 this.startTime = new Date(); 13904 }, 13905 OnMouseMove: function(evt) { 13906 if(!ASPx.Browser.MobileUI) 13907 ASPx.Selection.Clear(); 13908 if(Math.abs(this.GetCurrentDistanceX(evt)) < GestureHandler.SLIDER_MIN_START_DISTANCE && Math.abs(this.GetCurrentDistanceY(evt)) < GestureHandler.SLIDER_MIN_START_DISTANCE) 13909 GesturesHelper.isExecutedGesture = false; 13910 }, 13911 OnMouseUp: function (evt) { 13912 }, 13913 CanHandleEvent: function (evt) { 13914 return !this.canHandle || this.canHandle(evt); 13915 }, 13916 IsStartAllowed: function(value) { 13917 return !this.allowStart || this.allowStart(value); 13918 }, 13919 RollbackGesture: function () { 13920 }, 13921 GetRubberPosition: function (position) { 13922 return position / GestureHandler.FACTOR_RUBBER; 13923 }, 13924 GetCurrentDistanceX: function (evt) { 13925 return ASPx.Evt.GetEventX(evt) - this.startMousePosX; 13926 }, 13927 GetCurrentDistanceY: function (evt) { 13928 return ASPx.Evt.GetEventY(evt) - this.startMousePosY; 13929 }, 13930 GetDistanceLimit: function () { 13931 return (new Date() - this.startTime) < GestureHandler.MAX_TIME_SPAN ? GestureHandler.MIN_DISTANCE_LIMIT : GestureHandler.MAX_DISTANCE_LIMIT; 13932 }, 13933 GetContainerElement: function () { 13934 }, 13935 AttachPreventEvents: function (evt) { 13936 if(!this.isEventsPrevented) { 13937 var element = ASPx.Evt.GetEventSource(evt); 13938 var container = this.GetContainerElement(); 13939 while(element && element != container) { 13940 ASPx.Evt.AttachEventToElement(element, "mouseup", ASPx.Evt.PreventEvent); 13941 ASPx.Evt.AttachEventToElement(element, "click", ASPx.Evt.PreventEvent); 13942 this.savedElements.push(element); 13943 element = element.parentNode; 13944 } 13945 this.isEventsPrevented = true; 13946 } 13947 }, 13948 DetachPreventEvents: function () { 13949 if(this.isEventsPrevented) { 13950 window.setTimeout(function () { 13951 while(this.savedElements.length > 0) { 13952 var element = this.savedElements.pop(); 13953 ASPx.Evt.DetachEventFromElement(element, "mouseup", ASPx.Evt.PreventEvent); 13954 ASPx.Evt.DetachEventFromElement(element, "click", ASPx.Evt.PreventEvent); 13955 } 13956 }.aspxBind(this), 0); 13957 this.isEventsPrevented = false; 13958 } 13959 } 13960 }); 13961 GestureHandler.MAX_DISTANCE_LIMIT = 70; 13962 GestureHandler.MIN_DISTANCE_LIMIT = 10; 13963 GestureHandler.MIN_START_DISTANCE = 0; 13964 GestureHandler.SLIDER_MIN_START_DISTANCE = 5; 13965 GestureHandler.MAX_TIME_SPAN = 300; 13966 GestureHandler.FACTOR_RUBBER = 4; 13967 GestureHandler.RETURN_ANIMATION_DURATION = 150; 13968 var SwipeSlideGestureHandler = ASPx.CreateClass(GestureHandler, { 13969 constructor: function (getAnimationElement, direction, canHandle, backward, forward, rollback, move) { 13970 this.constructor.prototype.constructor.call(this, getAnimationElement, canHandle); 13971 this.slideElement = this.getAnimationElement(); 13972 this.container = this.slideElement.parentNode; 13973 this.direction = direction; 13974 this.backward = backward; 13975 this.forward = forward; 13976 this.rollback = rollback; 13977 this.slideElementSize = 0; 13978 this.containerElementSize = 0; 13979 this.startSliderElementPosition = 0; 13980 this.centeredSlideElementPosition = 0; 13981 }, 13982 OnMouseDown: function (evt) { 13983 GestureHandler.prototype.OnMouseDown.call(this, evt); 13984 this.slideElementSize = this.GetElementSize(); 13985 this.startSliderElementPosition = this.GetElementPosition(); 13986 this.containerElementSize = this.GetContainerElementSize(); 13987 if(this.slideElementSize <= this.containerElementSize) 13988 this.centeredSlideElementPosition = (this.containerElementSize - this.slideElementSize) / 2; 13989 }, 13990 OnMouseMove: function (evt) { 13991 GestureHandler.prototype.OnMouseMove.call(this, evt); 13992 if(!ASPx.Browser.TouchUI && !ASPx.GetIsParent(this.container, ASPx.Evt.GetEventSource(evt))) { 13993 GesturesHelper.OnDocumentMouseUp(evt); 13994 return; 13995 } 13996 var distance = this.GetCurrentDistance(evt); 13997 if(Math.abs(distance) < GestureHandler.SLIDER_MIN_START_DISTANCE || ASPx.TouchUIHelper.isGesture) 13998 return; 13999 this.SetElementPosition(this.GetCalculatedPosition(distance)); 14000 this.AttachPreventEvents(evt); 14001 ASPx.Evt.PreventEvent(evt); 14002 }, 14003 GetCalculatedPosition: function (distance) { 14004 ASPx.AnimationTransitionBase.Cancel(this.slideElement); 14005 var position = this.startSliderElementPosition + distance, 14006 maxPosition = -(this.slideElementSize - this.containerElementSize), 14007 minPosition = 0; 14008 if(this.centeredSlideElementPosition > 0) 14009 position = this.GetRubberPosition(distance) + this.centeredSlideElementPosition; 14010 else if(position > minPosition) 14011 position = this.GetRubberPosition(distance); 14012 else if(position < maxPosition) 14013 position = this.GetRubberPosition(distance) + maxPosition; 14014 return position; 14015 }, 14016 OnMouseUp: function (evt) { 14017 this.DetachPreventEvents(); 14018 if(this.GetCurrentDistance(evt) != 0) 14019 this.OnMouseUpCore(evt); 14020 }, 14021 OnMouseUpCore: function (evt) { 14022 var distance = this.GetCurrentDistance(evt); 14023 if(this.centeredSlideElementPosition > 0 || this.CheckSlidePanelIsOutOfBounds()) 14024 this.PerformRollback(); 14025 else 14026 this.PerformAction(distance); 14027 }, 14028 PerformAction: function (distance) { 14029 if(Math.abs(distance) < this.GetDistanceLimit()) 14030 this.PerformRollback(); 14031 else if(distance < 0) 14032 this.PerformForward(); 14033 else 14034 this.PerformBackward(); 14035 }, 14036 PerformBackward: function () { 14037 this.backward(); 14038 }, 14039 PerformForward: function () { 14040 this.forward(); 14041 }, 14042 PerformRollback: function () { 14043 this.rollback(); 14044 }, 14045 CheckSlidePanelIsOutOfBounds: function () { 14046 var minOffset = -(this.slideElementSize - this.containerElementSize), maxOffset = 0; 14047 var slideElementPos = this.GetElementPosition(); 14048 if(slideElementPos > maxOffset || slideElementPos < minOffset) 14049 return true; 14050 return false; 14051 }, 14052 GetContainerElement: function () { 14053 return this.container; 14054 }, 14055 GetElementSize: function () { 14056 return this.IsHorizontalDirection() ? this.slideElement.offsetWidth : this.slideElement.offsetHeight; 14057 }, 14058 GetContainerElementSize: function () { 14059 return this.IsHorizontalDirection() ? ASPx.GetClearClientWidth(this.container) : ASPx.GetClearClientHeight(this.container); 14060 }, 14061 GetCurrentDistance: function (evt) { 14062 return this.IsHorizontalDirection() ? this.GetCurrentDistanceX(evt) : this.GetCurrentDistanceY(evt); 14063 }, 14064 GetElementPosition: function () { 14065 return ASPx.AnimationUtils.GetTransformValue(this.slideElement, !this.IsHorizontalDirection()); 14066 }, 14067 SetElementPosition: function (position) { 14068 ASPx.AnimationUtils.SetTransformValue(this.slideElement, position, !this.IsHorizontalDirection()); 14069 }, 14070 IsHorizontalDirection: function () { 14071 return this.direction == AnimationHelper.SLIDE_HORIZONTAL_DIRECTION; 14072 } 14073 }); 14074 var SwipeSimpleSlideGestureHandler = ASPx.CreateClass(SwipeSlideGestureHandler, { 14075 constructor: function (getAnimationElement, direction, canHandle, backward, forward, rollback, updatePosition) { 14076 this.constructor.prototype.constructor.call(this, getAnimationElement, direction, canHandle, backward, forward, rollback); 14077 this.container = this.slideElement; 14078 this.updatePosition = updatePosition; 14079 this.prevDistance = 0; 14080 }, 14081 OnMouseDown: function (evt) { 14082 GestureHandler.prototype.OnMouseDown.call(this, evt); 14083 this.prevDistance = 0; 14084 }, 14085 OnMouseUpCore: function (evt) { 14086 this.PerformAction(this.GetCurrentDistance(evt)); 14087 }, 14088 PerformAction: function (distance) { 14089 if(Math.abs(distance) < this.GetDistanceLimit()) 14090 this.PerformRollback(); 14091 else if(distance < 0) 14092 this.PerformForward(); 14093 else 14094 this.PerformBackward(); 14095 }, 14096 GetCalculatedPosition: function (distance) { 14097 var position = distance - this.prevDistance; 14098 this.prevDistance = distance; 14099 return position; 14100 }, 14101 SetElementPosition: function (position) { 14102 this.updatePosition(position); 14103 } 14104 }); 14105 var SwipeGestureHandler = ASPx.CreateClass(GestureHandler, { 14106 constructor: function (getAnimationElement, canHandle, allowStart, start, allowComplete, complete, cancel, animationEngineType, rtl) { 14107 this.constructor.prototype.constructor.call(this, getAnimationElement, canHandle, allowStart); 14108 this.start = start; 14109 this.allowComplete = allowComplete; 14110 this.complete = complete; 14111 this.cancel = cancel; 14112 this.animationTween = null; 14113 this.currentDistanceX = 0; 14114 this.currentDistanceY = 0; 14115 this.tryStartGesture = false; 14116 this.tryStartScrolling = false; 14117 this.animationEngineType = animationEngineType; 14118 this.rtl = rtl; 14119 this.UpdateAnimationContainer(); 14120 }, 14121 UpdateAnimationContainer: function () { 14122 this.animationContainer = AnimationHelper.getSlideAnimationContainer(this.getAnimationElement(), true, false); 14123 }, 14124 CanHandleEvent: function (evt) { 14125 if(GestureHandler.prototype.CanHandleEvent.call(this, evt)) 14126 return true; 14127 return this.animationTween && this.animationContainer && ASPx.GetIsParent(this.animationContainer, ASPx.Evt.GetEventSource(evt)); 14128 }, 14129 OnMouseDown: function (evt) { 14130 GestureHandler.prototype.OnMouseDown.call(this, evt); 14131 if(this.animationTween) 14132 this.animationTween.Cancel(); 14133 this.currentDistanceX = 0; 14134 this.currentDistanceY = 0; 14135 this.tryStartGesture = false; 14136 this.tryStartScrolling = false; 14137 }, 14138 OnMouseMove: function (evt) { 14139 GestureHandler.prototype.OnMouseMove.call(this, evt);
14140 var isZoomGestureConflict = evt.touches && evt.touches.length > 1; 14141 if (isZoomGestureConflict) 14142 return false; 14143 this.currentDistanceX = this.GetCurrentDistanceX(evt); 14144 this.currentDistanceY = this.GetCurrentDistanceY(evt); 14145 if(this.rtl) 14146 this.currentDistanceX = -this.currentDistanceX; 14147 if(!this.animationTween && !this.tryStartScrolling && (Math.abs(this.currentDistanceX) > 14148 GestureHandler.MIN_START_DISTANCE || Math.abs(this.currentDistanceY) > GestureHandler.MIN_START_DISTANCE)) { 14149 if(Math.abs(this.currentDistanceY) < Math.abs(this.currentDistanceX)) { 14150 this.tryStartGesture = true; 14151 if(this.IsStartAllowed(this.currentDistanceX)) { 14152 this.animationContainer = AnimationHelper.getSlideAnimationContainer(this.getAnimationElement(), true, true); 14153 this.animationTween = AnimationHelper.createSlideTransition(this.animationContainer, AnimationHelper.SLIDE_LEFT_DIRECTION, 14154 function () { 14155 AnimationHelper.resetSlideAnimationContainerSize(this.animationContainer); 14156 this.animationContainer = null; 14157 this.animationTween = null; 14158 }.aspxBind(this), this.animationEngineType, this.rtl); 14159 this.PerformStart(this.currentDistanceX); 14160 this.AttachPreventEvents(evt); 14161 } 14162 } 14163 else 14164 this.tryStartScrolling = true; 14165 } 14166 if(this.animationTween) { 14167 if(this.allowComplete && !this.allowComplete(this.currentDistanceX)) 14168 this.currentDistanceX = this.GetRubberPosition(this.currentDistanceX); 14169 this.animationTween.SetValue(this.currentDistanceX); 14170 } 14171 if(!this.tryStartScrolling && !ASPx.TouchUIHelper.isGesture && evt.touches && evt.touches.length < 2) 14172 ASPx.Evt.PreventEvent(evt); 14173 }, 14174 OnMouseUp: function (evt) { 14175 if(!this.animationTween) { 14176 if(this.tryStartGesture) 14177 this.PerformCancel(this.currentDistanceX); 14178 } 14179 else { 14180 if(Math.abs(this.currentDistanceX) < this.GetDistanceLimit()) 14181 this.RollbackGesture(); 14182 else { 14183 if(this.IsCompleteAllowed(this.currentDistanceX)) { 14184 this.PerformComplete(this.currentDistanceX); 14185 this.animationContainer = null; 14186 this.animationTween = null; 14187 } 14188 else 14189 this.RollbackGesture(); 14190 } 14191 } 14192 this.DetachPreventEvents(); 14193 this.tryStartGesture = false; 14194 this.tryStartScrolling = false; 14195 }, 14196 PerformStart: function (value) { 14197 if(this.start) 14198 this.start(value); 14199 }, 14200 IsCompleteAllowed: function (value) { 14201 return !this.allowComplete || this.allowComplete(value); 14202 }, 14203 PerformComplete: function (value) { 14204 if(this.complete) 14205 this.complete(value); 14206 }, 14207 PerformCancel: function (value) { 14208 if(this.cancel) 14209 this.cancel(value); 14210 }, 14211 RollbackGesture: function () { 14212 this.animationTween.Start(this.currentDistanceX, 0); 14213 }, 14214 ResetGestureElementPosition: function () { 14215 if (this.currentDistanceX === 0) return; 14216 var container = AnimationHelper.getSlideAnimationContainer(this.getAnimationElement()); 14217 var onComplete = function () { AnimationHelper.resetSlideAnimationContainerSize(container); }; 14218 var animation = AnimationHelper.createSlideTransition(container, AnimationHelper.SLIDE_LEFT_DIRECTION, onComplete, this.animationEngineType, this.rtl); 14219 animation.Start(this.currentDistanceX, 0); 14220 }, 14221 GetContainerElement: function () { 14222 return this.animationContainer; 14223 } 14224 }); 14225 var GesturesHelper = { 14226 handlers: {}, 14227 activeHandler: null, 14228 isAttachedEvents: false, 14229 isExecutedGesture: false, 14230 AddSwipeGestureHandler: function (id, getAnimationElement, canHandle, allowStart, start, allowComplete, complete, cancel, animationEngineType, rtl) { 14231 this.handlers[id] = new SwipeGestureHandler(getAnimationElement, canHandle, allowStart, start, allowComplete, complete, cancel, animationEngineType, rtl); 14232 }, 14233 UpdateSwipeAnimationContainer: function (id) { 14234 if(this.handlers[id]) 14235 this.handlers[id].UpdateAnimationContainer(); 14236 }, 14237 AddSwipeSlideGestureHandler: function (id, getAnimationElement, direction, canHandle, backward, forward, rollback, updatePosition) { 14238 if(updatePosition) 14239 this.handlers[id] = new SwipeSimpleSlideGestureHandler(getAnimationElement, direction, canHandle, backward, forward, rollback, updatePosition); 14240 else 14241 this.handlers[id] = new SwipeSlideGestureHandler(getAnimationElement, direction, canHandle, backward, forward, rollback); 14242 }, 14243 getParentDXEditorWithSwipeGestures: function(element) { 14244 return ASPx.GetParent(element, function(parent) {
14245 var parentObj = ASPx.GetControlCollection().Get(parent.id); 14246 return parentObj && parentObj.supportGestures && parentObj.isSwipeGesturesEnabled(); 14247 }); 14248 }, 14249 canHandleMouseDown: function(evt) { 14250 if(!ASPx.Evt.IsLeftButtonPressed(evt)) 14251 return false; 14252 var element = ASPx.Evt.GetEventSource(evt); 14253 var dxFocusedEditor = ASPx.Ident.scripts.ASPxClientEdit && ASPx.GetFocusedEditor(); 14254 if(dxFocusedEditor && dxFocusedEditor.IsEditorElement(element)) { 14255 var elementParentDXEditorWithSwipeGestures = GesturesHelper.getParentDXEditorWithSwipeGestures(element); 14256 if(!elementParentDXEditorWithSwipeGestures || !dxFocusedEditor.IsEditorElement(elementParentDXEditorWithSwipeGestures)) 14257 return false; 14258 } 14259 var isTextEditor = element.tagName == "TEXTAREA" || element.tagName == "INPUT" && ASPx.Attr.GetAttribute(element, "type") == "text"; 14260 if(isTextEditor && document.activeElement == element) 14261 return false; 14262 return true; 14263 }, 14264 OnDocumentDragStart: function(evt) { 14265 if(GesturesHelper.activeHandler) 14266 GesturesHelper.activeHandler.OnDragStart(evt); 14267 }, 14268 OnDocumentSelectStart: function(evt) { 14269 if(GesturesHelper.activeHandler) 14270 GesturesHelper.activeHandler.OnSelectStart(evt); 14271 }, 14272 OnDocumentMouseDown: function (evt) { 14273 if(!GesturesHelper.canHandleMouseDown(evt)) 14274 return; 14275 GesturesHelper.activeHandler = GesturesHelper.FindHandler(evt); 14276 if(GesturesHelper.activeHandler) 14277 GesturesHelper.activeHandler.OnMouseDown(evt); 14278 }, 14279 OnDocumentMouseMove: function (evt) { 14280 if(GesturesHelper.activeHandler) { 14281 GesturesHelper.isExecutedGesture = true; 14282 GesturesHelper.activeHandler.OnMouseMove(evt); 14283 } 14284 }, 14285 OnDocumentMouseUp: function (evt) { 14286 if(GesturesHelper.activeHandler) { 14287 GesturesHelper.activeHandler.OnMouseUp(evt); 14288 GesturesHelper.activeHandler = null; 14289 window.setTimeout(function () { GesturesHelper.isExecutedGesture = false; }, 0); 14290 } 14291 }, 14292 AttachEvents: function () { 14293 if(!GesturesHelper.isAttachedEvents) { 14294 GesturesHelper.Attach(ASPx.Evt.AttachEventToElement); 14295 GesturesHelper.isAttachedEvents = true; 14296 } 14297 }, 14298 DetachEvents: function () { 14299 if(GesturesHelper.isAttachedEvents) { 14300 GesturesHelper.Attach(ASPx.Evt.DetachEventFromElement); 14301 GesturesHelper.isAttachedEvents = false; 14302 } 14303 }, 14304 Attach: function (changeEventsMethod) { 14305 var doc = window.document; 14306 changeEventsMethod(doc, ASPx.TouchUIHelper.touchMouseDownEventName, GesturesHelper.OnDocumentMouseDown); 14307 changeEventsMethod(doc, ASPx.TouchUIHelper.touchMouseMoveEventName, GesturesHelper.OnDocumentMouseMove); 14308 changeEventsMethod(doc, ASPx.TouchUIHelper.touchMouseUpEventName, GesturesHelper.OnDocumentMouseUp); 14309 if(!ASPx.Browser.MobileUI) { 14310 changeEventsMethod(doc, "selectstart", GesturesHelper.OnDocumentSelectStart); 14311 changeEventsMethod(doc, "dragstart", GesturesHelper.OnDocumentDragStart); 14312 } 14313 }, 14314 FindHandler: function (evt) { 14315 var handlers = []; 14316 for(var id in GesturesHelper.handlers) { 14317 if(GesturesHelper.handlers.hasOwnProperty(id)) { 14318 var handler = GesturesHelper.handlers[id]; 14319 if(handler.CanHandleEvent && handler.CanHandleEvent(evt)) 14320 handlers.push(handler); 14321 } 14322 } 14323 if(!handlers.length) 14324 return null; 14325 handlers.sort(function (a, b) { 14326 return ASPx.GetIsParent(a.getAnimationElement(), b.getAnimationElement()) ? 1 : -1; 14327 }); 14328 return handlers[0]; 14329 }, 14330 IsExecutedGesture: function () { 14331 return GesturesHelper.isExecutedGesture; 14332 } 14333 }; 14334 GesturesHelper.AttachEvents(); 14335 var AnimationEngineType = { 14336 "DEFAULT": 0, 14337 "CSS": 1, 14338 "JS": 2 14339 }; 14340 ASPx.AnimationEngineType = AnimationEngineType; 14341 ASPx.AnimationHelper = AnimationHelper; 14342 ASPx.GesturesHelper = GesturesHelper; 14343})(); 14344 14345(function() { 14346 ASPxClientPanelBase = ASPx.CreateClass(ASPxClientControl, { 14347 constructor: function(name) { 14348 this.constructor.prototype.constructor.call(this, name); 14349 this.touchUIScroller = null; 14350 }, 14351 Initialize: function(){ 14352 ASPxClientControl.prototype.Initialize.call(this); 14353 this.touchUIScroller = ASPx.TouchUIHelper.makeScrollableIfRequired(this.GetMainElement()); 14354 }, 14355 getContentElement: function() { 14356 if(this.getAnimationContentContainerElement()) 14357 return this.getAnimationContentContainerElement();
14358 if(this.getScrollContentContainerElement()) 14359 return this.getScrollContentContainerElement(); 14360 if(!ASPx.IsExistsElement(this.contentElement)){ 14361 var element = this.GetMainElement(); 14362 this.contentElement = element && element.tagName == "TABLE" ? element.rows[0].cells[0] : element; 14363 } 14364 return this.contentElement; 14365 }, 14366 getAnimationContentContainerElement: function() { 14367 return null; 14368 }, 14369 getScrollContentContainerElement: function() { 14370 return null; 14371 }, 14372 GetContentHTML: function(){ 14373 return this.GetContentHtml(); 14374 }, 14375 SetContentHTML: function(html){ 14376 this.SetContentHtml(html); 14377 }, 14378 GetContentHtml: function(){ 14379 return this.getContentElement().innerHTML; 14380 }, 14381 SetContentHtml: function(html){ 14382 ASPx.SetInnerHtml(this.getContentElement(), html); 14383 if(this.touchUIScroller) 14384 this.touchUIScroller.ChangeElement(this.getContentElement()); 14385 } 14386 }); 14387 ASPxClientPanelBase.Cast = ASPxClientControl.Cast; 14388 var FixedPanels = {}; 14389 var FixedPositionProperties; 14390 var InitFixedPositionProperties = function(){ 14391 FixedPositionProperties = {}; 14392 FixedPositionProperties["Top"] = { 14393 documentPadding: "padding-top", documentMargin: "margin-top", documentMargin2: "margin-bottom", 14394 contentEdge: "top", oppositeContentEdge: "bottom", size: "offsetHeight", animationSize: "height", oppositePanel: "Bottom" 14395 }; 14396 FixedPositionProperties["Bottom"] = { 14397 documentPadding: "padding-bottom", documentMargin: "margin-top", documentMargin2: "margin-bottom", 14398 contentEdge: "bottom", oppositeContentEdge: "top", size: "offsetHeight", animationSize: "height", oppositePanel: "Top" 14399 }; 14400 FixedPositionProperties["Left"] = { 14401 documentPadding: "padding-left", documentMargin: "margin-left", documentMargin2: "margin-right", 14402 contentEdge: "left", oppositeContentEdge: "right", size: "offsetWidth", animationSize: "width", oppositePanel: "Right" 14403 }; 14404 FixedPositionProperties["Right"] = { 14405 documentPadding: "padding-right", documentMargin: "margin-left", documentMargin2: "margin-right", 14406 contentEdge: "right", oppositeContentEdge: "left", size: "offsetWidth", animationSize: "width", oppositePanel: "Left" 14407 }; 14408 }; 14409 var ExpandDirectionProperties; 14410 var InitExpandDirectionProperties = function(){ 14411 ExpandDirectionProperties = {}; 14412 ExpandDirectionProperties["PopupToLeft"] = { 14413 hAlign: ASPx.PopupUtils.OutsideLeftAlignIndicator, vAlign: ASPx.PopupUtils.TopSidesAlignIndicator, 14414 size: "offsetWidth", animationSize: "width" 14415 }; 14416 ExpandDirectionProperties["PopupToRight"] = { 14417 hAlign: ASPx.PopupUtils.OutsideRightAlignIndicator, vAlign: ASPx.PopupUtils.TopSidesAlignIndicator, 14418 size: "offsetWidth", animationSize: "width" 14419 }; 14420 ExpandDirectionProperties["PopupToTop"] = { 14421 hAlign: ASPx.PopupUtils.LeftSidesAlignIndicator, vAlign: ASPx.PopupUtils.AboveAlignIndicator, 14422 size: "offsetHeight", animationSize: "height" 14423 }; 14424 ExpandDirectionProperties["PopupToBottom"] = { 14425 hAlign: ASPx.PopupUtils.LeftSidesAlignIndicator, vAlign: ASPx.PopupUtils.BelowAlignIndicator, 14426 size: "offsetHeight", animationSize: "height" 14427 }; 14428 }; 14429 var CollapsiblePanelsAutoGenGroupCount = 0; 14430 var CollapsiblePanelsGroups = {}; 14431 var ExpandedPanels = {}; 14432 var DocumentProperties = {}; 14433 var EXPANDED_SELECTOR = "dxpnl-expanded"; 14434 var COLLAPSIBLE_SELECTOR = "dxpnl-collapsible"; 14435 var CENTER_BTN_POSITION_SELECTOR = "dxpnl-cp"; 14436 var EXPAND_BAR_ID = "_EB"; 14437 var MODAL_ELEMENT_ID = "_M"; 14438 var EXPAND_BUTTON_ID = "_EBB"; 14439 var COLLAPSED_STATE_CLASS_NAME = "dxpnl-collapsedState"; 14440 var HIDDEN_STATE_CLASS_NAME = "dxpnl-hiddenState"; 14441 ASPxClientPanel = ASPx.CreateClass(ASPxClientPanelBase, { 14442 constructor: function(name) { 14443 this.constructor.prototype.constructor.call(this, name); 14444 this.animationType = "none"; 14445 this.fixedPosition = this.getFixedPosition(); 14446 this.expandEffect = "Slide"; 14447 this.expandOnPageLoad = false; 14448 this.groupName = ""; 14449 this.fixedPositionOverlap = false; 14450 this.fixedPositionProperties = null; 14451 this.expandDirectionProperties = null; 14452 this.documentMarginsChanged = false; 14453 this.slideAnimationPosProperty = null; 14454 this.slideAnimationExpandBarSize = null; 14455 this.collapseWindowWidth = 0; 14456 this.collapseWindowHeight = 0; 14457 this.hideWindowWidth = 0; 14458 this.hideWindowHeight = 0; 14459 this.modalElement = null; 14460 this.modalElementOpacity = 0.7; 14461 this.modalShowAnimationDuration = ASPx.AnimationConstants.Durations.SHORT; 14462 this.modalHideAnimationDuration = ASPx.AnimationConstants.Durations.SHORT - 50; 14463 this.contentElement = null; 14464 this.expandBarElement = null; 14465 this.expandButtonElement = null; 14466 this.animationContentContainerElement = null; 14467 this.scrollContentContainerElement = null; 14468 this.Collapsed = new ASPxClientEvent(); 14469 this.Expanded = new ASPxClientEvent(); 14470 }, 14471 InlineInitialize: function(){ 14472 ASPxClientPanelBase.prototype.InlineInitialize.call(this); 14473 if(this.fixedPosition) { 14474 if(!FixedPositionProperties) 14475 InitFixedPositionProperties(); 14476 this.fixedPositionProperties = FixedPositionProperties[this.fixedPosition]; 14477 } 14478 if(this.expandEffect.indexOf("Popup") > -1){ 14479 if(!ExpandDirectionProperties)
14480 InitExpandDirectionProperties(); 14481 this.expandDirectionProperties = ExpandDirectionProperties[this.expandEffect]; 14482 } 14483 if(this.isPositionFixed()){ 14484 this.prepareModalElement(); 14485 FixedPanels[this.fixedPosition] = this; 14486 var scrollContainer = this.getScrollContentContainerElement(); 14487 if(scrollContainer && 14488 (scrollContainer.style.overflow !== "" && scrollContainer.style.overflow !== "visible" || 14489 scrollContainer.style.overflowX !== "" && scrollContainer.style.overflowX !== "visible" || 14490 scrollContainer.style.overflowY !== "" && scrollContainer.style.overflowY !== "visible")){ 14491 ASPx.Evt.AttachEventToElement(scrollContainer, "scroll", 14492 function (evt) { 14493 if(ASPx.Evt.GetEventSource(evt) != scrollContainer) 14494 return; 14495 if(typeof(ASPx.GetDropDownCollection) != "undefined") 14496 ASPx.GetDropDownCollection().ProcessControlsInContainer(scrollContainer, function(control) { 14497 control.HideDropDown(); 14498 }); 14499 if(typeof(ASPx.GetMenuCollection) != "undefined") 14500 ASPx.GetMenuCollection().HideAll(); 14501 }.aspxBind(this)); 14502 } 14503 } 14504 if(this.hideWindowWidth > 0 || this.hideWindowHeight > 0) 14505 this.createVisibilityCss(); 14506 if(this.collapseWindowWidth > 0 || this.collapseWindowHeight > 0) 14507 this.createCollapsibilityCss(); 14508 if(this.useAdaptivityClassNames()) 14509 this.ensureAdaptivityClassNames(); 14510 if(this.groupName == ""){ 14511 this.groupName = "DXAutoGenExpandGroup" + CollapsiblePanelsAutoGenGroupCount; 14512 CollapsiblePanelsAutoGenGroupCount++; 14513 } 14514 if(!CollapsiblePanelsGroups[this.groupName]) 14515 CollapsiblePanelsGroups[this.groupName] = []; 14516 CollapsiblePanelsGroups[this.groupName].push(this); 14517 var btnElement = this.getExpandButtonElement(); 14518 if(btnElement){ 14519 ASPx.Evt.AttachEventToElement(btnElement, ASPx.TouchUIHelper.touchMouseUpEventName, 14520 function (evt) { 14521 if(ASPx.Evt.IsLeftButtonPressed(evt)) 14522 this.Toggle(); 14523 }.aspxBind(this)); 14524 } 14525 this.updateFixedPanelContext(); 14526 if(!this.clientEnabled) 14527 this.SetEnabled(this.clientEnabled); 14528 }, 14529 prepareModalElement: function() { 14530 if(!this.isModal()) return; 14531 var modalElement = this.getModalElement(); 14532 this.modalElementOpacity = ASPx.GetCurrentStyle(modalElement).opacity; 14533 ASPx.Evt.AttachEventToElement(modalElement, ASPx.TouchUIHelper.touchMouseUpEventName, 14534 function(evt) { 14535 if(ASPx.Evt.IsLeftButtonPressed(evt)) 14536 this.Collapse(); 14537 }.aspxBind(this)); 14538 modalElement.style.zIndex = ASPx.GetCurrentStyle(this.GetMainElement()).zIndex - 2; 14539 }, 14540 AfterInitialize: function(){ 14541 ASPxClientPanelBase.prototype.AfterInitialize.call(this); 14542 var barElement = this.getExpandBarElement(); 14543 if(barElement && this.isExpandBarChangeVisibilityOnExpanding()) 14544 ASPx.AddClassNameToElement(barElement, "h"); 14545 if(this.expandOnPageLoad) 14546 this.Expand(true); 14547 }, 14548 OnDispose: function () { 14549 if(FixedPanels[this.fixedPosition] === this) 14550 delete FixedPanels[this.fixedPosition]; 14551 if(ASPx.Ident.IsArray(CollapsiblePanelsGroups[this.groupName])){ 14552 ASPx.Data.ArrayRemove(CollapsiblePanelsGroups[this.groupName], this); 14553 if(CollapsiblePanelsGroups[this.groupName].length === 0) 14554 delete CollapsiblePanelsGroups[this.groupName]; 14555 } 14556 if(ExpandedPanels[this.groupName] === this) 14557 delete ExpandedPanels[this.groupName]; 14558 ASPxClientPanelBase.prototype.OnDispose.call(this); 14559 }, 14560 AdjustControlCore: function() { 14561 this.updateExpandButtonPosition(); 14562 this.updateFixedPanelContext(); 14563 }, 14564 GetAdjustedSizes: function() { 14565 var sizes = ASPxClientControl.prototype.GetAdjustedSizes.call(this); 14566 var expandBar = this.getExpandBarElement(); 14567 if(expandBar) { 14568 sizes["expandBarWidth"] = expandBar.offsetWidth; 14569 sizes["expandBarHeight"] = expandBar.offsetHeight; 14570 } 14571 return sizes; 14572 }, 14573 IsDisplayed: function() { 14574 if(ASPxClientPanelBase.prototype.IsDisplayed.call(this)) 14575 return true; 14576 return this.IsDisplayedElement(this.getExpandBarElement()); 14577 }, 14578 IsHidden: function() { 14579 if(!ASPxClientPanelBase.prototype.IsHidden.call(this)) 14580 return false; 14581 return this.IsHiddenElement(this.getExpandBarElement()); 14582 }, 14583 OnBrowserWindowResize: function(e) { 14584 if(this.useAdaptivityClassNames()) 14585 this.ensureAdaptivityClassNames(); 14586 this.onBrowserWindowResizeCore(); 14587 window.setTimeout(function() { 14588 this.onBrowserWindowResizeCore(); 14589 }.aspxBind(this), 0); 14590 }, 14591 BrowserWindowResizeSubscriber: function() { 14592 return this.isPositionFixed() || this.getExpandBarElement() || this.useAdaptivityClassNames(); 14593 }, 14594 HasFixedPosition: function() { 14595 return this.isPositionFixed(); 14596 }, 14597 RegisterInControlTree: function(tree) { 14598 var mainNode = tree.createNode(null, this); 14599 this.registerElementInTree(this.GetMainElement(), tree, mainNode); 14600 this.registerElementInTree(this.getExpandBarElement(), tree, mainNode); 14601 }, 14602 getSizeCore: function(element, sizeProperty){ 14603 return element[sizeProperty]; 14604 }, 14605 getFixedSize: function(sizeProperty){
14606 return this.getSizeCore(this.getFixedElement(), sizeProperty); 14607 }, 14608 getExpandedSize: function(sizeProperty){ 14609 if(this.getExpandBarElement() && this.isElementDisplayed(this.getExpandBarElement())) 14610 return this.getSizeCore(this.GetMainElement(), sizeProperty); 14611 return 0; 14612 }, 14613 GetWidth: function() { 14614 if(!this.getExpandBarElement()) 14615 return ASPxClientControl.prototype.GetWidth.call(this); 14616 var width = 0; 14617 if(this.isElementDisplayed(this.getExpandBarElement())) 14618 width += this.getExpandBarElement().offsetWidth; 14619 if(this.isElementDisplayed(this.GetMainElement()) && (!this.IsExpandedInternal() || !this.isPopupExpanding())) 14620 width += this.GetMainElement().offsetWidth; 14621 return width; 14622 }, 14623 GetHeight: function() { 14624 if(!this.getExpandBarElement()) 14625 return ASPxClientControl.prototype.GetHeight.call(this); 14626 var height = 0; 14627 if(this.isElementDisplayed(this.getExpandBarElement())) 14628 height += this.getExpandBarElement().offsetHeight; 14629 if(this.isElementDisplayed(this.GetMainElement()) && (!this.IsExpandedInternal() || !this.isPopupExpanding())) 14630 height += this.GetMainElement().offsetHeight; 14631 return height; 14632 }, 14633 SetVisible: function (value) { 14634 if(this.clientVisible != value) { 14635 ASPxClientPanelBase.prototype.SetVisible.call(this, value); 14636 var expandBarElement = this.getExpandBarElement(); 14637 if(expandBarElement) ASPx.SetElementDisplay(expandBarElement, value); 14638 this.updateFixedPanelContext(); 14639 } 14640 }, 14641 onBrowserWindowResizeCore: function() { 14642 this.updateExpandButtonPosition(); 14643 this.updateFixedPanelContext(); 14644 this.checkCollapseContent(); 14645 }, 14646 registerElementInTree: function(element, tree, mainNode) { 14647 if(element && element.id) { 14648 var node = tree.createNode(element.id, null); 14649 tree.addRelatedNode(node, mainNode); 14650 } 14651 }, 14652 updateFixedPanelContext: function(){ 14653 if(!this.isPositionFixed()) return; 14654 this.updateDocumentPaddings(); 14655 this.updateMainElementFixedPosition(); 14656 this.updateFixedPanelsPosition(); 14657 }, 14658 updateExpandButtonPosition: function(){ 14659 var expandButton = this.getExpandButtonElement(); 14660 if(!expandButton) return; 14661 var isCenterPosition = expandButton.className.indexOf(CENTER_BTN_POSITION_SELECTOR) > -1; 14662 if(isCenterPosition && expandButton.offsetWidth > 0){ 14663 expandButton.style.width = expandButton.offsetWidth + "px"; 14664 ASPx.SetElementFloat(expandButton, "none"); 14665 } 14666 var correctButtonPosition = false; 14667 if(this.fixedPosition == "Top" || this.fixedPosition == "Bottom") 14668 correctButtonPosition = true; 14669 else if(this.fixedPosition == "Left" || this.fixedPosition == "Right") 14670 correctButtonPosition = isCenterPosition; 14671 else if(this.hasVerticalOrientation()) 14672 correctButtonPosition = isCenterPosition; 14673 else 14674 correctButtonPosition = true; 14675 if(correctButtonPosition) 14676 this.CorrectVerticalAlignment(ASPx.AdjustVerticalMargins, this.getExpandButtonElement, "Btn", true); 14677 }, 14678 updateDocumentPaddings: function(){ 14679 if(!this.fixedPositionProperties) return; 14680 var size = this.getFixedSize(this.fixedPositionProperties.size); 14681 var expandedSize = 0; 14682 if(this.expandEffect == "Slide"){ 14683 expandedSize = this.getExpandedSize(this.fixedPositionProperties.size); 14684 if(this.fixedPosition == "Right" || this.fixedPosition == "Bottom") 14685 expandedSize = -expandedSize; 14686 } 14687 if(!this.fixedPanelCoversViewPort(this.fixedPositionProperties.contentEdge, size)) 14688 this.changeStyleSideAttribute(document.documentElement, "padding", this.fixedPositionProperties.documentPadding, size + "px"); 14689 var documentMarginValue = this.getDocumentPropertyValue(this.fixedPositionProperties.documentMargin); 14690 var documentMargin2Value = this.getDocumentPropertyValue(this.fixedPositionProperties.documentMargin2); 14691 if(expandedSize != 0){ 14692 ASPx.Attr.ChangeStyleAttribute(document.documentElement, this.fixedPositionProperties.documentMargin, (documentMarginValue + expandedSize) + "px"); 14693 ASPx.Attr.ChangeStyleAttribute(document.documentElement, this.fixedPositionProperties.documentMargin2, (documentMargin2Value - expandedSize) + "px"); 14694 this.documentMarginsChanged = true; 14695 } 14696 else if(this.documentMarginsChanged){ 14697 ASPx.Attr.RestoreStyleAttribute(document.documentElement, this.fixedPositionProperties.documentMargin); 14698 ASPx.Attr.RestoreStyleAttribute(document.documentElement, this.fixedPositionProperties.documentMargin2); 14699 this.documentMarginsChanged = false; 14700 } 14701 }, 14702 fixedPanelCoversViewPort: function(contentEdge, size) { 14703 return ((contentEdge === "top" || contentEdge === "bottom") && size >= window.innerHeight) || 14704 ((contentEdge === "left" || contentEdge === "right") && size >= window.innerWidth);
14705 }, 14706 changeStyleSideAttribute: function(element, baseAttr, attr, value){ 14707 if(!ASPx.Browser.IE || ASPx.Browser.Version > 8) 14708 ASPx.Attr.ChangeStyleAttribute(element, attr, value); 14709 else{ 14710 var style = ASPx.GetCurrentStyle(element); 14711 var top = (attr == baseAttr + "-top") ? value : style[baseAttr + "Top"]; 14712 var right = (attr == baseAttr + "-right") ? value : style[baseAttr + "Right"]; 14713 var bottom = (attr == baseAttr + "-bottom") ? value : style[baseAttr + "Bottom"]; 14714 var left = (attr == baseAttr + "-left") ? value : style[baseAttr + "Left"]; 14715 ASPx.Attr.ChangeStyleAttribute(element, baseAttr, top + " " + right + " " + bottom + " " + left); 14716 } 14717 }, 14718 updateMainElementFixedPosition: function(){ 14719 if(!this.fixedPositionProperties) return; 14720 var barElement = this.getExpandBarElement(); 14721 if(barElement){ 14722 var size = this.getSizeCore(barElement, this.fixedPositionProperties.size); 14723 ASPx.Attr.ChangeStyleAttribute(this.GetMainElement(), this.fixedPositionProperties.contentEdge, size + "px"); 14724 } 14725 }, 14726 updateFixedPanelsPosition: function() { 14727 this.updateFixedPanelsEdges(this.updateFixedPanelEdge); 14728 this.updateFixedPanelsEdges(this.updateFixedPanelOppositeEdge); 14729 }, 14730 updateFixedPanelsEdges: function(method) { 14731 if(FixedPanels["Top"]){ 14732 if(FixedPanels["Left"] && !FixedPanels["Top"].fixedPositionOverlap && FixedPanels["Left"].fixedPositionOverlap) 14733 method.call(FixedPanels["Left"], FixedPanels["Top"], FixedPanels["Right"]); 14734 if(FixedPanels["Right"] && !FixedPanels["Top"].fixedPositionOverlap && FixedPanels["Right"].fixedPositionOverlap) 14735 method.call(FixedPanels["Right"], FixedPanels["Top"], FixedPanels["Left"]); 14736 } 14737 if(FixedPanels["Bottom"]){ 14738 if(FixedPanels["Left"] && !FixedPanels["Bottom"].fixedPositionOverlap && FixedPanels["Left"].fixedPositionOverlap) 14739 method.call(FixedPanels["Left"], FixedPanels["Bottom"], FixedPanels["Right"]); 14740 if(FixedPanels["Right"] && !FixedPanels["Bottom"].fixedPositionOverlap && FixedPanels["Right"].fixedPositionOverlap) 14741 method.call(FixedPanels["Right"], FixedPanels["Bottom"], FixedPanels["Left"]); 14742 } 14743 if(FixedPanels["Left"]){ 14744 if(FixedPanels["Top"] && (!FixedPanels["Left"].fixedPositionOverlap || FixedPanels["Top"].fixedPositionOverlap)) 14745 method.call(FixedPanels["Top"], FixedPanels["Left"], FixedPanels["Bottom"]); 14746 if(FixedPanels["Bottom"] && (!FixedPanels["Left"].fixedPositionOverlap || FixedPanels["Bottom"].fixedPositionOverlap)) 14747 method.call(FixedPanels["Bottom"], FixedPanels["Left"], FixedPanels["Top"]); 14748 } 14749 if(FixedPanels["Right"]){ 14750 if(FixedPanels["Top"] && (!FixedPanels["Right"].fixedPositionOverlap || FixedPanels["Top"].fixedPositionOverlap)) 14751 method.call(FixedPanels["Top"], FixedPanels["Right"], FixedPanels["Bottom"]); 14752 if(FixedPanels["Bottom"] && (!FixedPanels["Right"].fixedPositionOverlap || FixedPanels["Bottom"].fixedPositionOverlap)) 14753 method.call(FixedPanels["Bottom"], FixedPanels["Right"], FixedPanels["Top"]); 14754 } 14755 }, 14756 updateFixedPanelEdge: function(panel){ 14757 var size = this.getFixedSize(this.fixedPositionProperties.size); 14758 if(this.expandEffect == "Slide") 14759 size += this.getExpandedSize(this.fixedPositionProperties.size); 14760 this.updateFixedPanelEdgeCore(panel, this.fixedPositionProperties.contentEdge, size); 14761 }, 14762 updateFixedPanelOppositeEdge: function(panel, opppositePanel){ 14763 if(!this.IsExpandedInternal() && opppositePanel) return; 14764 if(this.expandEffect == "Slide") { 14765 var size = this.getExpandedSize(this.fixedPositionProperties.size); 14766 this.updateFixedPanelEdgeCore(panel, this.fixedPositionProperties.oppositeContentEdge, -size); 14767 } 14768 }, 14769 updateFixedPanelEdgeCore: function(panel, edge, size){ 14770 var mainElement = panel.GetMainElement(); 14771 mainElement.style[edge] = size + "px"; 14772 var expandBarElement = panel.getExpandBarElement(); 14773 if(expandBarElement) 14774 expandBarElement.style[edge] = size + "px"; 14775 }, 14776 isPositionFixed: function(){ 14777 return !!this.fixedPositionProperties; 14778 }, 14779 getFixedPosition: function(){ 14780 var cssClass = this.GetMainElement().className; 14781 if(cssClass.indexOf("dxpnl-edge t") > -1) 14782 return "Top"; 14783 if(cssClass.indexOf("dxpnl-edge b") > -1) 14784 return "Bottom"; 14785 if(cssClass.indexOf("dxpnl-edge l") > -1) 14786 return "Left"; 14787 if(cssClass.indexOf("dxpnl-edge r") > -1) 14788 return "Right"; 14789 return null; 14790 }, 14791 isPopupExpanding: function(){ 14792 return !!this.expandDirectionProperties; 14793 }, 14794 isExpandBarChangeVisibilityOnExpanding: function(){ 14795 return !this.isPopupExpanding() && !this.isPositionFixed() && CollapsiblePanelsGroups[this.groupName].length > 1; 14796 }, 14797 createVisibilityCss: function() { 14798 var rules = []; 14799 rules.push({ selector: "#" + this.name, cssText: "display: none!important;" }); 14800 rules.push({ selector: "#" + this.getExpandBarId(), cssText: "display: none!important;" }); 14801 this.insertAdaptivityRules(rules, this.hideWindowWidth, this.hideWindowHeight, HIDDEN_STATE_CLASS_NAME); 14802 }, 14803 createCollapsibilityCss: function() { 14804 var rules = []; 14805 rules.push({ selector: "#" + this.name, cssText: "display: none;" }); 14806 rules.push({ selector: "#" + this.getExpandBarId() + ".dxpnl-bar", cssText: (this.isPositionFixed() ? "display: block;" : "display: table;") }); 14807 rules.push({ selector: "#" + this.name + "." + EXPANDED_SELECTOR, cssText: "display: block!important;" }); 14808 this.insertAdaptivityRules(rules, this.collapseWindowWidth, this.collapseWindowHeight, COLLAPSED_STATE_CLASS_NAME); 14809 }, 14810 insertAdaptivityRules: function(rules, maxWindowWidth, maxWindowHeight, adaptivityClassName) { 14811 var styleSheet = ASPx.GetCurrentStyleSheet(); 14812 if(!styleSheet) return; 14813 var mediaRule = "@media all and (max-width: " + maxWindowWidth + "px), (max-height: " + maxWindowHeight + "px) { "; 14814 for(var i = 0; i < rules.length; i++) 14815 mediaRule += rules[i].selector + "{" + rules[i].cssText + "}"; 14816 mediaRule += "}"; 14817 if(styleSheet.insertRule) 14818 styleSheet.insertRule(mediaRule, styleSheet.cssRules.length); 14819 }, 14820 ensureAdaptivityClassNames: function() { 14821 this.ensureAdaptivityClassName(HIDDEN_STATE_CLASS_NAME, this.hideWindowWidth, this.hideWindowHeight); 14822 this.ensureAdaptivityClassName(COLLAPSED_STATE_CLASS_NAME, this.collapseWindowWidth, this.collapseWindowHeight); 14823 }, 14824 ensureAdaptivityClassName: function(adaptivityClassName, maxWindowWidth, maxWindowHeight) { 14825 var currentDocumentWidth = ASPx.GetCurrentDocumentWidth(); 14826 var currentDocumentHeight = ASPx.GetCurrentDocumentHeight(); 14827 if(currentDocumentWidth <= maxWindowWidth || currentDocumentHeight <= maxWindowHeight) 14828 this.addAdaptivityClassName(adaptivityClassName); 14829 else 14830 this.removeAdaptivityClassName(adaptivityClassName); 14831 }, 14832 addAdaptivityClassName: function(className) { 14833 ASPx.AddClassNameToElement(this.GetMainElement(), className); 14834 if(ASPx.IsExists(this.getExpandBarElement())) 14835 ASPx.AddClassNameToElement(this.getExpandBarElement(), className); 14836 }, 14837 removeAdaptivityClassName: function(className) { 14838 ASPx.RemoveClassNameFromElement(this.GetMainElement(), className); 14839 if(ASPx.IsExists(this.getExpandBarElement())) 14840 ASPx.RemoveClassNameFromElement(this.getExpandBarElement(), className); 14841 }, 14842 useAdaptivityClassNames: function() { 14843 return this.isIE8() 14844 && (this.hideWindowWidth > 0 || this.hideWindowHeight > 0 || this.collapseWindowWidth > 0 || this.collapseWindowHeight > 0); 14845 }, 14846 isIE8: function() { 14847 return ASPx.Browser.IE && ASPx.Browser.Version === 8; 14848 }, 14849 Toggle: function() { 14850 if(this.IsExpandedInternal()) 14851 this.Collapse(); 14852 else 14853 this.Expand(); 14854 }, 14855 IsExpandable: function() { 14856 if(this.GetMainElement().className.indexOf(" " + COLLAPSIBLE_SELECTOR) > -1) 14857 return true; 14858 if(this.collapseWindowWidth > 0 || this.collapseWindowHeight > 0){ 14859 var expandBarElement = this.getExpandBarElement(); 14860 return expandBarElement && ASPx.GetCurrentStyle(expandBarElement).display !== "none"; 14861 } 14862 return false; 14863 }, 14864 IsExpanded: function() { 14865 if(this.IsExpandable()) 14866 return this.IsExpandedInternal(); 14867 return true; 14868 }, 14869 IsExpandedInternal: function() { 14870 return this.GetMainElement().className.indexOf(" " + EXPANDED_SELECTOR) > -1; 14871 }, 14872 Expand: function(preventAnimation) { 14873 if(ExpandedPanels[this.groupName] != this) { 14874 if(ExpandedPanels[this.groupName]) 14875 ExpandedPanels[this.groupName].Collapse(preventAnimation); 14876 this.collapseOppositePanel(preventAnimation); 14877 this.collapseUnfixedPopupPanels(); 14878 ExpandedPanels[this.groupName] = this; 14879 ASPx.GetStateController().SelectElementBySrcElement(this.GetMainElement()); 14880 ASPx.GetStateController().SelectElementBySrcElement(this.getExpandButtonElement()); 14881 if(this.isModal()) { 14882 var modalElement = this.getModalElement(); 14883 ASPx.AnimationHelper.fadeTo(modalElement, { from: 0, to: this.modalElementOpacity, duration: this.modalShowAnimationDuration }); 14884 } 14885 ASPx.GetControlCollection().AdjustControls(this.GetMainElement()); 14886 if(this.isPopupExpanding() && !this.isPositionFixed()) 14887 this.updateMainElementPosition(true); 14888 if(this.isExpandBarChangeVisibilityOnExpanding())
14889 this.slideAnimationExpandBarSize = this.getSlideAnimationSize(this.getExpandBarElement(), true); 14890 ASPx.GetStateController().SelectElementBySrcElement(this.getExpandBarElement()); 14891 if(!preventAnimation && this.animationType == "slide") 14892 this.startSlideAnimation(this.GetMainElement(), false); 14893 else if(!preventAnimation && this.animationType == "fade") 14894 this.startFadeAnimation(this.GetMainElement(), false); 14895 else 14896 this.expandCore(); 14897 } 14898 }, 14899 Collapse: function(preventAnimation) { 14900 if(ExpandedPanels[this.groupName] == this) { 14901 ExpandedPanels[this.groupName] = null; 14902 this.collapseUnfixedPopupPanels(); 14903 if(this.isExpandBarChangeVisibilityOnExpanding()){ 14904 ASPx.GetStateController().DeselectElementBySrcElement(this.getExpandBarElement()); 14905 this.slideAnimationExpandBarSize = this.getSlideAnimationSize(this.getExpandBarElement(), true); 14906 ASPx.GetStateController().SelectElementBySrcElement(this.getExpandBarElement()); 14907 } 14908 if(this.isModal()) { 14909 var modalElement = this.getModalElement(), 14910 fromOpacity = ASPx.GetCurrentStyle(modalElement).opacity; 14911 ASPx.AnimationHelper.fadeTo(modalElement, { from: fromOpacity, to: 0, duration: this.modalHideAnimationDuration }); 14912 } 14913 if(!preventAnimation && this.animationType == "slide") 14914 this.startSlideAnimation(this.GetMainElement(), true); 14915 else if(!preventAnimation && this.animationType == "fade") 14916 this.startFadeAnimation(this.GetMainElement(), true); 14917 else 14918 this.collapseCore(); 14919 } 14920 }, 14921 isModal: function() { 14922 return !!this.getModalElement(); 14923 }, 14924 expandCore: function() { 14925 if(this.isPositionFixed()) { 14926 this.updateFixedPanelContext(); 14927 } 14928 this.raiseExpanded(); 14929 }, 14930 collapseCore: function() { 14931 ASPx.GetStateController().DeselectElementBySrcElement(this.GetMainElement()); 14932 ASPx.GetStateController().DeselectElementBySrcElement(this.getExpandButtonElement()); 14933 if(this.isPopupExpanding() && !this.isPositionFixed()) 14934 this.updateMainElementPosition(false); 14935 ASPx.GetStateController().DeselectElementBySrcElement(this.getExpandBarElement()); 14936 if(this.isPositionFixed()) { 14937 this.updateFixedPanelContext(); 14938 } 14939 this.slideAnimationPosProperty = null; 14940 this.raiseCollapsed(); 14941 }, 14942 collapseOppositePanel: function(preventAnimation) { 14943 if(!this.fixedPositionProperties) return; 14944 if(FixedPanels[this.fixedPositionProperties.oppositePanel]) 14945 FixedPanels[this.fixedPositionProperties.oppositePanel].Collapse(preventAnimation); 14946 }, 14947 collapseUnfixedPopupPanels: function() { 14948 if(!this.isPositionFixed() || this.isPopupExpanding()) return; 14949 for(var groupName in ExpandedPanels){ 14950 if(ExpandedPanels[groupName] && !ExpandedPanels[groupName].fixedPosition && ExpandedPanels[groupName].isPopupExpanding()) 14951 ExpandedPanels[groupName].Collapse(true); 14952 } 14953 }, 14954 saveOpacity: function(element) { 14955 if(!this.isIE8()) 14956 ASPx.Attr.SaveStyleAttribute(element, "opacity"); 14957 else if(ASPx.GetCurrentStyle(element).filter) 14958 ASPx.Attr.SaveStyleAttribute(element, "filter"); 14959 }, 14960 restoreOpacity: function(element) { 14961 if(!this.isIE8()) 14962 ASPx.Attr.RestoreStyleAttribute(element, "opacity"); 14963 else 14964 ASPx.Attr.RestoreStyleAttribute(element, "filter"); 14965 }, 14966 startFadeAnimation: function (element, isCollapsing) { 14967 this.saveOpacity(element); 14968 var onComplete = function() { this.finishFadeAnimation(element, isCollapsing); }.aspxBind(this); 14969 if(isCollapsing) 14970 ASPx.AnimationHelper.fadeOut(element, onComplete, ASPx.AnimationConstants.Durations.SHORT); 14971 else 14972 ASPx.AnimationHelper.fadeIn(element, onComplete, ASPx.AnimationConstants.Durations.SHORT); 14973 }, 14974 finishFadeAnimation: function (element, isCollapsing) { 14975 this.restoreOpacity(element); 14976 if(isCollapsing) 14977 this.collapseCore(); 14978 else 14979 this.expandCore(); 14980 }, 14981 startSlideAnimation: function(element, isCollapsing) { 14982 var sizeProperty = this.getSlideAnimationSizeProperty(); 14983 ASPx.Attr.ChangeStyleAttribute(element, "overflow", "auto"); 14984 var offsetWidth = element.offsetWidth; 14985 var offsetHeight = element.offsetHeight; 14986 ASPx.Attr.RestoreStyleAttribute(element, "overflow"); 14987 ASPx.Attr.SaveStyleAttribute(element, sizeProperty); 14988 if(element.style.overflow !== "") 14989 ASPx.Attr.ChangeStyleAttribute(element, "overflow", "hidden"); 14990 else { 14991 ASPx.Attr.ChangeStyleAttribute(element, "overflow-x", "hidden"); 14992 ASPx.Attr.ChangeStyleAttribute(element, "overflow-y", "hidden"); 14993 } 14994 var contentContainer = this.getAnimationContentContainerElement(); 14995 if(contentContainer) { 14996 if(contentContainer.style.overflow !== "") 14997 ASPx.Attr.ChangeStyleAttribute(contentContainer, "overflow", "hidden"); 14998 else{ 14999 ASPx.Attr.ChangeStyleAttribute(contentContainer, "overflow-x", "hidden"); 15000 ASPx.Attr.ChangeStyleAttribute(contentContainer, "overflow-y", "hidden"); 15001 } 15002 ASPx.Attr.ChangeStyleAttribute(contentContainer, "width", offsetWidth - ASPx.GetLeftRightBordersAndPaddingsSummaryValue(element) + "px"); 15003 ASPx.Attr.ChangeStyleAttribute(contentContainer, "height", offsetHeight - ASPx.GetTopBottomBordersAndPaddingsSummaryValue(element) + "px"); 15004 } 15005 var transitionProperties = { 15006 duration: ASPx.AnimationConstants.Durations.SHORT, 15007 onComplete: function() { this.finishSlideAnimation(element, isCollapsing); }.aspxBind(this) 15008 }; 15009 if(this.isPositionFixed()) 15010 transitionProperties.onStep = function() { this.performSlideAnimationStep(); }.aspxBind(this); 15011 var transition = ASPx.AnimationHelper.createMultipleAnimationTransition(element, transitionProperties);
15012 var size = this.getSlideAnimationSize(element, !this.isPositionFixed()); 15013 var startSize = isCollapsing ? size : 0; 15014 var endSize = isCollapsing ? 0 : size; 15015 if(this.isExpandBarChangeVisibilityOnExpanding() && this.slideAnimationExpandBarSize){ 15016 if(startSize == 0) 15017 startSize = this.slideAnimationExpandBarSize; 15018 if(endSize == 0) 15019 endSize = this.slideAnimationExpandBarSize; 15020 } 15021 var properties = {}; 15022 properties[sizeProperty] = { from: startSize, to: endSize, unit: "px" }; 15023 if(!isCollapsing) 15024 ASPx.Attr.ChangeStyleAttribute(element, sizeProperty, startSize + "px"); 15025 if(this.slideAnimationPosProperty){ 15026 var position = parseInt(element.style[this.slideAnimationPosProperty]); 15027 var startPosition = isCollapsing ? position : position + size; 15028 var endPosition = isCollapsing ? position + size : position; 15029 properties[this.slideAnimationPosProperty] = { from: startPosition, to: endPosition, unit: "px" }; 15030 if(!isCollapsing) 15031 ASPx.Attr.ChangeStyleAttribute(element, this.slideAnimationPosProperty, startPosition + "px"); 15032 } 15033 transition.Start(properties); 15034 }, 15035 finishSlideAnimation: function(element, isCollapsing) { 15036 var sizeProperty = this.getSlideAnimationSizeProperty(); 15037 ASPx.Attr.RestoreStyleAttribute(element, sizeProperty); 15038 ASPx.Attr.RestoreStyleAttribute(element, "overflow"); 15039 ASPx.Attr.RestoreStyleAttribute(element, "overflow-x"); 15040 ASPx.Attr.RestoreStyleAttribute(element, "overflow-y"); 15041 var contentContainer = this.getAnimationContentContainerElement(); 15042 if(contentContainer) { 15043 ASPx.Attr.RestoreStyleAttribute(contentContainer, "overflow"); 15044 ASPx.Attr.RestoreStyleAttribute(contentContainer, "overflow-x"); 15045 ASPx.Attr.RestoreStyleAttribute(contentContainer, "overflow-y"); 15046 ASPx.Attr.RestoreStyleAttribute(contentContainer, "width"); 15047 ASPx.Attr.RestoreStyleAttribute(contentContainer, "height"); 15048 } 15049 if(isCollapsing) 15050 this.collapseCore(); 15051 else 15052 this.expandCore(); 15053 }, 15054 performSlideAnimationStep: function() { 15055 this.updateFixedPanelContext(); 15056 }, 15057 getSlideAnimationSizeProperty: function() { 15058 if(this.fixedPositionProperties) 15059 return this.fixedPositionProperties.animationSize; 15060 else if(this.expandDirectionProperties) 15061 return this.expandDirectionProperties.animationSize; 15062 else 15063 return this.hasVerticalOrientation() ? "width" : "height"; 15064 }, 15065 getSlideAnimationSize: function(element, fullSize) { 15066 var sizeProperty; 15067 if(this.fixedPositionProperties) 15068 sizeProperty = this.fixedPositionProperties.size; 15069 else if(this.expandDirectionProperties) 15070 sizeProperty = this.expandDirectionProperties.size; 15071 else 15072 sizeProperty = this.hasVerticalOrientation() ? "offsetWidth" : "offsetHeight"; 15073 var size = this.getSizeCore(element, sizeProperty); 15074 if(fullSize) { 15075 if(sizeProperty == "offsetWidth") 15076 size -= ASPx.GetHorizontalBordersWidth(element); 15077 else 15078 size -= ASPx.GetVerticalBordersWidth(element); 15079 } 15080 else { 15081 if(sizeProperty == "offsetWidth") 15082 size -= ASPx.GetLeftRightBordersAndPaddingsSummaryValue(element); 15083 else 15084 size -= ASPx.GetTopBottomBordersAndPaddingsSummaryValue(element); 15085 } 15086 return size; 15087 }, 15088 getSlideAnimationPosProperty: function(x, y) { 15089 if(this.expandEffect == "PopupToTop") 15090 return !y.isInverted ? "top" : null; 15091 if(this.expandEffect == "PopupToBottom") 15092 return y.isInverted ? "top" : null; 15093 if(this.expandEffect == "PopupToLeft") 15094 return !x.isInverted ? "left" : null; 15095 if(this.expandEffect == "PopupToRight") 15096 return y.isInverted ? "left" : null; 15097 return null; 15098 }, 15099 hasVerticalOrientation: function() { 15100 var float = ASPx.GetElementFloat(this.GetMainElement()); 15101 return (float === "left" || float === "right"); 15102 }, 15103 updateMainElementPosition: function(expanded) { 15104 if(!this.expandDirectionProperties) return; 15105 if(expanded) 15106 this.updateMainElementExpandedPosition(this.GetMainElement()); 15107 else 15108 this.updateMainElementCollapsedPosition(this.GetMainElement()); 15109 }, 15110 updateMainElementExpandedPosition: function(element) { 15111 if(element.style.width === "100%") 15112 ASPx.Attr.ChangeStyleAttribute(element, "width", (element.parentNode.offsetWidth - ASPx.GetLeftRightMargins(element)) + "px"); 15113 if(element.style.height === "100%") 15114 ASPx.Attr.ChangeStyleAttribute(element, "height", (element.parentNode.offsetHeight - ASPx.GetTopBottomMargins(element)) + "px"); 15115 ASPx.Attr.ChangeStyleAttribute(element, "position", "absolute"); 15116 var barElement = this.getExpandBarElement(); 15117 var x = ASPx.PopupUtils.GetPopupAbsoluteX(element, 15118 barElement, this.expandDirectionProperties.hAlign, 0, 0, 0, false, false); 15119 var y = ASPx.PopupUtils.GetPopupAbsoluteY(element, 15120 barElement, this.expandDirectionProperties.vAlign, 0, 0, 0, true, false); 15121 ASPx.SetAbsoluteX(element, x.position); 15122 ASPx.SetAbsoluteY(element, y.position);
15123 this.slideAnimationPosProperty = this.getSlideAnimationPosProperty(x, y); 15124 }, 15125 updateMainElementCollapsedPosition: function(element) { 15126 ASPx.Attr.RestoreStyleAttribute(element, "position"); 15127 ASPx.Attr.RestoreStyleAttribute(element, "left"); 15128 ASPx.Attr.RestoreStyleAttribute(element, "top"); 15129 ASPx.Attr.RestoreStyleAttribute(element, "width"); 15130 ASPx.Attr.RestoreStyleAttribute(element, "height"); 15131 }, 15132 checkCollapseContent: function(){ 15133 if(!this.getExpandBarElement()) return; 15134 if(this.IsExpandedInternal()){ 15135 if(CollapsiblePanelsGroups[this.groupName].length === 1 && !this.isElementDisplayed(this.getExpandBarElement()) && this.isElementDisplayed(this.GetMainElement())) 15136 this.Collapse(true); 15137 if(!this.isPositionFixed() && this.isPopupExpanding()) 15138 this.Collapse(true); 15139 } 15140 }, 15141 raiseCollapsed: function() { 15142 if(!this.Collapsed.IsEmpty()) { 15143 var args = new ASPxClientEventArgs(); 15144 this.Collapsed.FireEvent(this, args); 15145 } 15146 }, 15147 raiseExpanded: function() { 15148 if(!this.Expanded.IsEmpty()) { 15149 var args = new ASPxClientEventArgs(); 15150 this.Expanded.FireEvent(this, args); 15151 } 15152 }, 15153 getAnimationContentContainerElement: function() { 15154 if(!ASPx.IsExistsElement(this.animationContentContainerElement)) 15155 this.animationContentContainerElement = ASPx.GetChildByClassName(this.GetMainElement(), "dxpnl-acc"); 15156 return this.animationContentContainerElement; 15157 }, 15158 getScrollContentContainerElement: function() { 15159 if (!ASPx.IsExistsElement(this.scrollContentContainerElement)) { 15160 var mainElement = this.GetMainElement(); 15161 this.scrollContentContainerElement = ASPx.GetNodesByPartialClassName(this.GetMainElement(), "dxpnl-scc")[0]; 15162 if (mainElement.tagName == "DIV" && this.scrollContentContainerElement && this.scrollContentContainerElement.parentNode != mainElement) 15163 this.scrollContentContainerElement = null; 15164 } 15165 return this.scrollContentContainerElement; 15166 }, 15167 getExpandBarElement: function() { 15168 if(!ASPx.IsExistsElement(this.expandBarElement)) 15169 this.expandBarElement = ASPx.GetElementById(this.getExpandBarId()); 15170 return this.expandBarElement; 15171 }, 15172 getExpandBarId: function() { 15173 return this.name + EXPAND_BAR_ID; 15174 }, 15175 getModalElement: function() { 15176 if(!ASPx.IsExistsElement(this.modalElement)) 15177 this.modalElement = ASPx.GetElementById(this.getModalELementId()); 15178 return this.modalElement; 15179 }, 15180 getModalELementId: function() { 15181 return this.name + MODAL_ELEMENT_ID; 15182 }, 15183 getExpandButtonElement: function() { 15184 if(!ASPx.IsExistsElement(this.expandButtonElement)) 15185 this.expandButtonElement = ASPx.GetElementById(this.name + EXPAND_BUTTON_ID); 15186 return this.expandButtonElement; 15187 }, 15188 getFixedElement: function(){ 15189 if(this.getExpandBarElement() && this.isElementDisplayed(this.getExpandBarElement())) 15190 return this.getExpandBarElement(); 15191 else 15192 return this.GetMainElement(); 15193 }, 15194 getDocumentPropertyValue: function(attr){ 15195 if(DocumentProperties[attr] === undefined){ 15196 var currentStyle = ASPx.GetCurrentStyle(document.documentElement); 15197 var attrValue = parseInt(ASPx.Attr.GetAttribute(currentStyle, attr)); 15198 DocumentProperties[attr] = !isNaN(attrValue) ? attrValue : 0; 15199 } 15200 return DocumentProperties[attr]; 15201 }, 15202 isElementDisplayed: function(element){ 15203 return ASPx.GetCurrentStyle(element).display != "none"; 15204 } 15205 }); 15206 ASPxClientPanel.Cast = ASPxClientControl.Cast; 15207 window.ASPxClientPanelBase = ASPxClientPanelBase; 15208 window.ASPxClientPanel = ASPxClientPanel; 15209})(); 15210(function () { 15211var PopupUtils = { 15212 NotSetAlignIndicator: "NotSet", 15213 InnerAlignIndicator: "Sides", 15214 OutsideLeftAlignIndicator: "OutsideLeft", 15215 LeftSidesAlignIndicator: "LeftSides", 15216 RightSidesAlignIndicator: "RightSides", 15217 OutsideRightAlignIndicator: "OutsideRight", 15218 CenterAlignIndicator: "Center", 15219 AboveAlignIndicator: "Above", 15220 TopSidesAlignIndicator: "TopSides", 15221 MiddleAlignIndicator: "Middle", 15222 BottomSidesAlignIndicator: "BottomSides", 15223 BelowAlignIndicator: "Below", 15224 WindowCenterAlignIndicator: "WindowCenter", 15225 LeftAlignIndicator: "Left", 15226 RightAlignIndicator: "Right", 15227 TopAlignIndicator: "Top", 15228 BottomAlignIndicator: "Bottom", 15229 WindowLeftAlignIndicator: "WindowLeft", 15230 WindowRightAlignIndicator: "WindowRight", 15231 WindowTopAlignIndicator: "WindowTop", 15232 WindowBottomAlignIndicator: "WindowBottom", 15233 IsAlignNotSet: function (align) { 15234 return align == PopupUtils.NotSetAlignIndicator; 15235 }, 15236 IsInnerAlign: function (align) { 15237 return align.indexOf(PopupUtils.InnerAlignIndicator) != -1; 15238 }, 15239 IsRightSidesAlign: function(align) { 15240 return align == PopupUtils.RightSidesAlignIndicator; 15241 }, 15242 IsOutsideRightAlign: function(align) { 15243 return align == PopupUtils.OutsideRightAlignIndicator; 15244 }, 15245 IsCenterAlign: function(align) { 15246 return align == PopupUtils.CenterAlignIndicator; 15247 }, 15248 FindPopupElementById: function (id) { 15249 if(id == "") 15250 return null; 15251 var popupElement = ASPx.GetElementById(id); 15252 if(!ASPx.IsExistsElement(popupElement)) { 15253 var idParts = id.split("_"); 15254 var uniqueId = idParts.join("$"); 15255 popupElement = ASPx.GetElementById(uniqueId); 15256 } 15257 return popupElement; 15258 }, 15259 FindEventSourceParentByTestFunc: function (evt, testFunc) { 15260 return ASPx.GetParent(ASPx.Evt.GetEventSource(evt), testFunc); 15261 }, 15262 PreventContextMenu: function (evt) { 15263 ASPx.Evt.PreventEventAndBubble(evt); 15264 if(ASPx.Browser.WebKitFamily) 15265 evt.returnValue = false; 15266 }, 15267 GetDocumentClientWidthForPopup: function() { 15268 return ASPx.Browser.WebKitTouchUI ? document.body.offsetWidth : ASPx.GetDocumentClientWidth(); 15269 }, 15270 GetDocumentClientHeightForPopup: function() { 15271 return ASPx.Browser.WebKitTouchUI ? document.body.offsetHeight : ASPx.GetDocumentClientHeight(); 15272 }, 15273 AdjustPositionToClientScreen: function (element, pos, rtl, isX) { 15274 var min = isX ? ASPx.GetDocumentScrollLeft() : ASPx.GetDocumentScrollTop(), 15275 max = min + (isX ? ASPx.GetDocumentClientWidth() : ASPx.GetDocumentClientHeight()); 15276 max -= (isX ? element.offsetWidth : element.offsetHeight); 15277 if(rtl && isX) { 15278 if(pos < min) pos = min; 15279 if(pos > max) pos = max; 15280 } else { 15281 if(pos > max) pos = max; 15282 if(pos < min) pos = min; 15283 } 15284 return pos; 15285 }, 15286 GetPopupAbsoluteX: function(element, popupElement, hAlign, hOffset, x, left, rtl, isPopupFullCorrectionOn) { 15287 return PopupUtils.getPopupAbsolutePos(element, popupElement, hAlign, hOffset, x, left, rtl, isPopupFullCorrectionOn, false, false, true); 15288 }, 15289 GetPopupAbsoluteY: function (element, popupElement, vAlign, vOffset, y, top, isPopupFullCorrectionOn, ignoreAlignWithoutScrollReserve, ignorePopupElementBorders) { 15290 return PopupUtils.getPopupAbsolutePos(element, popupElement, vAlign, vOffset, y, top, false, isPopupFullCorrectionOn, ignoreAlignWithoutScrollReserve, ignorePopupElementBorders, false); 15291 }, 15292 getPopupAbsolutePos: function(element, popupElement, align, offset, startPos, startPosInit, rtl, isPopupFullCorrectionOn, ignoreAlignWithoutScrollReserve, ignorePopupElementBorders, isHorizontal) { 15293 var calculator = getPositionCalculator(); 15294 calculator.applyParams(element, popupElement, align, offset, startPos, startPosInit, rtl, isPopupFullCorrectionOn, ignoreAlignWithoutScrollReserve, ignorePopupElementBorders, isHorizontal); 15295 var position = calculator.getPopupAbsolutePos(); 15296 calculator.disposeState(); 15297 return position; 15298 }, 15299 RemoveFocus: function (parent) { 15300 var div = document.createElement('div'); 15301 div.tabIndex = "-1"; 15302 PopupUtils.ConcealDivElement(div); 15303 parent.appendChild(div); 15304 if(ASPx.IsFocusable(div)) 15305 div.focus(); 15306 ASPx.RemoveElement(div); 15307 }, 15308 ConcealDivElement: function (div) { 15309 div.style.position = "absolute"; 15310 div.style.left = 0; 15311 div.style.top = 0; 15312 if(ASPx.Browser.WebKitFamily) { 15313 div.style.opacity = 0; 15314 div.style.width = 1; 15315 div.style.height = 1; 15316 } else { 15317 div.style.border = 0; 15318 div.style.width = 0; 15319 div.style.height = 0; 15320 } 15321 }, 15322 InitAnimationProperties: function(element, onAnimStopCallString) { 15323 element.popuping = true; 15324 element.onAnimStopCallString = onAnimStopCallString; 15325 }, 15326 InitAnimationDiv: function (element, x, y, onAnimStopCallString, skipSizeInit) { 15327 PopupUtils.InitAnimationProperties(element, onAnimStopCallString); 15328 PopupUtils.InitAnimationDivCore(element); 15329 if(!skipSizeInit) { 15330 ASPx.SetStyles(element, { width: "", height: "" }); 15331 ASPx.SetStyles(element, { width: element.offsetWidth, height: element.offsetHeight });
15332 } 15333 ASPx.SetStyles(element, { left: x, top: y }); 15334 }, 15335 InitAnimationDivCore: function (element) { 15336 ASPx.SetStyles(element, { 15337 overflow: "hidden", 15338 position: "absolute" 15339 }); 15340 }, 15341 StartSlideAnimation: function (animationDivElement, element, iframeElement, duration, preventChangingWidth, preventChangingHeight) { 15342 if(iframeElement) { 15343 var endLeft = ASPx.PxToInt(iframeElement.style.left); 15344 var endTop = ASPx.PxToInt(iframeElement.style.top); 15345 var startLeft = ASPx.PxToInt(element.style.left) < 0 ? endLeft : animationDivElement.offsetLeft + animationDivElement.offsetWidth; 15346 var startTop = ASPx.PxToInt(element.style.top) < 0 ? endTop : animationDivElement.offsetTop + animationDivElement.offsetHeight; 15347 var properties = { 15348 left: { from: startLeft, to: endLeft, unit: "px" }, 15349 top: { from: startTop, to: endTop, unit: "px" } 15350 }; 15351 if(!preventChangingWidth) 15352 properties.width = { to: element.offsetWidth, unit: "px" }; 15353 if(!preventChangingHeight) 15354 properties.height = { to: element.offsetHeight, unit: "px" }; 15355 ASPx.AnimationHelper.createMultipleAnimationTransition(iframeElement, { 15356 duration: duration 15357 }).Start(properties); 15358 } 15359 ASPx.AnimationHelper.createMultipleAnimationTransition(element, { 15360 duration: duration, 15361 onComplete: function () { PopupUtils.AnimationFinished(animationDivElement, element); } 15362 }).Start({ 15363 left: { to: 0, unit: "px" }, 15364 top: { to: 0, unit: "px" } 15365 }); 15366 }, 15367 AnimationFinished: function (animationDivElement, element) { 15368 if(PopupUtils.StopAnimation(animationDivElement, element) && ASPx.IsExists(animationDivElement.onAnimStopCallString) && 15369 animationDivElement.onAnimStopCallString !== "") { 15370 window.setTimeout(animationDivElement.onAnimStopCallString, 0); 15371 } 15372 }, 15373 StopAnimation: function (animationDivElement, element) { 15374 if(animationDivElement.popuping) { 15375 ASPx.AnimationHelper.cancelAnimation(element); 15376 animationDivElement.popuping = false; 15377 animationDivElement.style.overflow = "visible"; 15378 return true; 15379 } 15380 return false; 15381 }, 15382 GetAnimationHorizontalDirection: function (popupPosition, horizontalAlign, verticalAlign, rtl) { 15383 if(PopupUtils.IsInnerAlign(horizontalAlign) 15384 && !PopupUtils.IsInnerAlign(verticalAlign) 15385 && !PopupUtils.IsAlignNotSet(verticalAlign)) 15386 return 0; 15387 var toTheLeft = (horizontalAlign == PopupUtils.OutsideLeftAlignIndicator || horizontalAlign == PopupUtils.RightSidesAlignIndicator || (horizontalAlign == PopupUtils.NotSetAlignIndicator && rtl)) ^ popupPosition.isInverted; 15388 return toTheLeft ? 1 : -1; 15389 }, 15390 GetAnimationVerticalDirection: function (popupPosition, horizontalAlign, verticalAlign) { 15391 if(PopupUtils.IsInnerAlign(verticalAlign) 15392 && !PopupUtils.IsInnerAlign(horizontalAlign) 15393 && !PopupUtils.IsAlignNotSet(horizontalAlign)) 15394 return 0; 15395 var toTheTop = (verticalAlign == PopupUtils.AboveAlignIndicator || verticalAlign == PopupUtils.BottomSidesAlignIndicator) ^ popupPosition.isInverted; 15396 return toTheTop ? 1 : -1; 15397 }, 15398 IsVerticalScrollExists: function () { 15399 var scrollIsNotHidden = ASPx.GetCurrentStyle(document.body).overflowY !== "hidden" && ASPx.GetCurrentStyle(document.documentElement).overflowY !== "hidden"; 15400 return (scrollIsNotHidden && ASPx.GetDocumentHeight() > ASPx.GetDocumentClientHeight()); 15401 }, 15402 CoordinatesInDocumentRect: function (x, y) { 15403 var docScrollLeft = ASPx.GetDocumentScrollLeft(); 15404 var docScrollTop = ASPx.GetDocumentScrollTop(); 15405 return (x > docScrollLeft && y > docScrollTop && 15406 x < ASPx.GetDocumentClientWidth() + docScrollLeft && 15407 y < ASPx.GetDocumentClientHeight() + docScrollTop); 15408 }, 15409 GetElementZIndexArray: function (element) { 15410 var currentElement = element; 15411 var zIndexesArray = [0]; 15412 while(currentElement && currentElement.tagName != "BODY") { 15413 if(currentElement.style) { 15414 if(typeof (currentElement.style.zIndex) != "undefined" && currentElement.style.zIndex != "") 15415 zIndexesArray.unshift(currentElement.style.zIndex); 15416 } 15417 currentElement = currentElement.parentNode; 15418 } 15419 return zIndexesArray; 15420 }, 15421 IsHigher: function (higherZIndexArrat, zIndexArray) { 15422 if(zIndexArray == null) return true; 15423 var count = (higherZIndexArrat.length >= zIndexArray.length) ? higherZIndexArrat.length : zIndexArray.length; 15424 for(var i = 0; i < count; i++) 15425 if(typeof (higherZIndexArrat[i]) != "undefined" && typeof (zIndexArray[i]) != "undefined") { 15426 var higherZIndexArrayCurrentElement = parseInt(higherZIndexArrat[i].toString()); 15427 var zIndexArrayCurrentElement = parseInt(zIndexArray[i].toString()); 15428 if(higherZIndexArrayCurrentElement != zIndexArrayCurrentElement) 15429 return higherZIndexArrayCurrentElement > zIndexArrayCurrentElement; 15430 } else return typeof (zIndexArray[i]) == "undefined"; 15431 return true; 15432 }, 15433 TestIsPopupElement: function (element) { 15434 return !!element.DXPopupElementControl; 15435 }, 15436 adjustViewportScrollWrapper: function(wrapper, wrapperScroll, windowElement) { 15437 var document = wrapper.ownerDocument; 15438 var window = document.defaultView || document.parentWindow; 15439 var isWindowElementDisplayed = ASPx.IsElementDisplayed(windowElement); 15440 if(!isWindowElementDisplayed) { 15441 wrapper.style.cssText = ""; 15442 wrapperScroll.style.cssText = ""; 15443 return; 15444 } 15445 var windowRect = windowElement.getBoundingClientRect(); 15446 var yAxis = this.calculateViewPortScrollDataByAxis(wrapper.style.top, windowRect.top, windowElement.offsetHeight, window.innerHeight, wrapper.scrollTop); 15447 var xAxis = this.calculateViewPortScrollDataByAxis(wrapper.style.left, windowRect.left, windowElement.offsetWidth, window.innerWidth, wrapper.scrollLeft); 15448 this.prepareViewPortScrollData(xAxis, yAxis); 15449 ASPx.SetStyles(windowElement, { 15450 top: yAxis.windowOffset,
15451 left: xAxis.windowOffset 15452 }); 15453 ASPx.SetStyles(wrapper, { 15454 width: xAxis.wrapperSize, 15455 height: yAxis.wrapperSize, 15456 position: "absolute", 15457 overflow: ASPx.Browser.MobileUI ? "scroll" : "auto", 15458 zIndex: windowElement.style.zIndex 15459 }); 15460 ASPx.SetAbsoluteX(wrapper, ASPx.GetDocumentScrollLeft()); 15461 ASPx.SetAbsoluteY(wrapper, ASPx.GetDocumentScrollTop()); 15462 ASPx.SetStyles(wrapperScroll, { 15463 width: xAxis.wrapperScrollSize, 15464 height: yAxis.wrapperScrollSize, 15465 position: "absolute", 15466 overflow: "hidden" 15467 }); 15468 wrapper.scrollLeft = xAxis.scrollSize; 15469 wrapper.scrollTop = yAxis.scrollSize; 15470 }, 15471 calculateViewPortScrollDataByAxis: function(wrapperOffsetStyle, windowOffset, windowSize, viewPortSize, scrollSize) { 15472 var isWindowOffsetNegative = windowOffset < 0; 15473 windowOffset = isWindowOffsetNegative ? 0 : windowOffset; 15474 var wrapperScrollSize = Math.max(viewPortSize + Math.abs(Math.min(0, windowOffset)), windowSize + Math.abs(windowOffset)); 15475 return { 15476 windowOffset: isWindowOffsetNegative ? 0 : windowOffset, 15477 wrapperSize: viewPortSize, 15478 wrapperScrollSize: wrapperScrollSize, 15479 scrollSize: isWindowOffsetNegative ? scrollSize + Math.abs(windowOffset) : 0, 15480 hasScroll: wrapperScrollSize > viewPortSize 15481 }; 15482 }, 15483 prepareViewPortScrollData: function(xAxis, yAxis) { 15484 var scrollBarSize = ASPx.GetVerticalScrollBarWidth(); 15485 if(yAxis.hasScroll && !xAxis.hasScroll) { 15486 xAxis.wrapperScrollSize = Math.min(xAxis.wrapperSize - scrollBarSize, xAxis.wrapperScrollSize); 15487 } else if(xAxis.hasScroll && !yAxis.hasScroll) { 15488 yAxis.wrapperScrollSize = Math.min(yAxis.wrapperSize - scrollBarSize, yAxis.wrapperScrollSize); 15489 } else if(yAxis.hasScroll && xAxis.hasScroll) { 15490 yAxis.wrapperScrollSize -= scrollBarSize; 15491 xAxis.wrapperScrollSize -= scrollBarSize; 15492 } 15493 } 15494}; 15495PopupUtils.OverControl = { 15496 GetPopupElementByEvt: function (evt) { 15497 return PopupUtils.FindEventSourceParentByTestFunc(evt, PopupUtils.TestIsPopupElement); 15498 }, 15499 OnMouseEvent: function (evt, mouseOver) { 15500 var popupElement = PopupUtils.OverControl.GetPopupElementByEvt(evt); 15501 if(mouseOver) 15502 popupElement.DXPopupElementControl.OnPopupElementMouseOver(evt, popupElement); 15503 else 15504 popupElement.DXPopupElementControl.OnPopupElementMouseOut(evt, popupElement); 15505 }, 15506 OnMouseOut: function (evt) { 15507 PopupUtils.OverControl.OnMouseEvent(evt, false); 15508 }, 15509 OnMouseOver: function (evt) { 15510 PopupUtils.OverControl.OnMouseEvent(evt, true); 15511 } 15512}; 15513PopupUtils.BodyScrollHelper = (function () { 15514 var windowScrollLock = {}, 15515 windowScroll = {}, 15516 hideScrollbarsClassName = "dxpc-hideScrollbars", 15517 savedHtmlOverflow = ""; 15518 function lockWindowScroll(windowId) { 15519 windowScrollLock[windowId] = true; 15520 } 15521 function unlockWindowScroll(windowId) { 15522 delete windowScrollLock[windowId]; 15523 } 15524 function isLocked(windowId) { 15525 return !!windowScrollLock[windowId]; 15526 } 15527 function isAnyWindowScrollLocked() { 15528 for(var key in windowScrollLock) 15529 if (windowScrollLock.hasOwnProperty(key) && windowScrollLock[key] === true) 15530 return true; 15531 return false; 15532 } 15533 function replaceVerticalScrollByPadding() { 15534 var currentBodyStyle = ASPx.GetCurrentStyle(document.body), 15535 paddingWidth = ASPx.GetVerticalScrollBarWidth() + ASPx.PxToInt(currentBodyStyle.paddingRight); 15536 ASPx.Attr.ChangeStyleAttribute(document.body, "padding-right", paddingWidth + "px"); 15537 } 15538 function needToChangeOverflowUsingStyle() { 15539 return ASPx.Browser.IE && ASPx.Browser.Version >= 11; 15540 } 15541 function changeOverflow() { 15542 if(needToChangeOverflowUsingStyle()) { 15543 savedHtmlOverflow = document.documentElement.style.overflow; 15544 document.documentElement.style.overflow = "hidden"; 15545 } 15546 else 15547 ASPx.Attr.ChangeStyleAttribute(document.documentElement, "overflow", "hidden"); 15548 if(ASPx.GetCurrentStyle(document.body).overflowY === "scroll") 15549 ASPx.Attr.ChangeStyleAttribute(document.body, "overflow", "hidden"); 15550 resetOverflowCache(); 15551 } 15552 function restoreOverflow() { 15553 if(needToChangeOverflowUsingStyle()) { 15554 document.documentElement.style.overflow = savedHtmlOverflow; 15555 savedHtmlOverflow = ""; 15556 } 15557 else 15558 ASPx.Attr.RestoreStyleAttribute(document.documentElement, "overflow"); 15559 ASPx.Attr.RestoreStyleAttribute(document.body, "overflow"); 15560 resetOverflowCache(); 15561 } 15562 function resetOverflowCache() { 15563 ASPx.verticalScrollIsNotHidden = null; 15564 ASPx.horizontalScrollIsNotHidden = null; 15565 } 15566 function saveScrollPosition(windowId) { 15567 windowScroll[windowId] = { 15568 x: window.pageXOffset, 15569 y: window.pageYOffset 15570 }; 15571 } 15572 function restoreScrollPosition(windowId) { 15573 var currentWindowScroll = windowScroll[windowId]; 15574 if(!!currentWindowScroll) 15575 window.scrollTo(currentWindowScroll.x, currentWindowScroll.y); 15576 } 15577 function restoreBodyScroll(windowId) { 15578 unlockWindowScroll(windowId); 15579 if(isAnyWindowScrollLocked()) 15580 return; 15581 if(ASPx.Browser.IE) { 15582 ASPx.Attr.RestoreAttribute(document.body, "scroll"); 15583 restoreOverflow(); 15584 restoreScrollPosition(windowId); 15585 } else if(ASPx.Browser.WebKitTouchUI) { 15586 ASPx.Attr.RestoreStyleAttribute(document.body, "position"); 15587 ASPx.Attr.RestoreStyleAttribute(document.body, "height"); 15588 ASPx.Attr.RestoreStyleAttribute(document.body, "margin"); 15589 ASPx.RemoveClassNameFromElement(document.documentElement, hideScrollbarsClassName); 15590 ASPx.Attr.RestoreStyleAttribute(document.body, "overflow"); 15591 restoreScrollPosition(windowId); 15592 } else { 15593 restoreOverflow(); 15594 restoreScrollPosition(windowId); 15595 } 15596 if(ASPx.Browser.Chrome) 15597 var dummy = document.documentElement.scrollTop; 15598 ASPx.Attr.RestoreStyleAttribute(document.body, "padding-right"); 15599 ASPx.Attr.RestoreStyleAttribute(document.body, "height"); 15600 ASPx.Attr.RestoreStyleAttribute(document.body, "width"); 15601 } 15602 return { 15603 RestoreIfLocked: function(windowId) { 15604 if(isLocked(windowId)) 15605 restoreBodyScroll(windowId); 15606 }, 15607 HideBodyScroll: function(windowId) { 15608 if(isAnyWindowScrollLocked()) { 15609 lockWindowScroll(windowId); 15610 return; 15611 } 15612 lockWindowScroll(windowId); 15613 if(PopupUtils.IsVerticalScrollExists()) 15614 replaceVerticalScrollByPadding(); 15615 if(ASPx.Browser.IE) { 15616 saveScrollPosition(windowId); 15617 ASPx.Attr.ChangeAttribute(document.body, "scroll", "no"); 15618 changeOverflow(); 15619 } else if(ASPx.Browser.WebKitTouchUI) { 15620 saveScrollPosition(windowId); 15621 ASPx.Attr.ChangeStyleAttribute(document.body, "overflow", "hidden"); 15622 ASPx.Attr.ChangeStyleAttribute(document.body, "position", "relative"); 15623 ASPx.Attr.ChangeStyleAttribute(document.body, "height", "100%"); 15624 ASPx.Attr.ChangeStyleAttribute(document.body, "margin", "0"); 15625 ASPx.AddClassNameToElement(document.documentElement, hideScrollbarsClassName); 15626 } else { 15627 saveScrollPosition(windowId); 15628 changeOverflow(); 15629 var documentHeight = ASPx.GetDocumentHeight(); 15630 var documentWidth = ASPx.GetDocumentWidth(); 15631 if(window.pageYOffset > 0 && ASPx.PxToInt(window.getComputedStyle(document.body, null)) != documentHeight) 15632 ASPx.Attr.ChangeStyleAttribute(document.body, "height", documentHeight + "px"); 15633 if(window.pageXOffset > 0 && ASPx.PxToInt(window.getComputedStyle(document.body, null)) != documentWidth) 15634 ASPx.Attr.ChangeStyleAttribute(document.body, "width", documentWidth + "px"); 15635 } 15636 }, 15637 RestoreBodyScroll: restoreBodyScroll 15638 }; 15639})(); 15640var PositionAlignConsts = { 15641 NOT_SET: 0, 15642 OUTSIDE_START: 1, 15643 NEAR_BOUND_START: 2, 15644 INNER_START: 3,
15645 CENTER: 4, 15646 INNER_END: 5, 15647 NEAR_BOUND_END: 6, 15648 OUTSIDE_END: 7, 15649 WINDOW_CENTER: 8, 15650 WINDOW_START: 9, 15651 WINDOW_END: 10 15652}; 15653var AlignIndicatorTable = {}; 15654var PositionCalculator = ASPx.CreateClass(null, { 15655 constructor: function() { 15656 this.element = null; 15657 this.popupElement = null; 15658 this.align = 0; 15659 this.offset = 0; 15660 this.startPos = 0; 15661 this.startPosInit = 0; 15662 this.rtl = false; 15663 this.isPopupFullCorrectionOn = false; 15664 this.isHorizontal = true; 15665 this.size = 0; 15666 this.bodySize = 0; 15667 this.actualBodySize = 0; 15668 this.elementStartPos = 0; 15669 this.scrollStartPos = 0; 15670 this.isInverted = false; 15671 this.popupElementSize = 0; 15672 this.boundStartPos = 0; 15673 this.boundEndPos = 0; 15674 this.innerBoundStartPos = 0; 15675 this.innerBoundEndPos = 0; 15676 this.isMoreFreeSpaceLeft = false; 15677 this.nearBoundOverlapRate = 0.25; 15678 this.functionsTable = {}; 15679 this.initializeFunctionsTable(); 15680 }, 15681 applyParams: function(element, popupElement, align, offset, startPos, startPosInit, rtl, isPopupFullCorrectionOn, ignoreAlignWithoutScrollReserve, ignorePopupElementBorders, isHorizontal) { 15682 this.isHorizontal = isHorizontal; 15683 this.element = element; 15684 this.popupElement = popupElement; 15685 this.align = this.getAlignValueFromIndicator(align); 15686 this.offset = offset; 15687 this.startPos = startPos; 15688 this.startPosInit = startPosInit; 15689 this.rtl = rtl; 15690 this.isPopupFullCorrectionOn = isPopupFullCorrectionOn; 15691 this.ignoreAlignWithoutScrollReserve = ignoreAlignWithoutScrollReserve; 15692 this.ignorePopupElementBorders = ignorePopupElementBorders; 15693 this.calculateParams(); 15694 }, 15695 disposeState: function() { 15696 this.element = null; 15697 this.popupElement = null; 15698 }, 15699 getPopupAbsolutePos: function() { 15700 if(this.isWindowAlign()) { 15701 var showAtPos = this.startPos != ASPx.InvalidPosition && !this.popupElement; 15702 if(showAtPos) 15703 this.align = PositionAlignConsts.NOT_SET; 15704 else 15705 return this.getWindowAlignPos(); 15706 } 15707 if(this.popupElement) 15708 this.calculatePopupElement(); 15709 else 15710 this.align = PositionAlignConsts.NOT_SET; 15711 return this.getPopupAbsolutePosCore(); 15712 }, 15713 initializeFunctionsTable: function() { 15714 var table = this.functionsTable; 15715 table[PositionAlignConsts.NOT_SET] = this.calculateNotSet; 15716 table[PositionAlignConsts.OUTSIDE_START] = this.calculateOutsideStart; 15717 table[PositionAlignConsts.INNER_START] = this.calculateInnerStart; 15718 table[PositionAlignConsts.CENTER] = this.calculateCenter; 15719 table[PositionAlignConsts.INNER_END] = this.calculateInnerEnd; 15720 table[PositionAlignConsts.OUTSIDE_END] = this.calculateOutsideEnd; 15721 table[PositionAlignConsts.NEAR_BOUND_START] = this.calculateNearBoundStart; 15722 table[PositionAlignConsts.NEAR_BOUND_END] = this.calculateNearBoundEnd; 15723 table[PositionAlignConsts.WINDOW_CENTER] = this.calculateWindowCenter; 15724 table[PositionAlignConsts.WINDOW_START] = this.calculateWindowStart; 15725 table[PositionAlignConsts.WINDOW_END] = this.calculateWindowEnd; 15726 }, 15727 calculateParams: function() { 15728 this.size = this.getElementSize(); 15729 if(this.isHorizontal) { 15730 this.bodySize = ASPx.GetDocumentClientWidth(); 15731 this.elementStartPos = ASPx.GetAbsoluteX(this.popupElement) + this.getBorderCorrection(); 15732 this.scrollStartPos = ASPx.GetDocumentScrollLeft(); 15733 } 15734 else { 15735 this.bodySize = ASPx.GetDocumentClientHeight(); 15736 this.elementStartPos = ASPx.GetAbsoluteY(this.popupElement) + this.getBorderCorrection(); 15737 this.scrollStartPos = ASPx.GetDocumentScrollTop(); 15738 } 15739 }, 15740 getBorderCorrection: function() { 15741 if(!this.ignorePopupElementBorders) 15742 return 0; 15743 var style = getComputedStyle(this.popupElement); 15744 return ASPx.PxToInt(this.isHorizontal ? style.borderLeftWidth : style.borderTopWidth); 15745 }, 15746 isWindowAlign: function() { 15747 return this.align == PositionAlignConsts.WINDOW_CENTER || this.align == PositionAlignConsts.WINDOW_START || 15748 this.align == PositionAlignConsts.WINDOW_END; 15749 }, 15750 getWindowAlignPos: function() { 15751 this.actualBodySize = ASPx.Browser.WebKitTouchUI ? this.getWindowInnerSize() : this.bodySize; 15752 return this.getPopupAbsolutePosCore(); 15753 }, 15754 getPopupAbsolutePosCore: function() { 15755 var calculationFunc = this.functionsTable[this.align]; 15756 calculationFunc.call(this); 15757 return new ASPx.PopupPosition(this.startPos, this.isInverted); 15758 }, 15759 calculateWindowCenter: function() { 15760 this.startPos = Math.max(Math.ceil(this.actualBodySize / 2 - this.size / 2), 0) + this.scrollStartPos + this.offset; 15761 }, 15762 calculateWindowStart: function() { 15763 this.startPos = this.scrollStartPos + this.offset; 15764 }, 15765 calculateWindowEnd: function() { 15766 this.startPos = this.scrollStartPos + this.actualBodySize - this.size + this.offset; 15767 }, 15768 calculatePopupElement: function() { 15769 this.popupElementSize = this.getPopupElementSize(); 15770 this.boundStartPos = this.elementStartPos - this.size; 15771 this.boundEndPos = this.elementStartPos + this.popupElementSize; 15772 this.innerBoundStartPos = this.elementStartPos; 15773 this.innerBoundEndPos = this.elementStartPos + this.popupElementSize - this.size; 15774 var hasLeftScrollReserve = this.boundStartPos >= 0;
15775 this.isMoreFreeSpaceLeft = (this.bodySize - (this.boundEndPos + this.size) < this.boundStartPos - 2 * this.scrollStartPos) && (!this.ignoreAlignWithoutScrollReserve || hasLeftScrollReserve); 15776 }, 15777 calculateOutsideStart: function() { 15778 this.isInverted = this.isPopupFullCorrectionOn && (!(this.boundStartPos - this.scrollStartPos > 0 || this.isMoreFreeSpaceLeft)); 15779 if(this.isInverted) 15780 this.startPos = this.boundEndPos - this.offset; 15781 else 15782 this.startPos = this.boundStartPos + this.offset; 15783 }, 15784 calculateInnerStart: function() { 15785 this.startPos = this.innerBoundStartPos + this.offset; 15786 if(this.isPopupFullCorrectionOn) 15787 this.startPos = PopupUtils.AdjustPositionToClientScreen(this.element, this.startPos, this.rtl, this.isHorizontal); 15788 }, 15789 calculateCenter: function() { 15790 this.startPos = this.elementStartPos + Math.round((this.popupElementSize - this.size) / 2) + this.offset; 15791 }, 15792 calculateInnerEnd: function() { 15793 this.startPos = this.innerBoundEndPos + this.offset; 15794 if(this.isPopupFullCorrectionOn) 15795 this.startPos = PopupUtils.AdjustPositionToClientScreen(this.element, this.startPos, this.rtl, this.isHorizontal); 15796 }, 15797 calculateOutsideEnd: function() { 15798 this.isInverted = this.isPopupFullCorrectionOn && (!(this.boundEndPos + this.size < this.bodySize + this.scrollStartPos || !this.isMoreFreeSpaceLeft)); 15799 if(this.isInverted) 15800 this.startPos = this.boundStartPos - this.offset; 15801 else 15802 this.startPos = this.boundEndPos + this.offset; 15803 }, 15804 calculateNotSet: function() { 15805 if(this.rtl) 15806 this.calculateNotSetRightToLeft(); 15807 else 15808 this.calculateNotSetLeftToRight(); 15809 }, 15810 calculateNotSetLeftToRight: function() { 15811 if(!ASPx.IsValidPosition(this.startPos)) { 15812 if(this.popupElement) 15813 this.startPos = this.elementStartPos; 15814 else if(this.offset) 15815 this.startPos = 0; 15816 else 15817 this.startPos = this.startPosInit; 15818 } 15819 this.isInverted = this.isPopupFullCorrectionOn && (this.startPos - this.scrollStartPos + this.size > this.bodySize && this.startPos - this.scrollStartPos > this.bodySize / 2); 15820 if(this.isInverted) 15821 this.startPos = this.startPos - this.size - this.offset; 15822 else 15823 this.startPos = this.startPos + this.offset; 15824 }, 15825 calculateNotSetRightToLeft: function() { 15826 if(!ASPx.IsValidPosition(this.startPos)) { 15827 if(this.popupElement) 15828 this.startPos = this.innerBoundEndPos; 15829 else if(this.offset) 15830 this.startPos = 0; 15831 else 15832 this.startPos = this.startPosInit; 15833 } 15834 else 15835 this.startPos -= this.size; 15836 this.isInverted = this.isPopupFullCorrectionOn && (this.startPos < this.scrollStartPos && this.startPos - this.scrollStartPos < this.bodySize / 2); 15837 if(this.isInverted) 15838 this.startPos = this.startPos + this.size + this.offset; 15839 else 15840 this.startPos = this.startPos - this.offset; 15841 }, 15842 calculateNearBoundStart: function() { 15843 this.startPos = this.boundStartPos + this.offset + this.size * this.nearBoundOverlapRate; 15844 if(this.isPopupFullCorrectionOn) 15845 this.startPos = PopupUtils.AdjustPositionToClientScreen(this.element, this.startPos, this.rtl, this.isHorizontal); 15846 }, 15847 calculateNearBoundEnd: function() { 15848 this.startPos = this.boundEndPos + this.offset - this.size * this.nearBoundOverlapRate; 15849 if(this.isPopupFullCorrectionOn) 15850 this.startPos = PopupUtils.AdjustPositionToClientScreen(this.element, this.startPos, this.rtl, this.isHorizontal); 15851 }, 15852 getAlignValueFromIndicator: function(alignIndicator) { 15853 var alignValue = AlignIndicatorTable[alignIndicator]; 15854 if(alignValue === undefined) 15855 throw "Incorrect align indicator."; 15856 return alignValue; 15857 }, 15858 getElementSize: function() { 15859 return this.getCustomElementSize(this.element, false); 15860 }, 15861 getPopupElementSize: function() { 15862 return this.getCustomElementSize(this.popupElement, this.ignorePopupElementBorders); 15863 }, 15864 getCustomElementSize: function(customElement, ignoreBorders) { 15865 if(ignoreBorders) { 15866 return this.isHorizontal ? ASPx.GetClearClientWidth(customElement) : ASPx.GetClearClientHeight(customElement); 15867 } 15868 return this.isHorizontal ? ASPx.GetElementOffsetWidth(customElement) : ASPx.GetElementOffsetHeight(customElement); 15869 }, 15870 getWindowInnerSize: function() { 15871 return this.isHorizontal ? window.innerWidth : window.innerHeight; 15872 } 15873}); 15874var positionCalculator = null; 15875function getPositionCalculator() { 15876 if(positionCalculator == null) 15877 positionCalculator = new PositionCalculator(); 15878 return positionCalculator; 15879} 15880function initializeAlignIndicatorTable() { 15881 AlignIndicatorTable[PopupUtils.NotSetAlignIndicator] = PositionAlignConsts.NOT_SET; 15882 AlignIndicatorTable[PopupUtils.OutsideLeftAlignIndicator] = PositionAlignConsts.OUT
15882SIDE_START; 15883 AlignIndicatorTable[PopupUtils.AboveAlignIndicator] = PositionAlignConsts.OUTSIDE_START; 15884 AlignIndicatorTable[PopupUtils.LeftAlignIndicator] = PositionAlignConsts.NEAR_BOUND_START; 15885 AlignIndicatorTable[PopupUtils.TopAlignIndicator] = PositionAlignConsts.NEAR_BOUND_START; 15886 AlignIndicatorTable[PopupUtils.LeftSidesAlignIndicator] = PositionAlignConsts.INNER_START; 15887 AlignIndicatorTable[PopupUtils.TopSidesAlignIndicator] = PositionAlignConsts.INNER_START; 15888 AlignIndicatorTable[PopupUtils.CenterAlignIndicator] = PositionAlignConsts.CENTER; 15889 AlignIndicatorTable[PopupUtils.MiddleAlignIndicator] = PositionAlignConsts.CENTER; 15890 AlignIndicatorTable[PopupUtils.RightSidesAlignIndicator] = PositionAlignConsts.INNER_END; 15891 AlignIndicatorTable[PopupUtils.BottomSidesAlignIndicator] = PositionAlignConsts.INNER_END; 15892 AlignIndicatorTable[PopupUtils.RightAlignIndicator] = PositionAlignConsts.NEAR_BOUND_END; 15893 AlignIndicatorTable[PopupUtils.BottomAlignIndicator] = PositionAlignConsts.NEAR_BOUND_END; 15894 AlignIndicatorTable[PopupUtils.OutsideRightAlignIndicator] = PositionAlignConsts.OUTSIDE_END; 15895 AlignIndicatorTable[PopupUtils.BelowAlignIndicator] = PositionAlignConsts.OUTSIDE_END; 15896 AlignIndicatorTable[PopupUtils.WindowCenterAlignIndicator] = PositionAlignConsts.WINDOW_CENTER; 15897 AlignIndicatorTable[PopupUtils.WindowLeftAlignIndicator] = PositionAlignConsts.WINDOW_START; 15898 AlignIndicatorTable[PopupUtils.WindowTopAlignIndicator] = PositionAlignConsts.WINDOW_START; 15899 AlignIndicatorTable[PopupUtils.WindowRightAlignIndicator] = PositionAlignConsts.WINDOW_END; 15900 AlignIndicatorTable[PopupUtils.WindowBottomAlignIndicator] = PositionAlignConsts.WINDOW_END; 15901} 15902initializeAlignIndicatorTable(); 15903ASPx.PopupPosition = function(position, isInverted) { 15904 this.position = position; 15905 this.isInverted = isInverted; 15906}; 15907ASPx.PopupSize = function(width, height) { 15908 this.width = width; 15909 this.height = height; 15910}; 15911ASPx.PopupUtils = PopupUtils; 15912ASPx.PositionCalculator = PositionCalculator; 15913})(); 15914(function(){ 15915 var ScrollingManager = ASPx.CreateClass(null, { 15916 constructor: function(owner, options) { 15917 this.owner = owner; 15918 this.scrollableArea = options.scrollableArea; 15919 this.orientation = options.orientation; 15920 this.animationDelay = 1; 15921 this.animationStep = 2; 15922 this.animationOffset = 5; 15923 this.animationAcceleration = 0; 15924 this.scrollSessionInterval = 10; 15925 this.stopScrolling = true; 15926 this.busy = false; 15927 this.currentAcceleration = 0; 15928 this.startPos = 0; 15929 this.onBeforeScrolling = options.onBeforeScrolling; 15930 this.onAfterScrolling = options.onAfterScrolling; 15931 this.emulationMode = options.forseEmulation === true || !ASPx.Browser.TouchUI; 15932 this.useMarginForPosition = options.useMarginForPosition; 15933 this.handleMouseWheel = !!options.handleMouseWheel; 15934 this.Initialize(); 15935 }, 15936 Initialize: function(){ 15937 this.setParentNodeOverflow(); 15938 if(this.emulationMode) { 15939 this.wrapper = new ScrollingManager.scrollWrapper(this.scrollableArea, this.useMarginForPosition); 15940 } else { 15941 this.wrapper = new ScrollingManager.scrollWrapperTouchUI(this.scrollableArea, function(direction){ 15942 if(this.onAfterScrolling) 15943 this.onAfterScrolling(this, direction); 15944 }.aspxBind(this)); 15945 } 15946 if(this.handleMouseWheel) 15947 ASPx.Evt.AttachEventToElement(this.scrollableArea, ASPx.Evt.GetMouseWheelEventName(), this.onMouseWheel.aspxBind(this)); 15948 }, 15949 onMouseWheel: function(e) { 15950 ASPx.Evt.PreventEvent(e); 15951 var delta = ASPx.Evt.GetWheelDelta(e); 15952 if(ASPx.Browser.Firefox) 15953 delta = delta / 0.03; 15954 this.DoScrollSessionToOffset(-delta); 15955 }, 15956 setParentNodeOverflow: function() { 15957 if(ASPx.Browser.MSTouchUI){ 15958 this.scrollableArea.parentNode.style.overflow = "auto"; 15959 this.scrollableArea.parentNode.style["-ms-overflow-style"] = "-ms-autohiding-scrollbar"; 15960 } 15961 }, 15962 GetScrolledAreaPosition: function() { 15963 return this.wrapper.GetScrollLeft() * this.orientation[0] 15964 + this.wrapper.GetScrollTop() * this.orientation[1]; 15965 }, 15966 SetScrolledAreaPosition: function(pos) { 15967 this.wrapper.SetScrollLeft(pos * this.orientation[0]); 15968 this.wrapper.SetScrollTop(pos * this.orientation[1]); 15969 }, 15970 PrepareForScrollAnimation: function() { 15971 if(!this.scrollableArea) 15972 return; 15973 this.currentAcceleration = 0; 15974 this.startPos = this.GetScrolledAreaPosition(); 15975 this.busy = false; 15976 }, 15977 GetAnimationStep: function(dir) { 15978 var step = dir * (this.animationStep + this.currentAcceleration); 15979 var newPos = this.GetScrolledAreaPosition() + step; 15980 var requiredPos = this.startPos + dir * this.animationOffset; 15981 if((dir == 1 && newPos >= requiredPos) || (dir == -1 && newPos <= requiredPos)) { 15982 step = requiredPos - this.GetScrolledAreaPosition(); 15983 } 15984 return step; 15985 }, 15986 DoScrollSessionToOffset: function(offset) { 15987 var newScrollPos = this.GetScrolledAreaPosition() - offset; 15988 this.stopScrolling = false; 15989 if(this.onBeforeScrolling) 15990 this.onBeforeScrolling(this, offset); 15991 if(this.stopScrolling) return; 15992 newScrollPos = Math.min(newScrollPos, 0); 15993 this.SetScrolledAreaPosition(newScrollPos); 15994 if(this.onAfterScrolling) 15995 this.onAfterScrolling(this, offset); 15996 }, 15997 DoScrollSessionAnimation: function(direction) { 15998 if(!this.scrollableArea) 15999 return; 16000 this.SetScrolledAreaPosition(this.GetScrolledAreaPosition() + this.GetAnimationStep(direction)); 16001 var self = this; 16002 if(!this.ShouldStopScrollSessionAnimation()) { 16003 this.busy = true; 16004 this.currentAcceleration += this.animationAcceleration; 16005 window.setTimeout(function() { self.DoScrollSessionAnimation(direction); }, this.animationDelay); 16006 } else { 16007 this.busy = false; 16008 if(this.onAfterScrolling) 16009 this.onAfterScrolling(this, -direction); 16010 this.currentAcceleration = 0; 16011 window.setTimeout(function() { self.DoScroll(direction); }, this.scrollSessionInterval); 16012 } 16013 }, 16014 ShouldStopScrollSessionAnimation: function() { 16015 return (Math.abs(this.GetScrolledAreaPosition() - this.startPos) >= Math.abs(this.animationOffset)); 16016 }, 16017 DoScroll: function(direction) { 16018 if(!this.scrollableArea) 16019 return; 16020 if(!this.busy && !this.stopScrolling) { 16021 if(this.onBeforeScrolling) 16022 this.onBeforeScrolling(this, -direction); 16023 if(this.stopScrolling) return; 16024 this.PrepareForScrollAnimation(); 16025 this.DoScrollSessionAnimation(direction); 16026 } 16027 }, 16028 StartScrolling: function(direction, delay, step) { 16029 this.stopScrolling = false; 16030 this.animationDelay = delay; 16031 this.animationStep = step; 16032 this.DoScroll(-direction); 16033 }, 16034 StopScrolling: function() { 16035 this.stopScrolling = true; 16036 }, 16037 IsStopped: function() { 16038 return this.stopScrolling; 16039 }, 16040 IsInProgress: function() { 16041 return this.busy; 16042 } 16043 }); 16044 var MouseScrollingManager = ASPx.CreateClass(ScrollingManager, { 16045 constructor: function(owner, options) { 16046 this.mouseEventsElement = options.mouseEventsElement; 16047 this.preventOuterScroll = options.preventOuterScroll; 16048 this.enableMouseScrollInternal = true; 16049 this.constructor.prototype.constructor.call(this, owner, options); 16050 }, 16051 Initialize: function() { 16052 ASPx.ScrollingManager.prototype.Initialize.call(this); 16053 this.initializeMouseScroll(); 16054 }, 16055 initializeMouseScroll: function() { 16056 this.mouseDown = false; 16057 this.vx = 0; 16058 this.prevX = 0; 16059 this.scrollTime = null; 16060 this.mouseScrollAcceleration = 0.7; 16061 this.mouseScrollTimeStep = 30; 16062 ASPx.Evt.AttachEventToElement(this.mouseEventsElement, ASPx.TouchUIHelper.touchMouseDownEventName, this.startMouseScroll.aspxBind(this)); 16063 }, 16064 scrollToOffset: function(mouseOffset) { 16065 var newOffset = this.GetScrolledAreaPosition() - mouseOffset; 16066 if(this.getValidNewScrollOffset) 16067 newOffset = this.getValidNewScrollOffset(newOffset); 16068 this.SetScrolledAreaPosition(newOffset); 16069 }, 16070 preventTextSelectionAndOuterDivScrollOnScroll: function(e) { 16071 if(this.preventOuterScroll) 16072 ASPx.Evt.PreventEvent(e); 16073 ASPx.Selection.Clear(); 16074 },
16075 mouseScroll: function(e) { 16076 if(!this.mouseDown) return; 16077 this.preventTextSelectionAndOuterDivScrollOnScroll(e); 16078 var x = ASPx.Evt.GetEventX(e), 16079 dx = this.prevX - x, 16080 dt = new Date() - this.scrollTime; 16081 if(dt < 1) dt = 1; 16082 this.vx = dx / dt; 16083 this.scrollToOffset(dx); 16084 this.prevX = x; 16085 this.scrollTime = new Date(); 16086 }, 16087 startMouseScroll: function(e) { 16088 if(!this.enableMouseScrollInternal) return; 16089 this.detachMouseEvents(); 16090 this.mouseMoveHandler = this.mouseScroll.aspxBind(this); 16091 this.mouseUpHandler = this.stopMouseScroll.aspxBind(this); 16092 ASPx.Evt.AttachEventToElement(document, ASPx.TouchUIHelper.touchMouseMoveEventName, this.mouseMoveHandler); 16093 ASPx.Evt.AttachEventToDocument(ASPx.TouchUIHelper.touchMouseUpEventName, this.mouseUpHandler); 16094 this.mouseDown = true; 16095 window.clearTimeout(this.inertialStopTimerId); 16096 this.prevX = ASPx.Evt.GetEventX(e); 16097 this.scrollTime = new Date(); 16098 }, 16099 detachMouseEvents: function() { 16100 ASPx.Evt.DetachEventFromElement(document, ASPx.TouchUIHelper.touchMouseMoveEventName, this.mouseMoveHandler); 16101 ASPx.Evt.DetachEventFromDocument(ASPx.TouchUIHelper.touchMouseUpEventName, this.mouseUpHandler); 16102 }, 16103 stopMouseScroll: function() { 16104 this.detachMouseEvents(); 16105 this.mouseDown = false; 16106 this.inertialStopTimerId = window.setTimeout(function() { 16107 this.vx *= this.mouseScrollAcceleration; 16108 if(Math.abs(this.vx) < 0.1) { 16109 this.vx = 0; 16110 if(this.onAfterScrolling) 16111 this.onAfterScrolling(this); 16112 return; 16113 } 16114 var dx = Math.ceil(this.vx * this.mouseScrollTimeStep); 16115 this.scrollToOffset(dx); 16116 this.stopMouseScroll(); 16117 }.aspxBind(this), this.mouseScrollTimeStep); 16118 } 16119 }); 16120 ScrollingManager.scrollWrapper = function(scrollableArea, useMarginForPosition) { 16121 this.scrollableArea = scrollableArea; 16122 this.useMarginForPosition = useMarginForPosition; 16123 this.Initialize(); 16124 }; 16125 ScrollingManager.scrollWrapper.prototype = { 16126 Initialize: function() { 16127 if(this.useMarginForPosition) { 16128 this.leftScrollProperty = "margin-left"; 16129 this.topScrollProperty = "margin-top"; 16130 } else { 16131 this.scrollableArea.style.position = "relative"; 16132 this.scrollableArea.parentNode.style.position = "relative"; 16133 this.leftScrollProperty = "left"; 16134 this.topScrollProperty = "top"; 16135 } 16136 }, 16137 GetScrollLeft: function() { return ASPx.PxToFloat(this.scrollableArea.style[this.leftScrollProperty]); }, 16138 GetScrollTop: function() { return ASPx.PxToFloat(this.scrollableArea.style[this.topScrollProperty]); }, 16139 SetScrollLeft: function(value) { 16140 this.scrollableArea.style[this.leftScrollProperty] = value + "px"; 16141 }, 16142 SetScrollTop: function(value) { 16143 this.scrollableArea.style[this.topScrollProperty] = value + "px"; 16144 } 16145 }; 16146 ScrollingManager.scrollWrapperTouchUI = function(scrollableArea, onScroll){ 16147 this.scrollableArea = scrollableArea; 16148 this.scrollTimerId = -1; 16149 this.onScroll = onScroll; 16150 this.Initialize(onScroll); 16151 }; 16152 ScrollingManager.scrollWrapperTouchUI.prototype = { 16153 Initialize: function(){ 16154 var div = this.scrollableArea.parentNode; 16155 var timeout = ASPx.Browser.MSTouchUI ? 500 : 1000; 16156 var nativeScrollSupported = ASPx.TouchUIHelper.nativeScrollingSupported(); 16157 this.onScrollCore = function(){ 16158 ASPx.Timer.ClearTimer(this.scrollTimerId); 16159 if(this.onScrollLocked) return; 16160 this.scrollTimerId = window.setTimeout(this.onScrollByTimer, timeout); 16161 }.aspxBind(this); 16162 this.onScrollByTimer = function(){ 16163 if(this.onScrollLocked) return; 16164 var direction = this.lastScrollTop < div.scrollTop ? 1 : -1; 16165 this.lastScrollTop = div.scrollTop; 16166 this.onScrollLocked = true; 16167 this.onScroll(direction); 16168 this.onScrollLocked = false; 16169 }.aspxBind(this); 16170 this.lastScrollTop = div.scrollTop; 16171 var onscroll = nativeScrollSupported ? this.onScrollCore : this.onScrollByTimer; 16172 ASPx.Evt.AttachEventToElement(div, "scroll", onscroll); 16173 if(ASPx.Browser.WebKitTouchUI) 16174 this.scrollExtender = ASPx.TouchUIHelper.MakeScrollable(div, {showHorizontalScrollbar: false}); 16175 }, 16176 GetScrollLeft: function(){ return -this.scrollableArea.parentNode.scrollLeft; }, 16177 GetScrollTop: function(){ return -this.scrollableArea.parentNode.scrollTop; }, 16178 SetScrollLeft: function(value){ 16179 this.onScrollLocked = true; 16180 this.scrollableArea.parentNode.scrollLeft = -value; 16181 this.onScrollLocked = false; 16182 }, 16183 SetScrollTop: function(value){ 16184 this.onScrollLocked = true; 16185 this.scrollableArea.parentNode.scrollTop = -value; 16186 this.onScrollLocked = false; 16187 } 16188 }; 16189 ASPx.ScrollingManager = ScrollingManager; 16190 ASPx.MouseScrollingManager = MouseScrollingManager; 16191})(); 16192(function() { 16193var Constants = { 16194 MIIdSuffix: "_DXI", 16195 MMIdSuffix: "_DXM", 16196 SBIdSuffix: "_DXSB", 16197 SBUIdEnd: "_U", 16198 SBDIdEnd: "_D", 16199 ATSIdSuffix: "_ATS", 16200 SampleCssClassNameForImageElement: "SAMPLE_CSS_CLASS", 16201 ImagePostfix: "Img", 16202 PopupImagePostfix: "PImg" 16203};
16204var SLIDE_DURATION_VALUE = 300; 16205var SIDE_MENU_ZINDEX_VALUE = 10000; 16206var MENU_PREFIX_CLASS_NAME = 'dxm'; 16207var SLIDE_PANEL_EXPANDED_CLASS_NAME = MENU_PREFIX_CLASS_NAME + '-expanded'; 16208var BREAD_CRUMBS_CLASS_NAME = MENU_PREFIX_CLASS_NAME + '-bread-crumbs'; 16209var OVERLAY_PANEL_CLASS_NAME = MENU_PREFIX_CLASS_NAME + '-overlay'; 16210var BURGER_CLASS_NAME = MENU_PREFIX_CLASS_NAME + '-side-menu-button'; 16211var BACK_ICON_CLASS_NAME = MENU_PREFIX_CLASS_NAME + '-back-icon'; 16212var NO_MAIN_POP_OUT_CLASS_NAME = MENU_PREFIX_CLASS_NAME + '-no-main-popout'; 16213var TEMPORARY_VISIBILITY_CLASS_NAME = MENU_PREFIX_CLASS_NAME + '-temp-visibility'; 16214var SIDE_MENU_CLASS_NAME = MENU_PREFIX_CLASS_NAME + '-side-menu-mode'; 16215var PRE_HOVERED_ELEMENT_CLASS_NAME = MENU_PREFIX_CLASS_NAME + '-pre-hovered'; 16216var PRE_SELECTED_ELEMENT_CLASS_NAME = MENU_PREFIX_CLASS_NAME + '-pre-selected'; 16217var MenuItemInfo = ASPx.CreateClass(null, { 16218 constructor: function(menu, indexPath) { 16219 var itemElement = menu.GetItemElement(indexPath); 16220 this.clientHeight = itemElement.clientHeight; 16221 this.clientWidth = itemElement.clientWidth; 16222 this.clientTop = ASPx.GetClientTop(itemElement); 16223 this.clientLeft = ASPx.GetClientLeft(itemElement); 16224 this.offsetHeight = itemElement.offsetHeight; 16225 this.offsetWidth = itemElement.offsetWidth; 16226 this.offsetTop = 0; 16227 this.offsetLeft = 0; 16228 } 16229}); 16230var MenuCssClasses = {}; 16231MenuCssClasses.Prefix = "dxm-"; 16232MenuCssClasses.Menu = "dxmLite"; 16233MenuCssClasses.BorderCorrector = "dxmBrdCor"; 16234MenuCssClasses.Disabled = MenuCssClasses.Prefix + "disabled"; 16235MenuCssClasses.MainMenu = MenuCssClasses.Prefix + "main"; 16236MenuCssClasses.PopupMenu = MenuCssClasses.Prefix + "popup"; 16237MenuCssClasses.ItemTemplate = MenuCssClasses.Prefix + "tmpl"; 16238MenuCssClasses.HorizontalMenu = MenuCssClasses.Prefix + "horizontal"; 16239MenuCssClasses.VerticalMenu = MenuCssClasses.Prefix + "vertical"; 16240MenuCssClasses.NoWrapMenu = MenuCssClasses.Prefix + "noWrap"; 16241MenuCssClasses.AutoWidthMenu = MenuCssClasses.Prefix + "autoWidth"; 16242MenuCssClasses.CalculateMenu = MenuCssClasses.Prefix + "calc"; 16243MenuCssClasses.DX = "dx"; 16244MenuCssClasses.Separator = MenuCssClasses.Prefix + "separator"; 16245MenuCssClasses.Spacing = MenuCssClasses.Prefix + "spacing"; 16246MenuCssClasses.AlignSpacing = MenuCssClasses.Prefix + "alignSpacing"; 16247MenuCssClasses.Gutter = MenuCssClasses.Prefix + "gutter"; 16248MenuCssClasses.WithoutImages = MenuCssClasses.Prefix + "noImages"; 16249MenuCssClasses.Item = MenuCssClasses.Prefix + "item"; 16250MenuCssClasses.ItemHovered = MenuCssClasses.Prefix + "hovered"; 16251MenuCssClasses.ItemSelected = MenuCssClasses.Prefix + "selected"; 16252MenuCssClasses.ItemChecked = MenuCssClasses.Prefix + "checked"; 16253MenuCssClasses.ItemWithoutImage = MenuCssClasses.Prefix + "noImage"; 16254MenuCssClasses.ItemWithSubMenu = MenuCssClasses.Prefix + "subMenu"; 16255MenuCssClasses.ItemDropDownMode = MenuCssClasses.Prefix + "dropDownMode"; 16256MenuCssClasses.ItemWithoutSubMenu = MenuCssClasses.Prefix + "noSubMenu"; 16257MenuCssClasses.AdaptiveMenuItem = MenuCssClasses.Prefix + "ami"; 16258MenuCssClasses.AdaptiveMenuItemSpacing = MenuCssClasses.Prefix + "amis"; 16259MenuCssClasses.AdaptiveMenu = MenuCssClasses.Prefix + "am"; 16260MenuCssClasses.AdaptiveMenuHiddenElement = MenuCssClasses.Prefix + "amhe"; 16261MenuCssClasses.ContentContainer = MenuCssClasses.Prefix + "content"; 16262MenuCssClasses.ContentContainerWithVerticalAlignment = MenuCssClasses.Prefix + "valign"; 16263MenuCssClasses.Image = MenuCssClasses.Prefix + "image"; 16264MenuCssClasses.PopOutContainer = MenuCssClasses.Prefix + "popOut"; 16265MenuCssClasses.PopOutImage = MenuCssClasses.Prefix + "pImage"; 16266MenuCssClasses.ImageLeft = MenuCssClasses.Prefix + "image-l"; 16267MenuCssClasses.ImageRight = MenuCssClasses.Prefix + "image-r"; 16268MenuCssClasses.ImageTop = MenuCssClasses.Prefix + "image-t"; 16269MenuCssClasses.ImageBottom = MenuCssClasses.Prefix + "image-b"; 16270MenuCssClasses.ScrollArea = MenuCssClasses.Prefix + "scrollArea"; 16271MenuCssClasses.ScrollUpButton = MenuCssClasses.Prefix + "scrollUpBtn"; 16272MenuCssClasses.ScrollDownButton = MenuCssClasses.Prefix + "scrollDownBtn";
16273MenuCssClasses.ItemClearElement = MenuCssClasses.DX + "-clear"; 16274MenuCssClasses.ItemTextElement = MenuCssClasses.Prefix + "contentText"; 16275MenuCssClasses.SmallImage = MenuCssClasses.DX + "-small-image"; 16276var MenuRenderHelper = ASPx.CreateClass(null, { 16277 constructor: function(menu) { 16278 this.menu = menu; 16279 this.itemLinkMode = "ContentBounds"; 16280 this.elementsToHide = []; 16281 }, 16282 InlineInitializeElements: function() { 16283 if(!this.menu.isPopupMenu) 16284 this.InlineInitializeMainMenuElements(this.menu.GetMainElement()); 16285 else 16286 this.InlineInitializePopupMenuElements(this.menu.GetMainElement()); 16287 var popupMenuElements = this.GetPopupMenuElements(this.menu.GetMainElement()); 16288 for(var i = 0; i < popupMenuElements.length; i++) { 16289 if(popupMenuElements[i] == this.menu.GetMainElement()) continue; 16290 this.InlineInitializePopupMenuElements(popupMenuElements[i]); 16291 } 16292 }, 16293 InlineInitializeSubMenuElements: function(parentItemIndexPath) { 16294 var popupMenuElements = this.GetPopupMenuElements(this.menu.GetMainElement()); 16295 for(var i = 0; i < popupMenuElements.length; i++) { 16296 if(popupMenuElements[i].id.indexOf(Constants.MMIdSuffix + parentItemIndexPath + "_") > 0) 16297 this.InlineInitializePopupMenuElements(popupMenuElements[i]); 16298 } 16299 }, 16300 InlineInitializeScrollElements: function(indexPath, menuElement) { 16301 var scrollArea = ASPx.GetNodeByClassName(menuElement, MenuCssClasses.ScrollArea); 16302 if(scrollArea) scrollArea.id = this.menu.GetScrollAreaId(indexPath); 16303 this.InitializeScrollButton(menuElement, MenuCssClasses.ScrollUpButton, this.menu.GetScrollUpButtonId(indexPath)); 16304 this.InitializeScrollButton(menuElement, MenuCssClasses.ScrollDownButton, this.menu.GetScrollDownButtonId(indexPath)); 16305 }, 16306 InitializeScrollButton: function(menuElement, buttonClassName, id) { 16307 var scrollButton = ASPx.GetNodeByClassName(menuElement, buttonClassName); 16308 if(!scrollButton) return; 16309 scrollButton.id = id; 16310 if(this.menu.NeedCreateItemsOnClientSide()) { 16311 ASPx.GetStateController().AddHoverItem(id, ["dxm-scrollBtnHovered"], [""]); 16312 ASPx.GetStateController().AddPressedItem(id, ["dxm-scrollBtnPressed"], [""]); 16313 } 16314 }, 16315 InlineInitializeMainMenuElements: function(menuElement) { 16316 this.menu.CheckElementsCache(menuElement); 16317 var contentElement = this.GetContentElement(menuElement); 16318 if(contentElement.className.indexOf("dxm-ti") > 1) 16319 this.itemLinkMode = "TextAndImage"; 16320 else if(contentElement.className.indexOf("dxm-t") > -1) 16321 this.itemLinkMode = "TextOnly"; 16322 var itemElements = this.GetItemElements(menuElement); 16323 for(var i = 0; i < itemElements.length; i++) 16324 this.InlineInitializeItemElement(itemElements[i], "", i); 16325 this.InlineInitializeScrollElements("", menuElement); 16326 }, 16327 InlineInitializePopupMenuElements: function(parentElement) { 16328 parentElement.style.position = "absolute"; 16329 var indexPath = this.GetSubMenuIndexPathByMenuParentElement(parentElement); 16330 var borderCorrectorElement = ASPx.GetNodeByClassName(parentElement, MenuCssClasses.BorderCorrector); 16331 if(borderCorrectorElement != null) { 16332 borderCorrectorElement.id = this.menu.GetMenuBorderCorrectorElementId(indexPath); 16333 borderCorrectorElement.style.position = "absolute"; 16334 parentElement.removeChild(borderCorrectorElement); 16335 parentElement.parentNode.appendChild(borderCorrectorElement); 16336 } 16337 this.InlineInitializePopupMenuMenuElement(parentElement, indexPath); 16338 }, 16339 GetSubMenuIndexPathByMenuParentElement: function(element){ 16340 return this.menu.GetMenuIndexPathById(element.id); 16341 }, 16342 InlineInitializePopupMenuMenuElement: function(parentElement, indexPath) { 16343 var menuElement = ASPx.GetNodeByClassName(parentElement, MenuCssClasses.PopupMenu); 16344 menuElement.id = this.menu.GetMenuMainElementId(indexPath); 16345 this.InlineInitializePopupMenuContentElements(parentElement, menuElement, indexPath); 16346 }, 16347 InlineInitializePopupMenuContentElements: function(parentElement, menuElement, indexPath) { 16348 this.menu.CheckElementsCache(menuElement); 16349 var contentElement = this.GetContentElement(menuElement); 16350 if(contentElement != null) { 16351 var itemElements = this.GetItemElements(menuElement); 16352 var parentIndexPath = parentElement == this.menu.GetMainElement() ? "" : indexPath; 16353 for(var i = 0; i < itemElements.length; i++) { 16354 var itemElementId = itemElements[i].id; 16355 if(itemElementId && aspxGetMenuCollection().GetMenu(itemElementId) != this.menu) 16356 continue; 16357 this.InlineInitializeItemElement(itemElements[i], parentIndexPath, i); 16358 } 16359 } 16360 this.InlineInitializeScrollElements(indexPath, menuElement); 16361 }, 16362 HasSubMenuTemplate: function(menuElement) { 16363 var contentElement = this.GetContentElement(menuElement); 16364 return contentElement && (contentElement.tagName != "UL" || !ASPx.GetNodesByPartialClassName(contentElement, MenuCssClasse
16364s.ContentContainer).length); 16365 }, 16366 InlineInitializeItemElement: function(itemElement, parentIndexPath, visibleIndex) { 16367 function getItemIndex(visibleIndex) { 16368 var itemData = parentItemData[Math.max(visibleIndex, 0)]; 16369 return itemData.constructor == Array 16370 ? itemData[0] 16371 : itemData; 16372 } 16373 var parentItemData = this.menu.renderData[parentIndexPath], 16374 prepareItemOnClick = parentItemData[visibleIndex].constructor == Array, 16375 indexPathPrefix = parentIndexPath + (parentIndexPath != "" ? ASPx.ItemIndexSeparator : ""), 16376 indexPath = indexPathPrefix + getItemIndex(visibleIndex); 16377 itemElement.id = this.menu.GetItemElementId(indexPath); 16378 if(this.canAssignAccessibilityEventsToChildrenLinks()) 16379 ASPx.AssignAccessibilityEventsToChildrenLinks(itemElement, true); 16380 if(this.canContainSeparators()) { 16381 var separatorElement = itemElement.previousSibling; 16382 if(separatorElement && separatorElement.className) { 16383 if(ASPx.ElementContainsCssClass(separatorElement, MenuCssClasses.Spacing)) 16384 separatorElement.id = this.menu.GetItemIndentElementId(indexPath); 16385 else if(ASPx.ElementContainsCssClass(separatorElement, MenuCssClasses.Separator)) 16386 separatorElement.id = this.menu.GetItemSeparatorElementId(indexPath); 16387 } 16388 } 16389 var contentElement = this.GetItemContentElement(itemElement); 16390 if(contentElement != null) { 16391 contentElement.id = this.menu.GetItemContentElementId(indexPath); 16392 if (this.canContainImageElement()) { 16393 var imageElement = ASPx.GetNodeByClassName(contentElement, MenuCssClasses.Image); 16394 if(imageElement == null) { 16395 var hyperLinkElement = ASPx.GetNodeByClassName(contentElement, MenuCssClasses.DX); 16396 if(hyperLinkElement != null) 16397 imageElement = ASPx.GetNodeByClassName(hyperLinkElement, MenuCssClasses.Image); 16398 } 16399 if(imageElement != null) 16400 imageElement.id = this.menu.GetItemImageId(indexPath); 16401 } 16402 } 16403 else 16404 prepareItemOnClick = false; 16405 this.InlineInitializeItemPopOutElement(itemElement, indexPath); 16406 if(prepareItemOnClick) 16407 this.InlineInitializeItemOnClick(itemElement, indexPath); 16408 if(ASPx.ElementContainsCssClass(itemElement, MenuCssClasses.ItemSelected)) 16409 this.menu.serverSideSelectedItemPath = indexPath; 16410 }, 16411 canAssignAccessibilityEventsToChildrenLinks: function () { return true; }, 16412 canContainSeparators: function () { return true; }, 16413 canContainImageElement: function () { return true; }, 16414 InlineInitializeItemPopOutElement: function(itemElement, indexPath) { 16415 var popOutElement = this.GetItemPopOutElement(itemElement); 16416 if(popOutElement != null) { 16417 popOutElement.id = this.menu.GetItemPopOutElementId(indexPath); 16418 var popOutImageElement = ASPx.GetNodeByClassName(popOutElement, MenuCssClasses.PopOutImage); 16419 if(popOutImageElement != null) 16420 popOutImageElement.id = this.menu.GetItemPopOutImageId(indexPath); 16421 } 16422 }, 16423 InlineInitializeItemOnClick: function(itemElement, indexPath) { 16424 var name = this.menu.name; 16425 var onclick = this.GetItemOnClick(name, itemElement, indexPath); 16426 if(this.menu.IsDropDownItem(indexPath)) { 16427 var contentElement = this.menu.GetItemContentElement(indexPath); 16428 var dropDownElement = this.menu.GetItemPopOutElement(indexPath); 16429 var dropDownOnclick = this.GetItemDropdownOnClick(name, itemElement, indexPath); 16430 this.AssignItemOnClickToElement(contentElement, this.itemLinkMode, onclick); 16431 this.AssignItemOnClickToElement(dropDownElement, this.itemLinkMode, dropDownOnclick); 16432 } 16433 else 16434 this.AssignItemOnClickToElement(itemElement, this.itemLinkMode, onclick); 16435 }, 16436 AssignItemOnClickToElement: function(element, itemLinkMode, method) { 16437 switch(itemLinkMode){ 16438 case "ContentBounds": 16439 this.AssignItemOnClickToElementCore(element, method); 16440 break; 16441 case "TextOnly": 16442 var textElement = ASPx.GetNodeByTagName(element, "A"); 16443 if(!textElement) 16444 textElement = ASPx.GetNodeByTagName(element, "SPAN"); 16445 if(textElement) 16446 this.AssignItemOnClickToElementCore(textElement, method); 16447 break; 16448 case "TextAndImage": 16449 var linkElement = ASPx.GetNodeByTagName(element, "A"); 16450 if(linkElement) 16451 this.AssignItemOnClickToElementCore(linkElement, method); 16452 else{ 16453 var textElement = ASPx.GetNodeByTagName(element, "SPAN"); 16454 if(textElement) 16455 this.AssignItemOnClickToElementCore(textElement, method); 16456 var imageElement = ASPx.GetNodeByTagName(element, "IMG"); 16457 if(imageElement) 16458 this.AssignItemOnClickToElementCore(imageElement, method); 16459 } 16460 break; 16461 } 16462 }, 16463 AssignItemOnClickToElementCore: function(element, method) { 16464 ASPx.Evt.AttachEventToElement(element, "click", method); 16465 }, 16466 GetItemOnClick: function(name, itemElement, indexPath) { 16467 var menu = this.menu; 16468 var sendPostBackHandler = function() { 16469 menu.SendPostBack("CLICK:" + indexPath); 16470 }; 16471 var itemClickHandler = function(e) { 16472 ASPx.MIClick(e, name, indexPath); 16473 }; 16474 var itemLink = this.GetItemLinkElement(itemElement); 16475 var handler = menu.autoPostBack && !menu.IsClientSideEventsAssigned() && (!itemLink || itemLink.href === "") 16476 ? sendPostBackHandler 16477 : itemClickHandler; 16478 return function(e) { 16479 if(!itemElement.clientDisabled) 16480 handler(e); 16481 }; 16482 }, 16483 GetItemDropdownOnClick: function(name, itemElement, indexPath) { 16484 return function(e) { 16485 if(!itemElement.clientDisabled) 16486 ASPx.MIDDClick(e, name, indexPath); 16487 }; 16488 }, 16489 ChangeItemEnabledAttributes: function(itemElement, enabled, accessibilityCompliant) { 16490 if(!itemElement) return; 16491 itemElement.clientDisabled = !enabled; 16492 ASPx.Attr.ChangeStyleAttributesMethod(enabled)(itemElement, "cursor"); 16493 var hyperLink = this.GetItemLinkElement(itemElement); 16494 if(hyperLink) 16495 this.ChangeItemLinkEnabledAttributes(hyperLink, itemElement, enabled, accessibilityCompliant); 16496 }, 16497 ChangeItemLinkEnabledAttributes: function(hyperLink, itemElement, enabled, accessibilityCompliant) { 16498 if(accessibilityCompliant) { 16499 var action = enabled ? ASPx.Attr.RemoveAttribute : ASPx.Attr.SetAttribute; 16500 action(hyperLink, "aria-disabled", "true"); 16501 } 16502 ASPx.Attr.ChangeAttributesMethod(enabled)(hyperLink, "href");
16503 if(accessibilityCompliant && !enabled && itemElement.enabled) 16504 hyperLink.href = ASPx.AccessibilityEmptyUrl; 16505 }, 16506 GetPopupMenuElements: function(menuElement) { 16507 return ASPx.GetChildNodesByTagName(menuElement.parentNode, "DIV"); 16508 }, 16509 GetContentElement: function(menuElement) { 16510 return ASPx.CacheHelper.GetCachedElement(this, "contentElement", 16511 function() { 16512 var contentElement = ASPx.GetNodeByTagName(menuElement, "DIV", 0); 16513 if(contentElement && contentElement.className == MenuCssClasses.DX && contentElement.parentNode == menuElement) 16514 return contentElement; 16515 contentElement = ASPx.GetNodeByTagName(menuElement, "UL", 0); 16516 if(contentElement) 16517 return contentElement; 16518 return ASPx.GetNodeByTagName(menuElement, "TABLE", 0); 16519 }, menuElement); 16520 }, 16521 GetItemElements: function(menuElement) { 16522 return ASPx.CacheHelper.GetCachedElements(this, "itemElements", 16523 function() { 16524 var contentElement = this.GetContentElement(menuElement); 16525 return contentElement ? ASPx.GetNodesByClassName(contentElement, MenuCssClasses.Item) : null; 16526 }, menuElement); 16527 }, 16528 GetSpacingElements: function(menuElement) { 16529 return ASPx.CacheHelper.GetCachedElements(this, "spacingElements", 16530 function() { 16531 var contentElement = this.GetContentElement(menuElement); 16532 return contentElement ? ASPx.GetNodesByClassName(contentElement, MenuCssClasses.Spacing) : null; 16533 }, menuElement); 16534 }, 16535 GetAlignSpacingElements: function(menuElement) { 16536 return ASPx.CacheHelper.GetCachedElements(this, "alignSpacingElements", 16537 function() { 16538 var contentElement = this.GetContentElement(menuElement); 16539 return contentElement ? ASPx.GetNodesByClassName(contentElement, MenuCssClasses.AlignSpacing) : null; 16540 }, menuElement); 16541 }, 16542 GetSeparatorElements: function(menuElement) { 16543 return ASPx.CacheHelper.GetCachedElements(this, "separatorElements", 16544 function() { 16545 var contentElement = this.GetContentElement(menuElement); 16546 return contentElement ? ASPx.GetNodesByClassName(contentElement, MenuCssClasses.Separator) : null; 16547 }, menuElement); 16548 }, 16549 GetItemContentElement: function(itemElement) { 16550 return ASPx.CacheHelper.GetCachedElement(this, "contentElement", 16551 function() { 16552 return ASPx.GetNodeByClassName(itemElement, MenuCssClasses.ContentContainer); 16553 }, itemElement); 16554 }, 16555 GetItemPopOutElement: function(itemElement) { 16556 return ASPx.CacheHelper.GetCachedElement(this, "popOutElement", 16557 function() { 16558 return ASPx.GetNodeByClassName(itemElement, MenuCssClasses.PopOutContainer); 16559 }, itemElement); 16560 }, 16561 GetAdaptiveMenuItemElement: function(menuElement) { 16562 return ASPx.CacheHelper.GetCachedElement(this, "adaptiveMenuItemElement", 16563 function() { 16564 var contentElement = this.GetContentElement(menuElement); 16565 return contentElement ? ASPx.GetNodeByClassName(contentElement, this.menu.getAdaptiveMenuItemCssClass()) : null; 16566 }, menuElement); 16567 }, 16568 GetAdaptiveMenuItemSpacingElement: function(menuElement) { 16569 return ASPx.CacheHelper.GetCachedElement(this, "adaptiveMenuItemSpacingElement", 16570 function() { 16571 var contentElement = this.GetContentElement(menuElement); 16572 return contentElement ? ASPx.GetNodeByClassName(contentElement, this.menu.getAdaptiveMenuItemSpacingCssClass()) : null; 16573 }, menuElement); 16574 }, 16575 GetAdaptiveMenuElement: function(menuElement) { 16576 return ASPx.CacheHelper.GetCachedElement(this, "adaptiveMenuElement", 16577 function() { 16578 var adaptiveItemElement = this.GetAdaptiveMenuItemElement(menuElement); 16579 if(adaptiveItemElement){ 16580 var adaptiveItemIndexPath = this.menu.GetIndexPathById(adaptiveItemElement.id); 16581 var adaptiveMenuParentElement = this.menu.GetMenuElement(adaptiveItemIndexPath); 16582 if(adaptiveMenuParentElement) 16583 return this.menu.GetMenuMainElement(adaptiveMenuParentElement); 16584 } 16585 return null; 16586 }, menuElement); 16587 }, 16588 GetAdaptiveMenuContentElement: function(menuElement) { 16589 return ASPx.CacheHelper.GetCachedElement(this, "adaptiveMenuContentElement", 16590 function() { 16591 var adaptiveMenuElement = this.GetAdaptiveMenuElement(menuElement); 16592 return adaptiveMenuElement ? this.GetContentElement(adaptiveMenuElement) : null; 16593 }, menuElement); 16594 }, 16595 GetItemLinkElement: function(itemElement) { 16596 return ASPx.GetNodeByTagName(itemElement, "A", 0); 16597 }, 16598 CalculateMenuControl: function(menuElement, recalculate) { 16599 if(menuElement.offsetWidth === 0) return; 16600 this.PrecalculateMenuPopOuts(menuElement); 16601 var isVertical = this.menu.IsVertical(""); 16602 var isAutoWidth = ASPx.ElementContainsCssClass(menuElement, MenuCssClasse
16602s.AutoWidthMenu); 16603 var isNoWrap = ASPx.ElementContainsCssClass(menuElement, MenuCssClasses.NoWrapMenu); 16604 var contentElement = this.GetContentElement(menuElement); 16605 if(this.menu.enableAdaptivity) 16606 this.CalculateAdaptiveMainMenu(menuElement, contentElement, isVertical, isAutoWidth, isNoWrap, recalculate); 16607 else 16608 this.CalculateMainMenu(menuElement, contentElement, isVertical, isAutoWidth, isNoWrap, recalculate); 16609 }, 16610 CalculateMainMenu: function(menuElement, contentElement, isVertical, isAutoWidth, isNoWrap, recalculate) { 16611 var itemElements = this.GetItemElements(menuElement); 16612 this.PrecalculateMenuItems(menuElement, itemElements, recalculate); 16613 this.CalculateMenuItemsAutoWidth(menuElement, itemElements, isVertical, isAutoWidth); 16614 this.CalculateMinSize(menuElement, contentElement, itemElements, isVertical, isAutoWidth, isNoWrap, recalculate); 16615 this.CalculateMenuItems(menuElement, contentElement, itemElements, isVertical, recalculate); 16616 this.CalculateSeparatorsAndSpacers(menuElement, itemElements, contentElement, isVertical); 16617 }, 16618 PrecalculateMenuPopOuts: function(menuElement) { 16619 if(menuElement.popOutsPreCalculated) return; 16620 var elements = this.GetItemElements(menuElement); 16621 for(var i = 0; i < elements.length; i++) { 16622 var popOutElement = this.GetItemPopOutElement(elements[i]); 16623 if (popOutElement) 16624 popOutElement.style.display = "block"; 16625 } 16626 menuElement.popOutsPreCalculated = true; 16627 }, 16628 PrecalculateMenuItems: function(menuElement, itemElements, recalculate) { 16629 if(!recalculate) return; 16630 for(var i = 0; i < itemElements.length; i++) { 16631 var itemContentElement = this.GetItemContentElement(itemElements[i]); 16632 if(!itemContentElement || itemContentElement.offsetWidth === 0) continue; 16633 ASPx.SetElementFloat(itemContentElement, ""); 16634 ASPx.Attr.RestoreStyleAttribute(itemContentElement, "padding-left"); 16635 ASPx.Attr.RestoreStyleAttribute(itemContentElement, "padding-right"); 16636 this.ReCalculateMenuItemContent(itemElements[i], itemContentElement); 16637 } 16638 }, 16639 ReCalculateMenuItemContent: function(itemElement, itemContentElement) { 16640 for(var j = 0; j < itemElement.childNodes.length; j++) { 16641 var child = itemElement.childNodes[j]; 16642 if(!child.offsetWidth) continue; 16643 if(child !== itemContentElement) { 16644 if(ASPx.Browser.IE && ASPx.Browser.Version == 8) 16645 ASPx.Attr.RestoreStyleAttribute(child, "margin"); 16646 else{ 16647 ASPx.Attr.RestoreStyleAttribute(child, "margin-top"); 16648 ASPx.Attr.RestoreStyleAttribute(child, "margin-bottom"); 16649 } 16650 } 16651 } 16652 }, 16653 CalculateMenuItemsAutoWidth: function(menuElement, itemElements, isVertical, isAutoWidth) { 16654 if(!isAutoWidth) return; 16655 for(var i = 0; i < itemElements.length; i++) 16656 ASPx.Attr.RestoreStyleAttribute(itemElements[i], "width"); 16657 if(!isVertical) { 16658 var autoWidthItemCount = 0; 16659 var adaptiveItemCssClass = this.menu.getAdaptiveMenuItemCssClass(); 16660 for(var i = 0; i < itemElements.length; i++) { 16661 if(ASPx.GetElementDisplay(itemElements[i]) && !ASPx.ElementHasCssClass(itemElements[i], adaptiveItemCssClass)) 16662 autoWidthItemCount++; 16663 } 16664 for(var i = 0; i < itemElements.length; i++) { 16665 if(autoWidthItemCount > 0 && !ASPx.ElementHasCssClass(itemElements[i], adaptiveItemCssClass) && (itemElements[i].style.width === "" || itemElements[i].autoWidth)) { 16666 ASPx.Attr.ChangeStyleAttribute(itemElements[i], "width", (100 / autoWidthItemCount) + "%"); 16667 itemElements[i].autoWidth = true; 16668 } 16669 } 16670 } 16671 }, 16672 CalculateMenuItems: function(menuElement, contentElement, itemElements, isVertical, recalculate) { 16673 if(contentElement.itemsCalculated && recalculate) 16674 contentElement.itemsCalculated = false; 16675 if(menuElement.offsetWidth === 0) return; 16676 if(contentElement.style.margin === "0px auto") 16677 ASPx.SetStyles(contentElement, { float: "none" }); 16678 var menuWidth = ASPx.GetCurrentStyle(menuElement).width; 16679 var menuRequireItemCorrection = isVertical && menuWidth; 16680 this.ApplyItemsVerticalAlignment(menuElement, itemElements); 16681 for(var i = 0; i < itemElements.length; i++) { 16682 if(!itemElements[i].style.width && !menuRequireItemCorrection) continue; 16683 if(ASPx.IsPercentageSize(itemElements[i].style.width) && contentElement.style.width === "") 16684 contentElement.style.width = "100%"; 16685 var itemContentElement = this.GetItemContentElement(itemElements[i]); 16686 if(!itemContentElement || itemContentElement.offsetWidth === 0) continue; 16687 if(!contentElement.itemsCalculated) { 16688 ASPx.Attr.RestoreStyleAttribute(itemContentElement, "padding-left"); 16689 ASPx.Attr.RestoreStyleAttribute(itemContentElement, "padding-right"); 16690 ASPx.SetElementFloat(itemContentElement, "none"); 16691 var itemContentCurrentStyle = ASPx.GetCurrentStyle(itemContentElement); 16692 if(!isVertical || (itemContentCurrentStyle.textAlign != "center" && menuWidth)) { 16693 var originalPaddingLeft = parseInt(itemContentCurrentStyle.paddingLeft); 16694 var originalPaddingRight = parseInt(itemContentCurrentStyle.paddingRight); 16695 var leftChildrenWidth = 0, rightChildrenWidth = 0;
16696 for(var j = 0; j < itemElements[i].childNodes.length; j++) { 16697 var child = itemElements[i].childNodes[j]; 16698 if(!child.offsetWidth) continue; 16699 if(child !== itemContentElement) { 16700 if(ASPx.GetElementFloat(child) === "right") 16701 rightChildrenWidth += child.offsetWidth + ASPx.GetLeftRightMargins(child); 16702 else if(ASPx.GetElementFloat(child) === "left") 16703 leftChildrenWidth += child.offsetWidth + ASPx.GetLeftRightMargins(child); 16704 } 16705 } 16706 if(leftChildrenWidth > 0 || rightChildrenWidth > 0){ 16707 ASPx.Attr.ChangeStyleAttribute(itemContentElement, "padding-left", (leftChildrenWidth + originalPaddingLeft) + "px"); 16708 ASPx.Attr.ChangeStyleAttribute(itemContentElement, "padding-right", (rightChildrenWidth + originalPaddingRight) + "px"); 16709 } 16710 } 16711 } 16712 ASPx.AdjustWrappedTextInContainer(itemContentElement); 16713 this.CalculateMenuItemContent(itemElements[i], itemContentElement); 16714 } 16715 contentElement.itemsCalculated = true; 16716 }, 16717 ApplyItemsVerticalAlignment: function(menuElement, itemElements) { 16718 var menuAlignmentInProgressClassName = "miva"; 16719 ASPx.AddClassNameToElement(menuElement, menuAlignmentInProgressClassName); 16720 if(!ASPx.IsExists(itemElements)) 16721 itemElements = this.GetItemElements(menuElement); 16722 for(var i = 0; i < itemElements.length; i++) { 16723 var itemContentElement = this.GetItemContentElement(itemElements[i]); 16724 if(itemContentElement && itemContentElement.offsetWidth !== 0 && itemContentElement.style.verticalAlign) { 16725 this.CalculateItemContentLineHeight(itemElements[i], itemContentElement); 16726 ASPx.RemoveClassNameFromElement(itemContentElement, MenuCssClasses.ContentContainerWithVerticalAlignment); 16727 } 16728 } 16729 ASPx.RemoveClassNameFromElement(menuElement, menuAlignmentInProgressClassName); 16730 }, 16731 CalculateItemContentLineHeight: function(itemElement, itemContentElement) { 16732 var lineHeight = 0; 16733 var maxHeight = itemElement.getBoundingClientRect().height - this.GetBordersAndPaddingSummaryHeight(itemElement); 16734 if(itemContentElement && itemContentElement.offsetHeight != maxHeight) 16735 lineHeight = maxHeight - this.GetBordersAndPaddingSummaryHeight(itemContentElement); 16736 if(lineHeight > 0) { 16737 var link = this.GetItemLinkElement(itemElement); 16738 if(link) 16739 ASPx.SetStyles(link, { lineHeight: lineHeight }, false); 16740 else 16741 ASPx.SetStyles(itemContentElement, { lineHeight: lineHeight }, false); 16742 } 16743 }, 16744 GetBordersAndPaddingSummaryHeight: function(element) { 16745 var elementStyle = getComputedStyle(element); 16746 return ASPx.GetVerticalBordersWidth(element, elementStyle) + ASPx.PxToFloat(elementStyle.paddingTop) + ASPx.PxToFloat(elementStyle.paddingBottom); 16747 }, 16748 CalculateMenuItemContent: function(itemElement, itemContentElement) { 16749 var itemContentFound = false; 16750 for(var j = 0; j < itemElement.childNodes.length; j++) { 16751 var child = itemElement.childNodes[j]; 16752 if(!child.offsetWidth) continue; 16753 var contentHeight = itemContentElement.offsetHeight; 16754 if(child !== itemContentElement) { 16755 if(itemContentFound){ 16756 if(ASPx.Browser.IE && ASPx.Browser.Version == 8) 16757 ASPx.Attr.ChangeStyleAttribute(child, "margin", "-" + contentHeight + "px 0 0"); 16758 else 16759 ASPx.Attr.ChangeStyleAttribute(child, "margin-top", "-" + contentHeight + "px"); 16760 } 16761 else{ 16762 if(ASPx.Browser.IE && ASPx.Browser.Version == 8) 16763 ASPx.Attr.ChangeStyleAttribute(child, "margin", "0 0 -" + contentHeight + "px"); 16764 else 16765 ASPx.Attr.ChangeStyleAttribute(child, "margin-bottom", "-" + contentHeight + "px"); 16766 } 16767 } 16768 else 16769 itemContentFound = true; 16770 } 16771 }, 16772 CalculateSubMenu: function(parentElement, recalculate) { 16773 var menuElement = this.menu.GetMenuMainElement(parentElement); 16774 var contentElement = this.GetContentElement(menuElement); 16775 if(!parentElement.isSubMenuCalculated || recalculate) { 16776 menuElement.style.width = ""; 16777 menuElement.style.display = "table"; 16778 menuElement.style.borderSpacing = "0px"; 16779 parentElement.isSubMenuCalculated = true; 16780 if(contentElement.tagName === "UL") { 16781 if(contentElement.offsetWidth > 0) { 16782 if(ASPx.Browser.IE && ASPx.ElementHasCssClass(menuElement, this.menu.getAdaptiveMenuCssClass())) 16783 menuElement.style.width = "0px"; 16784 menuElement.style.width = contentElement.offsetWidth + "px"; 16785 menuElement.style.display = ""; 16786 if(ASPx.IsPercentageSize(contentElement.style.width)) 16787 contentElement.style.width = menuElement.style.width; 16788 } 16789 else 16790 parentElement.isSubMenuCalculated = false; 16791 } 16792 } 16793 this.CalculateSubMenuItems(menuElement, contentElement, recalculate); 16794 }, 16795 CalculateSubMenuItems: function(menuElement, contentElement, recalculate) { 16796 var itemElements = this.GetItemElements(menuElement); 16797 this.PrecalculateMenuItems(menuElement, itemElements, recalculate); 16798 this.CalculateMenuItems(menuElement, contentElement, itemElements, true, recalculate); 16799 }, 16800 ResetMinSize: function() { 16801 var menuElement = this.menu.GetMainElement(); 16802 if(!menuElement.isMinSizeCalculated || this.menu.isVertical) return; 16803 var itemElements = this.GetItemElements(menuElement); 16804 var contentElement = this.GetContentElement(menuElement); 16805 if(!!contentElement.adaptiveInfo) 16806 itemElements = itemElements.concat(contentElement.adaptiveInfo.elements); 16807 for(var i = 0; i < itemElements.length; i++) 16808 this.ResetItemMinSize(itemElements[i]); 16809 menuElement.isMinSizeCalculated = false; 16810 }, 16811 ResetItemMinSize: function(itemElement) { 16812 itemElement.style.minWidth = ""; 16813 itemElement.isMinSizeCalculated = false; 16814 }, 16815 CalculateMinSize: function(menuElement, contentElement, itemElements, isVertical, isAutoWidth, isNoWrap, recalculate) { 16816 if(menuElement.isMinSizeCalculated && !recalculate) return; 16817 if(isVertical) { 16818 menuElement.style.minWidth = ""; 16819 if(!this.menu.IsSidePanelExpanded()) { 16820 ASPx.Attr.ChangeStyleAttribute(contentElement, "width", "1px"); 16821 for(var i = 0; i < itemElements.length; i++) { 16822 var itemContentElement = this.GetItemContentElement(itemElements[i]); 16823 if(!itemContentElement || itemElements[i].offsetWidth === 0) continue; 16824 this.CalculateItemMinSize(itemElements[i], recalculate); 16825 } 16826 ASPx.Attr.RestoreStyleAttribute(contentElement, "width"); 16827 } 16828 } 16829 else {
16830 ASPx.RemoveClassNameFromElement(menuElement, MenuCssClasses.NoWrapMenu); 16831 ASPx.RemoveClassNameFromElement(menuElement, MenuCssClasses.AutoWidthMenu); 16832 if(isAutoWidth || isNoWrap) 16833 menuElement.style.minWidth = ""; 16834 ASPx.Attr.ChangeStyleAttribute(menuElement, "width", "1px"); 16835 for(var i = 0; i < itemElements.length; i++) { 16836 var itemContentElement = this.GetItemContentElement(itemElements[i]); 16837 if((!itemContentElement || itemElements[i].offsetWidth === 0) && !ASPx.ElementHasCssClass(itemElements[i], MenuCssClasses.ItemTemplate)) continue; 16838 var textContainer = ASPx.GetNodeByTagName(itemContentElement, "SPAN", 0); 16839 if(textContainer && ASPx.GetCurrentStyle(textContainer).whiteSpace !== "nowrap") 16840 ASPx.AdjustWrappedTextInContainer(itemContentElement); 16841 this.CalculateItemMinSize(itemElements[i], recalculate); 16842 } 16843 if(isAutoWidth) 16844 ASPx.AddClassNameToElement(menuElement, MenuCssClasses.AutoWidthMenu); 16845 if(isNoWrap) 16846 ASPx.AddClassNameToElement(menuElement, MenuCssClasses.NoWrapMenu); 16847 if(isAutoWidth || isNoWrap) 16848 menuElement.style.minWidth = (contentElement.offsetWidth + ASPx.GetLeftRightBordersAndPaddingsSummaryValue(menuElement)) + "px"; 16849 ASPx.Attr.RestoreStyleAttribute(menuElement, "width"); 16850 } 16851 menuElement.isMinSizeCalculated = true; 16852 }, 16853 CalculateItemMinSize: function(itemElement, recalculate) { 16854 if(itemElement.isMinSizeCalculated && !recalculate) return; 16855 var sizeCorrection = ASPx.Browser.HardwareAcceleration ? 1 : 0; 16856 itemElement.style.minWidth = ""; 16857 var childrenWidth = 0; 16858 if(ASPx.ElementHasCssClass(itemElement, MenuCssClasses.ItemTemplate)) { 16859 ASPx.Attr.ChangeStyleAttribute(itemElement, "display", "table"); 16860 childrenWidth += itemElement.clientWidth + sizeCorrection; 16861 ASPx.Attr.RestoreStyleAttribute(itemElement, "display"); 16862 if(ASPx.Browser.Edge && ASPx.Browser.MajorVersion >= 16) 16863 var dummy = itemElement.clientWidth; 16864 } 16865 else { 16866 for(var j = 0; j < itemElement.childNodes.length; j++) { 16867 var child = itemElement.childNodes[j]; 16868 if(!child.offsetWidth) continue; 16869 var float = ASPx.GetElementFloat(child); 16870 if(float === "none") { 16871 childrenWidth = child.offsetWidth; 16872 break; 16873 } 16874 else 16875 childrenWidth += child.offsetWidth + sizeCorrection; 16876 } 16877 } 16878 itemElement.style.minWidth = childrenWidth + "px"; 16879 itemElement.isMinSizeCalculated = true; 16880 }, 16881 CalculateSeparatorsAndSpacers: function(menuElement, itemElements, contentElement, isVertical, isAutoWidth, isNoWrap) { 16882 var spacerElements = this.GetSpacingElements(menuElement); 16883 var spacerAndSeparatorElements = spacerElements.concat(this.GetSeparatorElements(menuElement)); 16884 for(var i = 0; i < spacerAndSeparatorElements.length; i++) 16885 ASPx.Attr.RestoreStyleAttribute(spacerAndSeparatorElements[i], "height"); 16886 if(!isVertical && itemElements) { 16887 var menuHeight = 0; 16888 if(!isAutoWidth && !isNoWrap) { 16889 for(var i=0; i < itemElements.length; i++) { 16890 var newHeight = itemElements[i].getBoundingClientRect().height; 16891 if(newHeight > menuHeight) 16892 menuHeight = newHeight; 16893 } 16894 } 16895 for(var i = 0; i < spacerAndSeparatorElements.length; i++){ 16896 var separatorHeight = menuHeight - ASPx.GetTopBottomBordersAndPaddingsSummaryValue(spacerAndSeparatorElements[i]) - ASPx.GetTopBottomMargins(spacerAndSeparatorElements[i]); 16897 ASPx.Attr.ChangeStyleAttribute(spacerAndSeparatorElements[i], "height", separatorHeight + "px"); 16898 } 16899 for(var i = 0; i < spacerElements.length; i++){ 16900 if(!ASPx.ElementContainsCssClass(spacerElements[i], this.menu.getAdaptiveMenuItemSpacingCssClass())) 16901 spacerElements[i].style.minWidth = spacerElements[i].style.width; 16902 } 16903 this.calculateAlignSpacings(menuElement, contentElement); 16904 } 16905 }, 16906 calculateAlignSpacings: function(menuElement, contentElement) { 16907 var separatorElements = this.GetAlignSpacingElements(menuElement), 16908 separatorsCount = separatorElements.length; 16909 if(separatorsCount === 0) return; 16910 ASPx.Data.ForEach(separatorElements, function(separator) { 16911 separator.style.width = "0"; 16912 }); 16913 var unit = this.menu.enableAdaptivity ? "%" : "px"; 16914 var width = this.menu.enableAdaptivity ? 100 / separatorsCount : 16915 (ASPx.GetClearClientWidth(menuElement) - contentElement.offsetWidth) / separatorsCount; 16916 ASPx.Data.ForEach(separatorElements, function(separator) { 16917 separator.style.width = width + unit; 16918 }); 16919 if(!this.menu.enableAdaptivity) 16920 separatorElements[0].style.width = (width - 1) + unit; 16921 }, 16922 CalculateAdaptiveMainMenu: function(menuElement, contentElement, isVertical, isAutoWidth, isNoWrap, recalculate) { 16923 var adaptiveItemElement = this.GetAdaptiveMenuItemElement(menuElement); 16924 if(!adaptiveItemElement) return; 16925 var adaptiveItemSpacing = this.GetAdaptiveMenuItemSpacingElement(menuElement); 16926 if(adaptiveItemSpacing) adaptiveItemSpacing.style.width = ""; 16927 var adaptiveMenuElement = this.GetAdaptiveMenuElement(menuElement); 16928 if(!adaptiveMenuElement) return; 16929 var adaptiveMenuContentElement = this.GetAdaptiveMenuContentElement(menuElement); 16930 if(!contentElement.adaptiveInfo) 16931 this.InitAdaptiveInfo(contentElement); 16932 var wasAdaptivity = contentElement.adaptiveInfo.hasAdaptivity; 16933 if(wasAdaptivity) { 16934 var previousSibling = this.GetAdaptiveItemElementPreviousSibling(adaptiveItemSpacing || adaptiveItemElement); 16935 this.RestoreAdaptiveItems(previousSibling, contentElement, isVertical); 16936 } 16937 if(!isVertical) { 16938 ASPx.SetElementDisplay(adaptiveItemElement, true); 16939 if(adaptiveItemSpacing) ASPx.SetElementDisplay(adaptiveItemSpacing, true);
16940 ASPx.AddClassNameToElement(menuElement, MenuCssClasses.CalculateMenu); 16941 ASPx.RemoveClassNameFromElement(menuElement, MenuCssClasses.NoWrapMenu); 16942 menuElement.style.minWidth = ""; 16943 var adaptiveItemWidth = adaptiveItemElement.offsetWidth; 16944 if(isAutoWidth) { 16945 ASPx.Attr.ChangeStyleAttribute(contentElement, "display", "none"); 16946 ASPx.Attr.ChangeStyleAttribute(menuElement, "min-width", ""); 16947 } 16948 var menuWidth = menuElement.offsetWidth - ASPx.GetLeftRightBordersAndPaddingsSummaryValue(menuElement) - adaptiveItemWidth; 16949 if(isAutoWidth) { 16950 ASPx.Attr.RestoreStyleAttribute(contentElement, "display"); 16951 ASPx.Attr.RestoreStyleAttribute(menuElement, "min-width"); 16952 } 16953 var additionalWidth = adaptiveItemWidth; 16954 if(adaptiveItemSpacing) { 16955 menuWidth -= adaptiveItemSpacing.offsetWidth; 16956 additionalWidth += adaptiveItemSpacing.offsetWidth; 16957 } 16958 var hasAdaptivity = this.HideAdaptiveItems(menuWidth, additionalWidth, contentElement, adaptiveMenuContentElement); 16959 contentElement.adaptiveInfo.hasAdaptivity = hasAdaptivity; 16960 this.SetAdaptiveItemElementVisibility(adaptiveItemElement, adaptiveItemSpacing, hasAdaptivity); 16961 contentElement.style.width = hasAdaptivity ? "100%" : ""; 16962 if(hasAdaptivity){ 16963 ASPx.CacheHelper.DropCache(adaptiveMenuElement); 16964 this.CalculateSubMenu(adaptiveMenuElement, true); 16965 this.CalculateSeparatorsAndSpacers(adaptiveMenuElement, null, adaptiveMenuContentElement, true); 16966 } 16967 if(isNoWrap) { 16968 ASPx.AddClassNameToElement(menuElement, MenuCssClasses.NoWrapMenu); 16969 if(adaptiveItemSpacing) adaptiveItemSpacing.style.width = hasAdaptivity ? "100%" : ""; 16970 } 16971 ASPx.RemoveClassNameFromElement(menuElement, MenuCssClasses.CalculateMenu); 16972 } 16973 else { 16974 this.SetAdaptiveItemElementVisibility(adaptiveItemElement, adaptiveItemSpacing, false); 16975 } 16976 if(wasAdaptivity || contentElement.adaptiveInfo.hasAdaptivity) 16977 ASPx.CacheHelper.DropCache(menuElement); 16978 this.CalculateMainMenu(menuElement, contentElement, isVertical, isAutoWidth, isNoWrap, wasAdaptivity || contentElement.adaptiveInfo.hasAdaptivity || recalculate); 16979 }, 16980 InitAdaptiveInfo: function(contentElement) { 16981 if(contentElement.adaptiveInfo) return; 16982 contentElement.adaptiveInfo = { }; 16983 contentElement.adaptiveInfo.elements = this.CreateAdaptiveElementsArray(contentElement); 16984 contentElement.adaptiveInfo.hasAdaptivity = false; 16985 }, 16986 GetAdaptiveItemElementByIndex: function(adaptiveInfo, index) { 16987 return adaptiveInfo.elements[index]; 16988 }, 16989 GetAdaptiveItemElementParent: function(adaptiveInfo, index) { 16990 return undefined; 16991 }, 16992 GetAdaptiveItemElementPreviousSibling: function(defaultPreviousSibling) { 16993 return defaultPreviousSibling; 16994 }, 16995 RestoreAdaptiveItems: function(previousSibling, contentElement, isVertical) { 16996 this.SetLastSeparatorsVisible(true, contentElement); 16997 for(var i = 0; i < contentElement.adaptiveInfo.elements.length; i++) { 16998 var element = this.GetAdaptiveItemElementByIndex(contentElement.adaptiveInfo, i); 16999 if(ASPx.Browser.IE) 17000 ASPx.RemoveElement(element); 17001 var isReplacedIndent = !element.parent; 17002 if(isReplacedIndent) 17003 ASPx.RemoveElement(ASPx.GetElementById(element.id)); 17004 var itemParentElement = this.GetAdaptiveItemElementParent(contentElement.adaptiveInfo, i) || contentElement; 17005 itemParentElement.insertBefore(element, previousSibling); 17006 ASPx.Attr.RestoreStyleAttribute(element, "width"); 17007 if(!isVertical) 17008 this.SetItemItemPopOutImageHorizontal(element); 17009 if(ASPx.ElementContainsCssClass(element, MenuCssClasses.Separator) || ASPx.ElementContainsCssClass(element, MenuCssClasses.Spacing)) 17010 ASPx.RemoveClassNameFromElement(element, MenuCssClasses.AdaptiveMenuHiddenElement); 17011 } 17012 if(this.menu.GetRootItem()) { 17013 for(var i = this.elementsToHide.length - 1; i >= 0; i--) { 17014 if(!this.elementsToHide[i]) continue; 17015 var indexPath = this.elementsToHide[i].indexPath; 17016 if(this.menu.GetItemByIndexPath(indexPath).GetVisible()) 17017 this.menu.UpdateItemCssClasses(indexPath, true); 17018 this.elementsToHide[i] = null; 17019 } 17020 } 17021 this.elementsToHide = []; 17022 }, 17023 SetLastSeparatorsVisible: function(isVisible, contentElement) { 17024 var elements = ASPx.GetChildElementNodes(contentElement); 17025 for(var i = 0; i < elements.length; i++) { 17026 var element = elements[i];
17027 if(ASPx.ElementContainsCssClass(element, MenuCssClasses.Separator) || ASPx.ElementContainsCssClass(element, MenuCssClasses.Spacing)) 17028 ASPx.RemoveClassNameFromElement(element, MenuCssClasses.AdaptiveMenuHiddenElement); 17029 else 17030 break; 17031 } 17032 }, 17033 CreateAdaptiveElementsArray: function(contentElement) { 17034 var result = []; 17035 var elements = ASPx.GetChildElementNodes(contentElement); 17036 for(var i = 0; i < elements.length; i++) { 17037 if(this.CheckElementIsAdaptive(elements[i])) 17038 result.push(elements[i]); 17039 } 17040 return result; 17041 }, 17042 SetItemItemPopOutImageHorizontal: function(element) { 17043 var popOutElements = ASPx.GetNodesByPartialClassName(element, "dxWeb_mVerticalPopOut"); 17044 for(var i = 0; i < popOutElements.length; i++) 17045 popOutElements[i].className = popOutElements[i].className.replace("Vertical", "Horizontal"); 17046 }, 17047 CheckElementIsAdaptive: function(element) { 17048 return !ASPx.ElementHasCssClass(element, this.menu.getAdaptiveMenuItemCssClass()) && !ASPx.ElementHasCssClass(element, this.menu.getAdaptiveMenuItemSpacingCssClass()); 17049 }, 17050 CheckAdaptiveItemsWidth: function(contentElement, menuWidth, additionalWidth) { 17051 var itemsWidth = 0; 17052 var elements = ASPx.GetChildElementNodes(contentElement); 17053 for(var i = 0; i < elements.length; i++) { 17054 var element = elements[i]; 17055 if(this.CheckElementIsAdaptive(element) && element.offsetWidth > 0) 17056 itemsWidth += this.GetAdaptiveElementWidth(element); 17057 if(itemsWidth > menuWidth + additionalWidth) 17058 return false; 17059 } 17060 return true; 17061 }, 17062 GetAdaptiveElementWidth: function(element) { 17063 return element.style.minWidth !== "" ? parseInt(element.style.minWidth) + ASPx.GetHorizontalBordersWidth(element) : element.offsetWidth; 17064 }, 17065 HideAdaptiveItems: function(menuWidth, additionalWidth, contentElement, adaptiveMenuContentElement) { 17066 if(this.CheckAdaptiveItemsWidth(contentElement, menuWidth, additionalWidth)) 17067 return false; 17068 this.elementsToHide = []; 17069 var elementsToHide = this.elementsToHide; 17070 var adaptiveItemSpacingCssClass = this.menu.getAdaptiveMenuItemSpacingCssClass(); 17071 var addToHide = function(index, indexPath, itemElement, separatorElement, indentElement, insteadSeparatorElement) { 17072 if(!itemElement) return; 17073 if(separatorElement && ASPx.ElementHasCssClass(separatorElement, adaptiveItemSpacingCssClass)) 17074 separatorElement = null; 17075 if(indentElement && ASPx.ElementHasCssClass(indentElement, adaptiveItemSpacingCssClass)) 17076 indentElement = null; 17077 elementsToHide[index] = { indexPath: indexPath, itemElement: itemElement, separatorElement: separatorElement, indentElement: indentElement, insteadSeparatorElement: insteadSeparatorElement }; 17078 ASPx.Attr.ChangeStyleAttribute(itemElement, "display", "none"); 17079 if(separatorElement) { 17080 var elementForHide = insteadSeparatorElement || separatorElement; 17081 ASPx.Attr.ChangeStyleAttribute(elementForHide, "display", "none"); 17082 } 17083 if(indentElement) 17084 ASPx.Attr.ChangeStyleAttribute(indentElement, "display", "none"); 17085 }; 17086 for(var i = 0; i < this.menu.adaptiveItemsOrder.length; i++){ 17087 var indexPath = this.menu.adaptiveItemsOrder[i], 17088 index = parseInt(indexPath, 10), 17089 itemToKeepSeparator = this.menu.GetRootItem() ? this.GetItemForKeepSeparator(index) : null, 17090 insteadSeparatorElement = itemToKeepSeparator ? this.menu.GetItemIndentElement(itemToKeepSeparator.indexPath) : null; 17091 addToHide(index, indexPath, this.menu.GetItemElement(indexPath), this.menu.GetItemSeparatorElement(indexPath), this.menu.GetItemIndentElement(indexPath), insteadSeparatorElement); 17092 var actualAdditionalWidth = this.NeedShowAdaptiveItemForHiddenElements(elementsToHide) ? 0 : additionalWidth; 17093 if(this.CheckAdaptiveItemsWidth(contentElement, menuWidth, actualAdditionalWidth)) 17094 break; 17095 } 17096 var hasImages = false; 17097 for(var i = 0; i < elementsToHide.length; i++) { 17098 if(!elementsToHide[i]) continue; 17099 ASPx.Attr.RestoreStyleAttribute(elementsToHide[i].itemElement, "display"); 17100 if(elementsToHide[i].separatorElement) { 17101 var elementForRestore = elementsToHide[i].insteadSeparatorElement || elementsToHide[i].separatorElement;
17102 ASPx.Attr.RestoreStyleAttribute(elementForRestore, "display"); 17103 } 17104 if(elementsToHide[i].indentElement) 17105 ASPx.Attr.RestoreStyleAttribute(elementsToHide[i].indentElement, "display"); 17106 this.menu.UpdateItemCssClasses(elementsToHide[i].indexPath, false); 17107 if(elementsToHide[i].separatorElement) { 17108 if(this.menu.GetRootItem()) 17109 this.KeepSeparatorInRoot(i); 17110 adaptiveMenuContentElement.appendChild(elementsToHide[i].separatorElement); 17111 } 17112 else if(this.menu.GetRootItem()) 17113 this.InsertSeparatorInAdaptiveMenu(i, elementsToHide[i].indexPath); 17114 if(elementsToHide[i].indentElement) 17115 adaptiveMenuContentElement.appendChild(elementsToHide[i].indentElement); 17116 adaptiveMenuContentElement.appendChild(elementsToHide[i].itemElement); 17117 this.PrepareHiddenAdaptiveItemElement(elementsToHide[i].itemElement); 17118 if(ASPx.GetNodeByClassName(elementsToHide[i].itemElement, "dxm-image")) 17119 hasImages = true; 17120 } 17121 for(var i = 0; i < elementsToHide.length; i++) { 17122 if(!elementsToHide[i]) continue; 17123 if(elementsToHide[i].separatorElement) 17124 ASPx.AddClassNameToElement(elementsToHide[i].separatorElement, MenuCssClasses.AdaptiveMenuHiddenElement); 17125 if(elementsToHide[i].indentElement) 17126 ASPx.AddClassNameToElement(elementsToHide[i].indentElement, MenuCssClasses.AdaptiveMenuHiddenElement); 17127 break; 17128 } 17129 this.SetLastSeparatorsVisible(false, contentElement); 17130 this.PrepareAdaptiveMenuContentElement(adaptiveMenuContentElement, hasImages); 17131 return elementsToHide.length > 0; 17132 }, 17133 PrepareHiddenAdaptiveItemElement: function(itemElement) { 17134 ASPx.Attr.ChangeStyleAttribute(itemElement, "width", "auto"); 17135 this.SetItemPopOutImageVertical(itemElement); 17136 }, 17137 PrepareAdaptiveMenuContentElement: function(contentElement, hasImages) { 17138 if(hasImages) 17139 ASPx.RemoveClassNameFromElement(contentElement, MenuCssClasses.WithoutImages); 17140 else 17141 ASPx.AddClassNameToElement(contentElement, MenuCssClasses.WithoutImages); 17142 }, 17143 SetAdaptiveItemElementVisibility: function(adaptiveItemElement, adaptiveItemSpacing, visible) { 17144 ASPx.SetElementDisplay(adaptiveItemElement, visible); 17145 if(adaptiveItemSpacing) 17146 ASPx.SetElementDisplay(adaptiveItemSpacing, visible); 17147 }, 17148 NeedShowAdaptiveItemForHiddenElements: function(elementsToHide) { 17149 return true; 17150 }, 17151 KeepSeparatorInRoot: function(index) { 17152 var nextItemInGroup = this.GetItemForKeepSeparator(index); 17153 if(nextItemInGroup) { 17154 var separatorElement = this.elementsToHide[index].separatorElement; 17155 this.ReplaceIndentElement(nextItemInGroup.indexPath, separatorElement); 17156 } 17157 }, 17158 InsertSeparatorInAdaptiveMenu: function(index, indexPath) { 17159 var itemWithSeparator = this.GetItemWithSeparatorForAdaptiveMenu(index); 17160 if(itemWithSeparator) { 17161 var separatorElement = this.menu.GetItemSeparatorElement(itemWithSeparator.indexPath); 17162 if(!separatorElement) return; 17163 this.elementsToHide[index].indentElement = this.ReplaceIndentElement(indexPath, separatorElement); 17164 } 17165 }, 17166 ReplaceIndentElement: function(indexPath, separatorElement) { 17167 var itemElement = this.menu.GetItemElement(indexPath), 17168 itemIndent = this.menu.GetItemIndentElement(indexPath), 17169 newIndentElement = separatorElement.cloneNode(true), 17170 parentNode = itemElement.parentNode; 17171 newIndentElement.id = this.menu.GetItemIndentElementId(indexPath); 17172 if(itemIndent) 17173 itemIndent.parentNode.removeChild(itemIndent); 17174 parentNode.insertBefore(newIndentElement, itemElement); 17175 return newIndentElement; 17176 }, 17177 GetItemForKeepSeparator: function(index) { 17178 var rootItem = this.menu.GetRootItem(), 17179 nextItemInGroup = this.menu.GetNextVisibleItemInGroup(rootItem, index, true); 17180 if(nextItemInGroup && this.IsItemInAdaptiveMenu(nextItemInGroup.index)) { 17181 while(nextItemInGroup && this.IsItemInAdaptiveMenu(nextItemInGroup.index)) 17182 nextItemInGroup = this.menu.GetNextVisibleItemInGroup(rootItem, nextItemInGroup.index, true); 17183 } 17184 return nextItemInGroup; 17185 }, 17186 GetItemWithSeparatorForAdaptiveMenu: function(index) { 17187 var rootItem = this.menu.GetRootItem(), 17188 prevItemInGroup = this.menu.GetPrevVisibleItemInGroup(rootItem, index); 17189 if(prevItemInGroup && !this.IsItemInAdaptiveMenu(prevItemInGroup.index) && !this.menu.IsItemBeginsGroup(prevItemInGroup)) { 17190 while(prevItemInGroup && !this.IsItemInAdaptiveMenu(prevItemInGroup.index) && !this.menu.IsItemBeginsGroup(prevItemInGroup)) 17191 prevItemInGroup = this.menu.GetPrevVisibleItemInGroup(rootItem, prevItemInGroup.index); 17192 } 17193 return prevItemInGroup && !this.IsItemInAdaptiveMenu(prevItemInGroup.index) ? prevItemInGroup : null; 17194 }, 17195 IsItemInAdaptiveMenu: function(index) { 17196 return this.elementsToHide.length >= index ? !!this.elementsToHide[index] : false; 17197 }, 17198 SetItemPopOutImageVertical: function(element) { 17199 var popOutElements = ASPx.GetNodesByPartialClassName(element, "dxWeb_mHorizontalPopOut"); 17200 for(var i = 0; i < popOutElements.length; i++) 17201 popOutElements[i].className = popOutElements[i].className.replace("Horizontal", "Vertical"); 17202 }, 17203 ChangeItemsPopOutImages: function(menuElement, isVertical) { 17204 var itemElements = this.GetItemElements(menuElement); 17205 for(var i = 0; i < itemElements.length; i++){ 17206 if(isVertical) 17207 this.SetItemPopOutImageVertical(itemElements[i]); 17208 else 17209 this.SetItemItemPopOutImageHorizontal(itemElements[i]); 17210 } 17211 }, 17212 ChangeOrientaion: function(menuElement, isVertical) {
17213 var oldCssSelector = isVertical ? MenuCssClasses.HorizontalMenu : MenuCssClasses.VerticalMenu; 17214 var newCssSelector = isVertical ? MenuCssClasses.VerticalMenu : MenuCssClasses.HorizontalMenu; 17215 menuElement.className = menuElement.className.replace(oldCssSelector, newCssSelector); 17216 this.ChangeItemsPopOutImages(menuElement, isVertical); 17217 this.CalculateMenuControl(menuElement, true); 17218 this.ChangeItemsPopOutImages(menuElement, isVertical); 17219 } 17220}); 17221var MenuScrollingManager = ASPx.CreateClass(ASPx.ScrollingManager, { 17222 constructor: function(menuScrollHelper) { 17223 this.constructor.prototype.constructor.call(this, menuScrollHelper, { 17224 scrollableArea: menuScrollHelper.scrollingAreaElement, 17225 orientation: [0, 1], 17226 onBeforeScrolling: function(manager, direction) { 17227 manager.owner.OnBeforeScrolling(direction); 17228 }, 17229 onAfterScrolling: function(manager, direction) { 17230 manager.owner.OnAfterScrolling(direction); 17231 }, 17232 forseEmulation: false, 17233 useMarginForPosition: true, 17234 handleMouseWheel: menuScrollHelper.handleMouseWheel 17235 }); 17236 }, 17237 setParentNodeOverflow: function() { 17238 if(ASPx.Browser.MSTouchUI) { 17239 this.scrollableArea.parentNode.style.overflow = "auto"; 17240 this.scrollableArea.parentNode.style["-ms-overflow-style"] = "none"; 17241 } 17242 } 17243}); 17244var MenuScrollHelper = ASPx.CreateClass(null, { 17245 constructor: function(menu, indexPath) { 17246 this.menu = menu; 17247 this.indexPath = indexPath; 17248 this.scrollingAreaElement = null; 17249 this.manager = null; 17250 this.initialized = false; 17251 this.visibleItems = []; 17252 this.itemsHeight = 0; 17253 this.scrollHeight = 0; 17254 this.scrollUpButtonHeight = 0; 17255 this.scrollDownButtonHeight = 0; 17256 this.scrollAreaHeight = null; 17257 this.scrollUpButtonVisible = false; 17258 this.scrollDownButtonVisible = false; 17259 this.handleMouseWheel = true; 17260 }, 17261 Initialize: function() { 17262 if(this.initialized && !this.menu.NeedCreateItemsOnClientSide()) return; 17263 this.scrollingAreaElement = this.menu.GetScrollContentItemsContainer(this.indexPath); 17264 this.manager = new MenuScrollingManager(this); 17265 this.ShowScrollButtons(); 17266 var scrollUpButton = this.menu.GetScrollUpButtonElement(this.indexPath); 17267 if(scrollUpButton) { 17268 this.scrollUpButtonHeight = this.GetScrollButtonHeight(scrollUpButton); 17269 ASPx.Selection.SetElementSelectionEnabled(scrollUpButton, false); 17270 } 17271 var scrollDownButton = this.menu.GetScrollDownButtonElement(this.indexPath); 17272 if(scrollDownButton) { 17273 this.scrollDownButtonHeight = this.GetScrollButtonHeight(scrollDownButton); 17274 ASPx.Selection.SetElementSelectionEnabled(scrollDownButton, false); 17275 } 17276 if(ASPx.Browser.WebKitTouchUI) { 17277 var preventDefault = function(event) { event.preventDefault(); }; 17278 ASPx.Evt.AttachEventToElement(scrollUpButton, "touchstart", preventDefault); 17279 ASPx.Evt.AttachEventToElement(scrollDownButton, "touchstart", preventDefault); 17280 } 17281 this.HideScrollButtons(); 17282 this.initialized = true; 17283 }, 17284 GetScrollButtonHeight: function(button) { 17285 var style = ASPx.GetCurrentStyle(button); 17286 return button.offsetHeight + ASPx.PxToInt(style.marginTop) + ASPx.PxToInt(style.marginBottom); 17287 }, 17288 FillVisibleItemsList: function() { 17289 var index = 0; 17290 this.visibleItems = []; 17291 while(true) { 17292 var childIndexPath = (this.indexPath != "" ? this.indexPath + ASPx.ItemIndexSeparator : "") + index; 17293 var itemElement = this.menu.GetItemElement(childIndexPath); 17294 if(itemElement == null) 17295 break; 17296 if(ASPx.GetElementDisplay(itemElement)) 17297 this.visibleItems.push(itemElement); 17298 index++; 17299 } 17300 }, 17301 CanCalculate: function() { 17302 return this.scrollingAreaElement && ASPx.IsElementDisplayed(this.scrollingAreaElement); 17303 }, 17304 Calculate: function(scrollHeight) { 17305 if(!this.CanCalculate()) return; 17306 this.FillVisibleItemsList(); 17307 this.itemsHeight = 0; 17308 this.scrollHeight = scrollHeight; 17309 var itemsContainer = this.menu.GetScrollContentItemsContainer(this.indexPath); 17310 if(itemsContainer) this.itemsHeight = itemsContainer.offsetHeight; 17311 this.SetPosition(0); 17312 this.CalculateScrollingElements(-1); 17313 }, 17314 GetPosition: function() { 17315 return -this.manager.GetScrolledAreaPosition(); 17316 }, 17317 SetPosition: function(pos) { 17318 this.manager.SetScrolledAreaPosition(-pos); 17319 }, 17320 CalculateScrollingElements: function(direction) { 17321 if(this.itemsHeight <= this.scrollHeight) { 17322 this.scrollUpButtonVisible = false; 17323 this.scrollDownButtonVisible = false; 17324 this.scrollAreaHeight = null; 17325 this.SetPosition(0); 17326 } 17327 else { 17328 var scrollTop = this.GetPosition(); 17329 this.scrollAreaHeight = this.scrollHeight; 17330 if(direction > 0) { 17331 var showScrollUpButton = !this.scrollUpButtonVisible; 17332 this.scrollUpButtonVisible = true; 17333 this.scrollAreaHeight -= this.scrollUpButtonHeight; 17334 this.scrollDownButtonVisible = this.itemsHeight - this.scrollAreaHeight - scrollTop > this.scrollDownButtonHeight; 17335 if(this.scrollDownButtonVisible) { 17336 this.scrollAreaHeight -= this.scrollDownButtonHeight; 17337 if(showScrollUpButton) 17338 this.SetPosition(this.GetPosition() + this.scrollUpButtonHeight); 17339 } 17340 else { 17341 this.SetPosition(this.itemsHeight - this.scrollAreaHeight); 17342 } 17343 } 17344 else { 17345 this.scrollDownButtonVisible = true; 17346 this.scrollAreaHeight -= this.scrollDownButtonHeight; 17347 this.scrollUpButtonVisible = scrollTop > this.scrollUpButtonHeight; 17348 if(this.scrollUpButtonVisible) 17349 this.scrollAreaHeight -= this.scrollUpButtonHeight; 17350 else 17351 this.SetPosition(0); 17352 } 17353 if(this.scrollAreaHeight < 1) this.scrollAreaHeight = 1; 17354 } 17355 this.UpdateScrollingElements(); 17356 }, 17357 UpdateScrollingElements: function() { 17358 this.UpdateScrollAreaHeight(); 17359 this.UpdateScrollButtonsVisibility(); 17360 }, 17361 UpdateScrollAreaHeight: function() { 17362 var scrollAreaElement = this.menu.GetScrollAreaElement(this.indexPath); 17363 if(scrollAreaElement) 17364 scrollAreaElement.style.height = (this.scrollAreaHeight) ? (this.scrollAreaHeight + "px") : ""; 17365 }, 17366 UpdateScrollButtonsVisibility: function() { 17367 var scrollUpButton = this.menu.GetScrollUpButtonElement(this.indexPath); 17368 if(scrollUpButton) ASPx.SetElementDisplay(scrollUpButton, this.scrollUpButtonVisible); 17369 var scrollDownButton = this.menu.GetScrollDownButtonElement(this.indexPath); 17370 if(scrollDownButton) ASPx.SetElementDisplay(scrollDownButton, this.scrollDownButtonVisible); 17371 }, 17372 ChangeScrollButtonsVisibility: function(visible) { 17373 this.scrollUpButtonVisible = visible; 17374 this.scrollDownButtonVisible = visible; 17375 this.UpdateScrollButtonsVisibility(); 17376 }, 17377 ShowScrollButtons: function() { 17378 this.ChangeScrollButtonsVisibility(true); 17379 }, 17380 HideScrollButtons: function() { 17381 this.ChangeScrollButtonsVisibility(false); 17382 }, 17383 ResetScrolling: function() { 17384 if(!this.initialized) 17385 return; 17386 this.HideScrollButtons(); 17387 this.SetPosition(0); 17388 this.scrollAreaHeight = null; 17389 this.UpdateScrollAreaHeight(); 17390 }, 17391 GetScrollAreaHeight: function() { 17392 var scrollAreaElement = this.menu.GetScrollAreaElement(this.indexPath); 17393 if(scrollAreaElement) 17394 return scrollAreaElement.offsetHeight; 17395 return 0; 17396 }, 17397 OnAfterScrolling: function(direction) { 17398 this.CalculateScrollingElements(direction); 17399 }, 17400 OnBeforeScrolling: function(direction) { 17401 var scrollButton = (direction > 0) ? this.menu.GetScrollDownButtonElement(this.indexPath) : 17402 this.menu.GetScrollUpButtonElement(this.indexPath);
17403 if(!scrollButton || !ASPx.GetElementDisplay(scrollButton)) 17404 this.manager.StopScrolling(); 17405 }, 17406 StartScrolling: function(direction, delay, step) { 17407 this.manager.StartScrolling(direction, delay, step); 17408 }, 17409 StopScrolling: function() { 17410 this.manager.StopScrolling(); 17411 } 17412}); 17413MenuScrollHelper.GetMenuByScrollButtonId = function(id) { 17414 var menuName = aspxGetMenuCollection().GetMenuNameBySuffixes(id, [Constants.SBIdSuffix]); 17415 return aspxGetMenuCollection().Get(menuName); 17416}; 17417var ASPxClientMenuBase = ASPx.CreateClass(ASPxClientControl, { 17418 constructor: function(name) { 17419 this.constructor.prototype.constructor.call(this, name); 17420 this.renderData = null; 17421 this.renderHelper = this.CreateRenderHelper(); 17422 this.sampleItemsFlags = { 17423 TextOnly: 0, 17424 SubItems: 1, 17425 Image: 2, 17426 NavigateUrl: 4, 17427 DropDownMode: 8, 17428 CheckBox: 16, 17429 ImageClassName: 32, 17430 Svg: 64 17431 }; 17432 this.rootMenuSample = null; 17433 this.dropElementsCache = false; 17434 this.allowSelectItem = false; 17435 this.allowCheckItems = false; 17436 this.allowMultipleCallbacks = false; 17437 this.appearAfter = 300; 17438 this.slideAnimationDuration = 60; 17439 this.disappearAfter = 500; 17440 this.enableAnimation = true; 17441 this.enableAdaptivity = false; 17442 this.adaptiveItemsOrder = []; 17443 this.enableSubMenuFullWidth = false; 17444 this.checkedItems = []; 17445 this.isVertical = true; 17446 this.itemCheckedGroups = []; 17447 this.itemCheckedGroups.groupNames = {}; 17448 this.lockHoverEvents = false; 17449 this.popupToLeft = false; 17450 this.popupCount = 0; 17451 this.rootItem = null; 17452 this.showSubMenus = false; 17453 this.savedCallbackHoverItem = null; 17454 this.savedCallbackHoverElement = null; 17455 this.selectedItemIndexPath = ""; 17456 this.checkedState = null; 17457 this.scrollInfo = []; 17458 this.scrollHelpers = {}; 17459 this.scrollVertOffset = 1; 17460 this.keyboardHelper = null; 17461 this.isContextMenu = false; 17462 this.accessibleFocusElement = null; 17463 this.rootSubMenuFIXOffset = 0; 17464 this.rootSubMenuFIYOffset = 0; 17465 this.rootSubMenuLIXOffset = 0; 17466 this.rootSubMenuLIYOffset = 0; 17467 this.rootSubMenuXOffset = 0; 17468 this.rootSubMenuYOffset = 0; 17469 this.subMenuFIXOffset = 0; 17470 this.subMenuFIYOffset = 0; 17471 this.subMenuLIXOffset = 0; 17472 this.subMenuLIYOffset = 0; 17473 this.subMenuXOffset = 0; 17474 this.subMenuYOffset = 0; 17475 this.maxHorizontalOverlap = -3; 17476 this.sizingConfig.allowSetHeight = false; 17477 this.ItemClick = new ASPxClientEvent(); 17478 this.ItemMouseOver = new ASPxClientEvent(); 17479 this.ItemMouseOut = new ASPxClientEvent(); 17480 this.PopUp = new ASPxClientEvent(); 17481 this.CloseUp = new ASPxClientEvent(); 17482 aspxGetMenuCollection().Add(this); 17483 }, 17484 SetData: function(data) { 17485 if(data.items) 17486 this.CreateItems(data.items); 17487 }, 17488 InlineInitialize: function() { 17489 ASPxClientControl.prototype.InlineInitialize.call(this); 17490 if(!this.NeedCreateItemsOnClientSide()) 17491 this.renderHelper.InlineInitializeElements(); 17492 else 17493 this.renderHelper.InlineInitializeScrollElements("", this.GetMainElement()); 17494 this.InitializeInternal(true); 17495 if(this.IsCallbacksEnabled()) { 17496 this.showSubMenus = this.GetLoadingPanelElement() != null; 17497 this.CreateCallback("DXMENUCONTENT"); 17498 } 17499 else 17500 this.showSubMenus = true; 17501 this.popupToLeft = this.rtl; 17502 }, 17503 InitializeInternal: function(inline) { 17504 if(!this.NeedCreateItemsOnClientSide()) { 17505 this.InitializeCheckedItems(); 17506 this.InitializeSelectedItem(); 17507 } 17508 this.InitializeEnabledAndVisible(!inline || !this.IsCallbacksEnabled()); 17509 if(!this.IsCallbacksEnabled()) 17510 this.InitializeScrollableMenus(); 17511 this.InitializeKeyboardHelper(); 17512 }, 17513 InitializeEnabledAndVisible: function(recursive) { 17514 if(this.rootItem == null) return; 17515 for(var i = 0; i < this.rootItem.items.length; i++) 17516 this.rootItem.items[i].InitializeEnabledAndVisible(recursive); 17517 }, 17518 InitializeScrollableMenus: function() { 17519 var info = eval(this.scrollInfo); 17520 this.scrollHelpers = {}; 17521 for(var i = 0; i < info.length; i++) 17522 this.InitializeScrollableMenu(info[i]); 17523 }, 17524 InitializeScrollableMenu: function(indexPath) { 17525 if(!this.scrollHelpers[indexPath]) 17526 this.scrollHelpers[indexPath] = new MenuScrollHelper(this, indexPath); 17527 }, 17528 GetScrollHelper: function(indexPath) { 17529 var scrollsEnabledOnServer = this.scrollInfo.length > 0;
17530 if(this.NeedCreateItemsOnClientSide() && scrollsEnabledOnServer) 17531 this.InitializeScrollableMenu(indexPath); 17532 return this.scrollHelpers[indexPath]; 17533 }, 17534 InitializeKeyboardHelper: function() { 17535 this.keyboardHelper = new ASPxMenuKeyboardHelper(this); 17536 }, 17537 InitializeMenuSamples: function() { 17538 this.rootMenuSample = this.GetSampleNode(this.samples.root); 17539 this.samples.spacing = this.GetSampleNode(this.samples.spacing); 17540 this.samples.separator = this.GetSampleNode(this.samples.separator); 17541 this.InitializeItemsSamples(this.samples.rootItems); 17542 if(this.samples.submenu) { 17543 this.samples.submenu = this.GetSampleNode(this.samples.submenu); 17544 this.InitializeItemsSamples(this.samples.submenuItems); 17545 } 17546 }, 17547 InitializeItemsSamples: function(itemsSamples) { 17548 for(var sampleProperty in itemsSamples) { 17549 if(itemsSamples.hasOwnProperty(sampleProperty)) { 17550 itemsSamples[sampleProperty] = itemsSamples[sampleProperty].replace(/DXFAKE/, ""); 17551 itemsSamples[sampleProperty] = this.GetSampleNode(itemsSamples[sampleProperty]); 17552 } 17553 } 17554 }, 17555 CheckElementsCache: function(menuElement){ 17556 if(this.dropElementsCache) { 17557 ASPx.CacheHelper.DropCache(menuElement); 17558 this.dropElementsCache = false; 17559 } 17560 }, 17561 NeedCreateItemsOnClientSide: function() { 17562 return false; 17563 }, 17564 IsClientSideEventsAssigned: function() { 17565 return !this.ItemClick.IsEmpty() 17566 || !this.ItemMouseOver.IsEmpty() 17567 || !this.ItemMouseOut.IsEmpty() 17568 || !this.PopUp.IsEmpty() 17569 || !this.CloseUp.IsEmpty() 17570 || !this.Init.IsEmpty(); 17571 }, 17572 IsCallbacksEnabled: function() { 17573 return ASPx.IsFunction(this.callBack); 17574 }, 17575 ShouldHideExistingLoadingElements: function() { 17576 return false; 17577 }, 17578 CreateRenderHelper: function(){ 17579 return new MenuRenderHelper(this); 17580 }, 17581 IsSidePanelExpanded: function() { 17582 return false; 17583 }, 17584 GetMenuElementId: function(indexPath) { 17585 return this.name + Constants.MMIdSuffix + indexPath + "_"; 17586 }, 17587 GetMenuMainElementId: function(indexPath) { 17588 return this.name + "_DXME" + indexPath + "_"; 17589 }, 17590 GetMenuBorderCorrectorElementId: function(indexPath) { 17591 return this.name + "_DXMBC" + indexPath + "_"; 17592 }, 17593 GetMenuIFrameElementId: function(indexPath) { 17594 return this.name + "_DXMIF" + this.GetMenuLevel(indexPath); 17595 }, 17596 GetScrollAreaId: function(indexPath) { 17597 return this.name + "_DXSA" + indexPath; 17598 }, 17599 GetMenuTemplateContainerID: function(indexPath) { 17600 return this.name + "_MTCNT" + indexPath; 17601 }, 17602 GetItemTemplateContainerID: function(indexPath) { 17603 return this.name + "_ITCNT" + indexPath; 17604 }, 17605 GetScrollUpButtonId: function(indexPath) { 17606 return this.name + Constants.SBIdSuffix + indexPath + Constants.SBUIdEnd; 17607 }, 17608 GetScrollDownButtonId: function(indexPath) { 17609 return this.name + Constants.SBIdSuffix + indexPath + Constants.SBDIdEnd; 17610 }, 17611 GetItemElementId: function(indexPath) { 17612 return this.name + Constants.MIIdSuffix + indexPath + "_"; 17613 }, 17614 GetItemContentElementId: function(indexPath) { 17615 return this.GetItemElementId(indexPath) + "T"; 17616 }, 17617 GetItemPopOutElementId: function(indexPath) { 17618 return this.GetItemElementId(indexPath) + "P"; 17619 }, 17620 GetItemImageId: function(indexPath) { 17621 return this.GetItemElementId(indexPath) + Constants.ImagePostfix; 17622 }, 17623 GetItemPopOutImageId: function(indexPath) { 17624 return this.GetItemElementId(indexPath) + Constants.PopupImagePostfix; 17625 }, 17626 GetItemIndentElementId: function(indexPath) { 17627 return this.GetItemElementId(indexPath) + "II"; 17628 }, 17629 GetItemSeparatorElementId: function(indexPath) { 17630 return this.GetItemElementId(indexPath) + "IS"; 17631 }, 17632 GetMenuElement: function (indexPath) { 17633 if(indexPath == "") 17634 return this.GetMainElement(); 17635 return ASPx.CacheHelper.GetCachedElementById(this, this.GetMenuElementId(indexPath)); 17636 }, 17637 GetMenuIFrameElement: function(indexPath) { 17638 var elementId = this.GetMenuIFrameElementId(indexPath); 17639 var element = ASPx.GetElementById(elementId); 17640 if(!element && this.renderIFrameForPopupElements) 17641 return this.CreateIFrameElement(elementId); 17642 return element; 17643 }, 17644 CreateIFrameElement: function(elementId) {
17645 var element = document.createElement("IFRAME"); 17646 ASPx.Attr.SetAttribute(element, "id", elementId); 17647 ASPx.Attr.SetAttribute(element, "src", "javascript:false"); 17648 ASPx.Attr.SetAttribute(element, "scrolling", "no"); 17649 ASPx.Attr.SetAttribute(element, "frameborder", "0"); 17650 if(this.accessibilityCompliant) 17651 ASPx.Attr.SetAttribute(element, "title", ASPx.AccessibilitySR.AccessibilityIFrameTitle); 17652 element.style.position = "absolute"; 17653 element.style.display = "none"; 17654 element.style.zIndex = "19997"; 17655 element.style.filter = "progid:DXImageTransform.Microsoft.Alpha(Style=0, Opacity=0)"; 17656 ASPx.InsertElementAfter(element, this.GetMainElement()); 17657 return element; 17658 }, 17659 GetMenuBorderCorrectorElement: function(indexPath) { 17660 return ASPx.CacheHelper.GetCachedElementById(this, this.GetMenuBorderCorrectorElementId(indexPath)); 17661 }, 17662 GetMenuMainElement: function(element) { 17663 var indexPath = this.GetIndexPathById(element.id, true); 17664 return ASPx.CacheHelper.GetCachedElement(this, "menuMainElement" + indexPath, 17665 function() { 17666 var shadowTable = ASPx.GetElementById(this.GetMenuMainElementId(indexPath)); 17667 return shadowTable != null ? shadowTable : element; 17668 }); 17669 }, 17670 GetScrollAreaElement: function(indexPath) { 17671 return ASPx.CacheHelper.GetCachedElementById(this, this.GetScrollAreaId(indexPath)); 17672 }, 17673 GetScrollContentItemsContainer: function(indexPath) { 17674 return ASPx.CacheHelper.GetCachedElement(this, "scrollContentItemsContainer" + indexPath, 17675 function() { 17676 return ASPx.GetNodeByTagName(this.GetScrollAreaElement(indexPath), "UL", 0); 17677 }); 17678 }, 17679 GetScrollUpButtonElement: function(indexPath) { 17680 return ASPx.CacheHelper.GetCachedElementById(this, this.GetScrollUpButtonId(indexPath)); 17681 }, 17682 GetScrollDownButtonElement: function(indexPath) { 17683 return ASPx.CacheHelper.GetCachedElementById(this, this.GetScrollDownButtonId(indexPath)); 17684 }, 17685 GetItemElement: function(indexPath) { 17686 return ASPx.CacheHelper.GetCachedElementById(this, this.GetItemElementId(indexPath)); 17687 }, 17688 GetItemTemplateElement: function(indexPath) { 17689 return this.GetItemTextTemplateContainer(indexPath); 17690 }, 17691 GetItemTemplateContainer: function(indexPath) { 17692 return this.GetItemElement(indexPath); 17693 }, 17694 GetItemTextTemplateContainer: function(indexPath) { 17695 return this.GetItemContentElement(indexPath); 17696 }, 17697 GetItemContentElement: function(indexPath) { 17698 return ASPx.CacheHelper.GetCachedElementById(this, this.GetItemContentElementId(indexPath)); 17699 }, 17700 GetItemPopOutElement: function(indexPath) { 17701 return ASPx.CacheHelper.GetCachedElementById(this, this.GetItemPopOutElementId(indexPath)); 17702 }, 17703 GetPopOutElements: function() { 17704 return ASPx.GetNodesByClassName(this.GetMainElement().parentNode, "dxm-popOut"); 17705 }, 17706 GetPopOutImages: function() { 17707 return ASPx.GetNodesByClassName(this.GetMainElement().parentNode, "dxm-pImage"); 17708 }, 17709 GetSubMenuXPosition: function(indexPath, isVertical) { 17710 var itemElement = this.GetItemElement(indexPath); 17711 var pos = ASPx.GetAbsoluteX(itemElement) + (isVertical ? itemElement.clientWidth + itemElement.clientLeft : 0); 17712 if(ASPx.Browser.WebKitFamily && !this.IsParentElementPositionStatic(indexPath)) 17713 pos -= document.body.offsetLeft; 17714 return pos; 17715 }, 17716 GetSubMenuYPosition: function(indexPath, isVertical) { 17717 var position = 0; 17718 var element = this.GetItemElement(indexPath); 17719 if(element != null) { 17720 if(isVertical) { 17721 position = ASPx.GetAbsoluteY(element); 17722 } 17723 else { 17724 if(ASPx.Browser.Opera && ASPx.Browser.Version >= 9 || ASPx.Browser.AndroidDefaultBrowser) 17725 position = ASPx.GetAbsoluteY(element) + element.offsetHeight - ASPx.GetClientTop(element); 17726 else 17727 position = ASPx.GetAbsoluteY(element) + element.clientHeight + ASPx.GetClientTop(element); 17728 } 17729 } 17730 if(ASPx.Browser.WebKitFamily && !this.IsParentElementPositionStatic(indexPath)) 17731 position -= document.body.offsetTop; 17732 return position; 17733 }, 17734 GetClientSubMenuXPosition: function(element, x, indexPath, isVertical) { 17735 var docClientWidth = ASPx.GetDocumentClientWidth(); 17736 if(isVertical) 17737 return this.GetClientSubMenuXPositionVerticalCore(element, x, indexPath, isVertical, docClientWidth);
17738 return this.GetClientSubMenuXPositionHorizontalCore(element, x, indexPath, isVertical, docClientWidth); 17739 }, 17740 GetClientSubMenuXPositionVerticalCore: function(element, x, indexPath, isVertical, docClientWidth) { 17741 var itemInfo = new MenuItemInfo(this, indexPath); 17742 var itemWidth = itemInfo.clientWidth; 17743 var subMenuWidth = this.GetMenuMainElement(element).offsetWidth; 17744 var left = x - ASPx.GetDocumentScrollLeft(); 17745 var right = left + subMenuWidth; 17746 var toLeftX = x - subMenuWidth - itemWidth; 17747 var toLeftLeft = left - subMenuWidth - itemWidth; 17748 if(this.IsCorrectionDisableMethodRequired(indexPath)) 17749 return this.GetCorrectionDisabledResult(x, toLeftX); 17750 if(this.popupToLeft) { 17751 if(toLeftLeft > this.maxHorizontalOverlap) 17752 return toLeftX; 17753 if(docClientWidth - right > this.maxHorizontalOverlap || !this.rtl) { 17754 this.popupToLeft = false; 17755 return x; 17756 } 17757 return ASPx.InvalidPosition; 17758 } 17759 else { 17760 if(docClientWidth - right > this.maxHorizontalOverlap) 17761 return x; 17762 if(toLeftLeft > this.maxHorizontalOverlap || this.rtl) { 17763 this.popupToLeft = true; 17764 return toLeftX; 17765 } 17766 return ASPx.InvalidPosition; 17767 } 17768 }, 17769 GetClientSubMenuXPositionHorizontalCore: function(element, x, indexPath, isVertical, docClientWidth) { 17770 var itemInfo = new MenuItemInfo(this, indexPath); 17771 var itemOffsetWidth = itemInfo.offsetWidth; 17772 var subMenuWidth = this.GetMenuMainElement(element).offsetWidth; 17773 var left = x - ASPx.GetDocumentScrollLeft(); 17774 if(this.popupToLeft) { 17775 var rtlX = left - subMenuWidth + itemOffsetWidth; 17776 return rtlX < 0 ? 0 : rtlX; 17777 } 17778 else { 17779 if(docClientWidth - (left + subMenuWidth) < 0) { 17780 x = docClientWidth - subMenuWidth; 17781 if(x < 0) 17782 x = 0; 17783 return x; 17784 } 17785 return x; 17786 } 17787 }, 17788 GetClientSubMenuYPosition: function(element, y, indexPath, isVertical) { 17789 var itemInfo = new MenuItemInfo(this, indexPath); 17790 var itemHeight = itemInfo.offsetHeight; 17791 var subMenuHeight = this.GetMenuMainElement(element).offsetHeight; 17792 var menuItemTop = y - ASPx.GetDocumentScrollTop(); 17793 var subMenuBottom = menuItemTop + subMenuHeight; 17794 var docClientHeight = ASPx.GetDocumentClientHeight(); 17795 var clientSubMenuYPos = y; 17796 if(isVertical) { 17797 var notEnoughSpaceToShowDown = subMenuBottom > docClientHeight; 17798 var menuItemBottom = menuItemTop + itemHeight; 17799 if(menuItemBottom > docClientHeight) { 17800 menuItemBottom = docClientHeight; 17801 itemHeight = menuItemBottom - menuItemTop; 17802 } 17803 var notEnoughSpaceToShowUp = menuItemBottom < subMenuHeight; 17804 var subMenuIsFitToDisplayFrames = docClientHeight >= subMenuHeight; 17805 if(!subMenuIsFitToDisplayFrames) clientSubMenuYPos = y - menuItemTop; 17806 else if(notEnoughSpaceToShowDown) { 17807 if(notEnoughSpaceToShowUp) { 17808 var docClientBottom = ASPx.GetDocumentScrollTop() + docClientHeight; 17809 clientSubMenuYPos = docClientBottom - subMenuHeight; 17810 } else 17811 clientSubMenuYPos = y + itemHeight - subMenuHeight; 17812 } 17813 } 17814 else { 17815 if(this.IsHorizontalSubmenuNeedInversion(subMenuBottom, docClientHeight, menuItemTop, subMenuHeight, itemHeight)) 17816 clientSubMenuYPos = y - subMenuHeight - itemHeight; 17817 } 17818 return clientSubMenuYPos; 17819 }, 17820 IsHorizontalSubmenuNeedInversion: function(subMenuBottom, docClientHeight, menuItemTop, subMenuHeight, itemHeight) { 17821 return subMenuBottom > docClientHeight && menuItemTop - subMenuHeight - itemHeight > docClientHeight - subMenuBottom; 17822 }, 17823 IsCorrectionDisableMethodRequired: function(indexPath) { 17824 return false; 17825 }, 17826 HasChildren: function(indexPath) { 17827 return (this.GetMenuElement(indexPath) != null); 17828 }, 17829 IsVertical: function(indexPath) { 17830 return true; 17831 }, 17832 IsRootItem: function(indexPath) { 17833 return this.GetMenuLevel(indexPath) <= 1; 17834 }, 17835 IsParentElementPositionStatic: function(indexPath) { 17836 return this.IsRootItem(indexPath); 17837 }, 17838 GetItemIndexPath: function(indexes) { 17839 return aspxGetMenuCollection().GetItemIndexPath(indexes); 17840 }, 17841 GetItemIndexes: function(indexPath) { 17842 return aspxGetMenuCollection().GetItemIndexes(indexPath); 17843 }, 17844 GetItemIndexPathById: function(id) { 17845 return aspxGetMenuCollection().GetIndexPathById(id, Constants.MIIdSuffix); 17846 }, 17847 GetMenuIndexPathById: function(id) { 17848 return aspxGetMenuCollection().GetIndexPathById(id, Constants.MMIdSuffix); 17849 }, 17850 GetScrollButtonIndexPathById: function(id) { 17851 return aspxGetMenuCollection().GetIndexPathById(id, Constants.SBIdSuffix); 17852 }, 17853 GetIndexPathById: function(id, checkMenu) { 17854 var indexPath = this.GetItemIndexPathById(id); 17855 if(indexPath == "" && checkMenu) 17856 indexPath = this.GetMenuIndexPathById(id); 17857 return indexPath; 17858 }, 17859 GetMenuLevelInternal: function(indexPath) { 17860 if(indexPath == "") 17861 return 0; 17862 else { 17863 var indexes = this.GetItemIndexes(indexPath); 17864 return indexes.length; 17865 } 17866 }, 17867 GetMenuLevel: function(indexPath) { 17868 var level = this.GetMenuLevelInternal(indexPath); 17869 if(this.IsAdaptiveMenuItem(indexPath))
17870 level ++; 17871 return level; 17872 }, 17873 IsAdaptiveMenuItem: function(indexPath){ 17874 var level = this.GetMenuLevelInternal(indexPath); 17875 while(level > 1){ 17876 indexPath = this.GetParentIndexPath(indexPath); 17877 level = this.GetMenuLevelInternal(indexPath); 17878 } 17879 var itemElement = this.GetItemElement(indexPath); 17880 if(itemElement && ASPx.GetParentByClassName(itemElement, this.getAdaptiveMenuCssClass())) 17881 return true; 17882 return false; 17883 }, 17884 IsAdaptiveItem: function(indexPath){ 17885 var itemElement = this.GetItemElement(indexPath); 17886 if(itemElement && ASPx.ElementContainsCssClass(itemElement, this.getAdaptiveMenuItemCssClass())) 17887 return true; 17888 return false; 17889 }, 17890 GetParentIndexPath: function(indexPath) { 17891 var indexes = this.GetItemIndexes(indexPath); 17892 indexes.length--; 17893 return (indexes.length > 0) ? this.GetItemIndexPath(indexes) : ""; 17894 }, 17895 IsLastElement: function(element) { 17896 return element && (!element.nextSibling || !element.nextSibling.tagName); 17897 }, 17898 IsLastItem: function(indexPath) { 17899 var itemElement = this.GetItemElement(indexPath); 17900 return this.IsLastElement(itemElement); 17901 }, 17902 IsFirstElement: function(element) { 17903 return element && (!element.previousSibling || !element.previousSibling.tagName); 17904 }, 17905 IsFirstItem: function(indexPath) { 17906 var itemElement = this.GetItemElement(indexPath); 17907 return this.IsFirstElement(itemElement); 17908 }, 17909 IsItemElement: function(element) { 17910 return ASPx.ElementContainsCssClass(element, MenuCssClasses.Item); 17911 }, 17912 GetPreviousItem: function(itemPath, isItemNameUsed) { 17913 var indexPath = itemPath; 17914 if(isItemNameUsed) { 17915 var indexPath = this.GetMenuIndexPathById(itemPath); 17916 if(indexPath == "") 17917 indexPath = this.GetItemIndexPathById(itemPath); 17918 } 17919 var currentItem = this.GetItemByIndexPath(indexPath), 17920 previousItem = null; 17921 if(currentItem) { 17922 for(var i = currentItem.index - 1; i >= 0 && previousItem === null; i--) { 17923 if(currentItem.parent.items[i].GetVisible()) 17924 previousItem = currentItem.parent.items[i]; 17925 } 17926 } 17927 return previousItem; 17928 }, 17929 GetClientSubMenuPos: function(element, indexPath, pos, isVertical, isXPos) { 17930 if(!ASPx.IsValidPosition(pos)) { 17931 pos = isXPos ? this.GetSubMenuXPosition(indexPath, isVertical) : this.GetSubMenuYPosition(indexPath, isVertical); 17932 } 17933 var clientPos = isXPos ? this.GetClientSubMenuXPosition(element, pos, indexPath, isVertical) : this.GetClientSubMenuYPosition(element, pos, indexPath, isVertical); 17934 var isInverted = pos != clientPos; 17935 if(clientPos !== ASPx.InvalidPosition){ 17936 var offset = isXPos ? this.GetSubMenuXOffset(indexPath) : this.GetSubMenuYOffset(indexPath); 17937 clientPos += isInverted ? -offset : offset; 17938 clientPos -= ASPx.GetPositionElementOffset(this.GetMenuElement(indexPath), isXPos); 17939 } 17940 return new ASPx.PopupPosition(clientPos, isInverted); 17941 }, 17942 GetSubMenuXOffset: function(indexPath) { 17943 if(indexPath == "") 17944 return 0; 17945 else if(this.IsRootItem(indexPath)) { 17946 if(this.IsFirstItem(indexPath)) 17947 return this.rootSubMenuFIXOffset; 17948 else if(this.IsLastItem(indexPath)) 17949 return this.rootSubMenuLIXOffset; 17950 else 17951 return this.rootSubMenuXOffset; 17952 } 17953 else { 17954 if(this.IsFirstItem(indexPath)) 17955 return this.subMenuFIXOffset; 17956 else if(this.IsLastItem(indexPath)) 17957 return this.subMenuLIXOffset; 17958 else 17959 return this.subMenuXOffset; 17960 } 17961 }, 17962 GetSubMenuYOffset: function(indexPath) { 17963 if(indexPath == "") 17964 return 0; 17965 else if(this.IsRootItem(indexPath)) { 17966 if(this.IsFirstItem(indexPath)) 17967 return this.rootSubMenuFIYOffset; 17968 else if(this.IsLastItem(indexPath)) 17969 return this.rootSubMenuLIYOffset; 17970 else 17971 return this.rootSubMenuYOffset; 17972 } 17973 else { 17974 if(this.IsFirstItem(indexPath)) 17975 return this.subMenuFIYOffset; 17976 else if(this.IsLastItem(indexPath)) 17977 return this.subMenuLIYOffset; 17978 else 17979 return this.subMenuYOffset; 17980 } 17981 }, 17982 CalculateSubMenuPosition: function(element, x, y, indexPath, enableAnimation) { 17983 var isVertical = this.IsVertical(indexPath); 17984 var horizontalPopupPosition = this.GetClientSubMenuPos(element, indexPath, x, isVertical, true); 17985 if(horizontalPopupPosition.position === ASPx.InvalidPosition) { 17986 isVertical = !isVertical; 17987 horizontalPopupPosition = this.GetClientSubMenuPos(element, indexPath, x, isVertical, true); 17988 } 17989 var verticalPopupPosition = this.GetClientSubMenuPos(element, indexPath, y, isVertical, false); 17990 var clientX = horizontalPopupPosition.position; 17991 var clientY = verticalPopupPosition.position; 17992 var toTheLeft = horizontalPopupPosition.isInverted; 17993 var toTheTop = verticalPopupPosition.isInverted;
17994 clientY += this.GetScrollingCorrection(element, indexPath, clientY); 17995 verticalPopupPosition.position = clientY; 17996 var parentElement = this.GetItemContentElement(indexPath); 17997 var prevParentPos = ASPx.GetAbsoluteX(parentElement); 17998 ASPx.SetStyles(element, { 17999 left: clientX, top: clientY 18000 }); 18001 if(ASPx.Browser.IE && ASPx.IsElementRightToLeft(document.body)) { 18002 ASPx.SetElementDisplay(element, false); 18003 ASPx.SetElementDisplay(element, true); 18004 } 18005 clientX += ASPx.GetAbsoluteX(parentElement) - prevParentPos; 18006 if(enableAnimation) { 18007 this.StartAnimation(element, indexPath, horizontalPopupPosition, verticalPopupPosition, isVertical); 18008 } 18009 else { 18010 ASPx.SetStyles(element, { left: clientX, top: clientY }); 18011 ASPx.SetElementVisibility(element, true); 18012 if(this.enableSubMenuFullWidth) 18013 this.ApplySubMenuFullWidth(element); 18014 this.DoShowPopupMenuIFrame(element, clientX, clientY, ASPx.InvalidDimension, ASPx.InvalidDimension, indexPath); 18015 this.DoShowPopupMenuBorderCorrector(element, clientX, clientY, indexPath, toTheLeft, toTheTop); 18016 } 18017 }, 18018 StartScrolling: function(buttonId, delay, step) { 18019 var indexPath = this.GetScrollButtonIndexPathById(buttonId); 18020 var level = this.GetMenuLevel(indexPath); 18021 aspxGetMenuCollection().DoHidePopupMenus(null, level, this.name, false, ""); 18022 var direction = (buttonId.lastIndexOf(Constants.SBDIdEnd) == buttonId.length - Constants.SBDIdEnd.length) ? 1 : -1; 18023 var scrollHelper = this.GetScrollHelper(indexPath); 18024 if(scrollHelper) scrollHelper.StartScrolling(direction, delay, step); 18025 }, 18026 StopScrolling: function(buttonId) { 18027 var indexPath = this.GetScrollButtonIndexPathById(buttonId); 18028 var scrollHelper = this.GetScrollHelper(indexPath); 18029 if(scrollHelper) scrollHelper.StopScrolling(); 18030 }, 18031 ClearAppearTimer: function() { 18032 aspxGetMenuCollection().ClearAppearTimer(); 18033 }, 18034 ClearDisappearTimer: function() { 18035 aspxGetMenuCollection().ClearDisappearTimer(); 18036 }, 18037 IsAppearTimerActive: function() { 18038 return aspxGetMenuCollection().IsAppearTimerActive(); 18039 }, 18040 IsDisappearTimerActive: function() { 18041 return aspxGetMenuCollection().IsDisappearTimerActive(); 18042 }, 18043 IsAdaptiveItemAnimationActive: function() { 18044 return this.inSubmenuShowAnimation; 18045 }, 18046 GetAppearAfter: function(indexPath) { 18047 return this.appearAfter; 18048 }, 18049 SetAppearTimer: function(indexPath, preventSubMenu) { 18050 aspxGetMenuCollection().SetAppearTimer(this.name, indexPath, this.GetAppearAfter(indexPath), preventSubMenu); 18051 }, 18052 GetDisappearAfter: function() { 18053 return this.disappearAfter; 18054 }, 18055 SetDisappearTimer: function() { 18056 aspxGetMenuCollection().SetDisappearTimer(this.name, this.GetDisappearAfter()); 18057 }, 18058 IsDropDownItem: function(indexPath) { 18059 return ASPx.ElementContainsCssClass(this.GetItemElement(indexPath), MenuCssClasses.ItemDropDownMode); 18060 }, 18061 DoItemClick: function(indexPath, hasItemLink, htmlEvent) { 18062 aspxGetMenuCollection().LockMenusVisibility(); 18063 var processOnServer = this.RaiseItemClick(indexPath, htmlEvent); 18064 if(processOnServer && !hasItemLink) { 18065 if(ASPx.Browser.IE || ASPx.Browser.Edge) { 18066 var activeElement = document.activeElement; 18067 if(activeElement) 18068 activeElement.blur(); 18069 } 18070 this.SendPostBack("CLICK:" + indexPath); 18071 } 18072 else { 18073 this.ClearDisappearTimer(); 18074 this.ClearAppearTimer(); 18075 if(this.CanCloseSubMenuOnClick(indexPath) && (!this.HasChildren(indexPath) || this.IsDropDownItem(indexPath))) 18076 aspxGetMenuCollection().DoHidePopupMenus(null, -1, this.name, false, ""); 18077 else if(this.IsItemEnabled(indexPath) && !this.IsDropDownItem(indexPath)) 18078 this.ShowSubMenu(indexPath); 18079 } 18080 aspxGetMenuCollection().UnlockMenusVisibility(); 18081 }, 18082 CanCloseSubMenuOnClick: function(indexPath) { 18083 return true; 18084 }, 18085 HasContent: function(mainCell) { 18086 for(var i = 0; i < mainCell.childNodes.length; i++) 18087 if(mainCell.childNodes[i].tagName) 18088 return true; 18089 return false; 18090 }, 18091 DoShowPopupMenu: function(element, x, y, indexPath) { 18092 var parent = this.GetItemByIndexPath(indexPath); 18093 var menuElement = this.GetMenuMainElement(element); 18094 var popupMenuHasVisibleContent = menuElement && (this.renderHelper.HasSubMenuTemplate(menuElement) || 18095 ASPx.ElementContainsCssClass(menuElement, this.getAdaptiveMenuCssClass())) || 18096 parent && this.HasVisibleItems(parent); 18097 if(popupMenuHasVisibleContent === false) 18098 return; 18099 if(element && this.IsCallbacksEnabled()) 18100 this.ShowLoadingPanelInMenu(element); 18101 if(ASPx.GetElementVisibility(element)) 18102 ASPx.SetStyles(element, { left: ASPx.InvalidPosition, top: ASPx.InvalidPosition }); 18103 ASPx.SetElementDisplay(element, true); 18104 if(parent) { 18105 for(var i = 0; i < parent.GetItemCount() ; i++) { 18106 var item = parent.GetItem(i); 18107 this.SetPopOutElementVisible(item.indexPath, this.HasVisibleItems(item)); 18108 } 18109 } 18110 this.renderHelper.CalculateSubMenu(element, false); 18111 if(this.popupCount == 0) this.popupToLeft = this.rtl; 18112 this.RaisePopUp(indexPath); 18113 this.CalculateSubMenuPosition(element, x, y, indexPath, this.enableAnimation); 18114 aspxGetMenuCollection().RegisterVisiblePopupMenu(this.name, element.i
18114d); 18115 this.popupCount++; 18116 ASPx.GetControlCollection().AdjustControls(element); 18117 this.CorrectVerticalAlignment(ASPx.AdjustHeight, this.GetPopOutElements, "PopOut"); 18118 this.CorrectVerticalAlignment(ASPx.AdjustVerticalMargins, this.GetPopOutImages, "PopOutImg"); 18119 }, 18120 ShowLoadingPanelInMenu: function(element) { 18121 var lpParent = this.GetMenuMainElement(element); 18122 if(lpParent && !this.HasContent(lpParent)) 18123 this.CreateLoadingPanelInsideContainer(lpParent); 18124 }, 18125 GetScrollSubMenuYCorrection: function(element, scrollHelper, clientY) { 18126 var absoluteClientY = clientY + ASPx.GetPositionElementOffset(element); 18127 var excessTop = this.GetScrollExcessTop(absoluteClientY); 18128 var excessBottom = this.GetScrollExcessBottom(element, absoluteClientY); 18129 var correction = 0; 18130 if(excessTop > 0) 18131 correction += excessTop + this.scrollVertOffset; 18132 if(excessBottom > 0 && (absoluteClientY + correction == ASPx.GetDocumentScrollTop())) { 18133 excessBottom += this.scrollVertOffset; 18134 correction += this.scrollVertOffset; 18135 } 18136 this.PrepareScrolling(element, scrollHelper, excessTop, excessBottom); 18137 return correction; 18138 }, 18139 GetScrollExcessTop: function(clientY) { 18140 return ASPx.GetDocumentScrollTop() - clientY; 18141 }, 18142 GetScrollExcessBottom: function(element, clientY) { 18143 ASPx.SetElementDisplay(element, false); 18144 var docHeight = ASPx.GetDocumentClientHeight(); 18145 ASPx.SetElementDisplay(element, true); 18146 return clientY + element.offsetHeight - ASPx.GetDocumentScrollTop() - docHeight; 18147 }, 18148 PrepareScrolling: function(element, scrollHelper, excessTop, excessBottom) { 18149 scrollHelper.Initialize(); 18150 var corrector = element.offsetHeight - scrollHelper.GetScrollAreaHeight() + this.scrollVertOffset; 18151 if(excessTop > 0) 18152 scrollHelper.Calculate(element.offsetHeight - excessTop - corrector); 18153 if(excessBottom > 0) 18154 scrollHelper.Calculate(element.offsetHeight - excessBottom - corrector); 18155 }, 18156 ApplySubMenuFullWidth: function(element) { 18157 ASPx.SetStyles(element, { left: 0, right: 0, width: "auto" }); 18158 var menuElement = this.GetMenuMainElement(element); 18159 ASPx.SetStyles(menuElement, { width: "100%", "box-sizing": "border-box" }); 18160 var templateElement = ASPx.GetChildByClassName(menuElement, "dx"); 18161 if(templateElement) ASPx.SetStyles(templateElement, { width: "100%" }); 18162 }, 18163 DoShowPopupMenuIFrame: function(element, x, y, width, height, indexPath) { 18164 if(!this.renderIFrameForPopupElements) return; 18165 var iFrame = element.overflowElement; 18166 if(!iFrame) { 18167 iFrame = this.GetMenuIFrameElement(indexPath); 18168 element.overflowElement = iFrame; 18169 } 18170 if(iFrame) { 18171 var menuElement = this.GetMenuMainElement(element); 18172 if(width < 0) 18173 width = menuElement.offsetWidth; 18174 if(height < 0) 18175 height = menuElement.offsetHeight; 18176 ASPx.SetStyles(iFrame, { 18177 width: width, height: height, 18178 left: x, top: y, display: "" 18179 }); 18180 } 18181 }, 18182 DoShowPopupMenuBorderCorrector: function(element, x, y, indexPath, toTheLeft, toTheTop) { 18183 var borderCorrectorElement = this.GetMenuBorderCorrectorElement(indexPath); 18184 if(borderCorrectorElement) { 18185 var params = this.GetPopupMenuBorderCorrectorPositionAndSize(element, x, y, indexPath, toTheLeft, toTheTop); 18186 var itemCell = this.GetItemContentElement(indexPath); 18187 var popOutImageCell = this.GetItemPopOutElement(indexPath); 18188 if(ASPx.Browser.IE && ASPx.Browser.MajorVersion == 9) { 18189 var isVertical = this.IsVertical(indexPath); 18190 var itemBoundCoord = itemCell.getBoundingClientRect()[isVertical ? 'bottom' : 'right']; 18191 var itemBorderWidth = ASPx.PxToInt(ASPx.GetCurrentStyle(itemCell)[isVertical ? 'borderBottomWidth' : 'borderRightWidth']); 18192 if(popOutImageCell != null) { 18193 var popOutImageBoundCoord = popOutImageCell.getBoundingClientRect()[isVertical ? 'bottom' : 'right']; 18194 if(popOutImageBoundCoord > itemBoundCoord) { 18195 itemBoundCoord = popOutImageBoundCoord; 18196 itemBorderWidth = ASPx.PxToInt(ASPx.GetCurrentStyle(popOutImageCell)[isVertical ? 'borderBottomWidth' : 'borderRightWidth']); 18197 } 18198 } 18199 var menu = this.GetMainElement(); 18200 itemBoundCoord -= Math.min(menu.getBoundingClientRect()[isVertical ? 'top' : 'left'], ASPx.GetPositionElementOffset(menu, !isVertical)); 18201 if(isVertical) { 18202 var bottomsDifference = this.GetItemElement(indexPath).getBoundingClientRect().bottom - 18203 this.GetMenuElement(indexPath).getBoundingClientRect().bottom; 18204 itemBoundCoord -= bottomsDifference > 0 && bottomsDifference; 18205 } 18206 var borderCorrectorBoundCoord = isVertical ? params.top + params.height : params.left + params.width; 18207 if(itemBoundCoord - borderCorrectorBoundCoord != itemBorderWidth) { 18208 borderCorrectorBoundCoord = itemBoundCoord - itemBorderWidth; 18209 if(isVertical) 18210 params.height = borderCorrectorBoundCoord - params.top; 18211 else 18212 params.width = borderCorrectorBoundCoord - params.left; 18213 } 18214 } 18215 ASPx.SetStyles(borderCorrectorElement, { 18216 width: params.width, height: params.height, 18217 left: params.left, top: params.top, 18218 display: "", visibility: "visible" 18219 }); 18220 element.borderCorrectorElement = borderCorrectorElement; 18221 } 18222 }, 18223 GetPopupMenuBorderCorrectorPositionAndSize: function(element, x, y, indexPath, toTheLeft, toTheTop) { 18224 var result = {}; 18225 var itemInfo = new MenuItemInfo(this, indexPath); 18226 var menuXOffset = ASPx.GetClientLeft(this.GetMenuMainElement(element)); 18227 var menuYOffset = ASPx.GetClientTop(this.GetMenuMainElement(element)); 18228 var menuElement = this.GetMenuMainElement(element); 18229 var menuClientWidth = menuElement.clientWidth; 18230 var menuClientHeight = menuElement.clientHeight; 18231 if(this.IsVertical(indexPath)) { 18232 var commonClientHeight = itemInfo.clientHeight < menuClientHeight 18233 ? itemInfo.clientHeight 18234 : menuClientHeight; 18235 result.width = menuXOffset; 18236 result.height = commonClientHeight + itemInfo.clientTop - menuYOffset; 18237 result.left = x; 18238 if(toTheLeft) 18239 result.left += menuClientWidth + menuXOffset; 18240 result.top = y + menuYOffset; 18241 if(toTheTop) 18242 result.top += menuClientHeight - result.height; 18243 } 18244 else { 18245 var itemWidth = itemInfo.clientWidth; 18246 if(this.IsDropDownItem(indexPath)) 18247 itemWidth = this.GetItemContentElement(indexPath).clientWidth; 18248 var commonClientWidth = itemWidth < menuClientWidth 18249 ? itemWidth 18250 : menuClientWidth; 18251 result.width = commonClientWidth + itemInfo.clientLeft - menuXOffset; 18252 result.height = menuYOffset; 18253 result.left = x + menuXOffset; 18254 if(toTheLeft) 18255 result.left += menuClientWidth - result.width; 18256 result.top = y; 18257 if(toTheTop) 18258 result.top += menuClientHeight + menuYOffset; 18259 } 18260 return result; 18261 }, 18262 DoHidePopupMenu: function(evt, element) { 18263 this.DoHidePopupMenuBorderCorrector(element); 18264 this.DoHidePopupMenuIFrame(element); 18265 var menuElement = this.GetMenuMainElement(element); 18266 ASPx.PopupUtils.StopAnimation(element, menuElement); 18267 ASPx.SetElementVisibility(element, false); 18268 ASPx.SetElementDisplay(element, false); 18269 this.CancelSubMenuItemHoverItem(element); 18270 aspxGetMenuCollection().UnregisterVisiblePopupMenu(this.name, element.i
18270d); 18271 this.popupCount--; 18272 var indexPath = this.GetIndexPathById(element.id, true); 18273 this.DoResetScrolling(element, indexPath); 18274 this.RaiseCloseUp(indexPath); 18275 }, 18276 DoResetScrolling: function(element, indexPath) { 18277 var scrollHelper = this.GetScrollHelper(indexPath); 18278 if(scrollHelper) { 18279 element.style.height = ""; 18280 scrollHelper.ResetScrolling(); 18281 } 18282 }, 18283 DoHidePopupMenuIFrame: function(element) { 18284 if(!this.renderIFrameForPopupElements) return; 18285 var iFrame = element.overflowElement; 18286 if(iFrame) 18287 ASPx.SetElementDisplay(iFrame, false); 18288 }, 18289 DoHidePopupMenuBorderCorrector: function(element) { 18290 var borderCorrectorElement = element.borderCorrectorElement; 18291 if(borderCorrectorElement) { 18292 ASPx.SetElementVisibility(borderCorrectorElement, false); 18293 ASPx.SetElementDisplay(borderCorrectorElement, false); 18294 element.borderCorrectorElement = null; 18295 } 18296 }, 18297 MarkPrecedingItem: function(currentItemName, className, isItemNameUsed) { 18298 this.MarkPrecedingItemCore(currentItemName, className, true, isItemNameUsed); 18299 }, 18300 UnmarkPrecedingItem: function(currentItemName, className, isItemNameUsed) { 18301 this.MarkPrecedingItemCore(currentItemName, className, false, isItemNameUsed); 18302 }, 18303 MarkPrecedingItemCore: function(currentItemName, className, addClass, isItemNameUsed) { 18304 var previousItem = this.GetPreviousItem(currentItemName, isItemNameUsed); 18305 if(previousItem) { 18306 var element = this.GetItemElement(previousItem.indexPath); 18307 if(addClass) 18308 ASPx.AddClassNameToElement(element, className); 18309 else 18310 ASPx.RemoveClassNameFromElement(element, className); 18311 } 18312 }, 18313 SetHoverElement: function(element) { 18314 if(!this.IsStateControllerEnabled()) return; 18315 this.lockHoverEvents = true; 18316 ASPx.GetStateController().SetCurrentHoverElementBySrcElement(element); 18317 this.lockHoverEvents = false; 18318 }, 18319 ApplySubMenuItemHoverItem: function(element, hoverItem, hoverElement) { 18320 if(!element.hoverItem && ASPx.GetElementDisplay(element)) { 18321 var newHoverItem = hoverItem.Clone(); 18322 element.hoverItem = newHoverItem; 18323 element.hoverElement = hoverElement; 18324 newHoverItem.Apply(hoverElement); 18325 } 18326 }, 18327 CancelSubMenuItemHoverItem: function(element) { 18328 if(element.hoverItem) { 18329 element.hoverItem.Cancel(element.hoverElement); 18330 element.hoverItem = null; 18331 element.hoverElement = null; 18332 } 18333 }, 18334 ShowSubMenu: function(indexPath) { 18335 var element = this.GetMenuElement(indexPath); 18336 if(element != null) { 18337 var level = this.GetMenuLevel(indexPath); 18338 aspxGetMenuCollection().DoHidePopupMenus(null, level - 1, this.name, false, this.getExceptIdsForShowSubMenu(indexPath, element.id)); 18339 if(!this.isSubMenuElementVisible(element) && this.IsItemEnabled(indexPath)) 18340 this.DoShowPopupMenu(element, ASPx.InvalidPosition, ASPx.InvalidPosition, indexPath); 18341 } 18342 this.ClearAppearTimer(); 18343 }, 18344 getExceptIdsForShowSubMenu: function (itemIndexPath, exceptId) { 18345 return [exceptId]; 18346 }, 18347 isSubMenuElementVisible: function(subMenuElement) { 18348 return ASPx.GetElementDisplay(subMenuElement); 18349 }, 18350 SelectItem: function(indexPath) { 18351 if(!this.IsStateControllerEnabled()) return; 18352 var element = this.GetItemContentElement(indexPath); 18353 if(element != null) { 18354 ASPx.GetStateController().SelectElementBySrcElement(element); 18355 if(this.sideMenuModeOn) 18356 this.MarkPrecedingItem(indexPath, PRE_SELECTED_ELEMENT_CLASS_NAME, false); 18357 } 18358 }, 18359 DeselectItem: function(indexPath) { 18360 if(!this.IsStateControllerEnabled()) return; 18361 var element = this.GetItemContentElement(indexPath); 18362 if(element != null) { 18363 var hoverItem = null; 18364 var hoverElement = null; 18365 var menuElement = this.GetMenuElement(indexPath); 18366 if(menuElement && menuElement.hoverItem) { 18367 hoverItem = menuElement.hoverItem; 18368 hoverElement = menuElement.hoverElement; 18369 this.CancelSubMenuItemHoverItem(menuElement); 18370 } 18371 ASPx.GetStateController().DeselectElementBySrcElement(element); 18372 if(menuElement != null && hoverItem != null) 18373 this.ApplySubMenuItemHoverItem(menuElement, hoverItem, hoverElement); 18374 if(this.sideMenuModeOn) 18375 this.UnmarkPrecedingItem(indexPath, PRE_SELECTED_ELEMENT_CLASS_NAME, false); 18376 } 18377 }, 18378 InitializeSelectedItem: function() { 18379 if(!this.allowSelectItem && !this.HasServerSideSelectedItem()) return; 18380 this.SelectItem(this.GetSelectedItemIndexPath()); 18381 this.InitializeServerSideSelectedItem(); 18382 }, 18383 InitializeServerSideSelectedItem: function() { 18384 if(!this.allowSelectItem && this.sideMenuModeOn && this.HasServerSideSelectedItem()) 18385 this.MarkPrecedingItem(this.serverSideSelectedItemPath, PRE_SELECTED_ELEMENT_CLASS_NAME, false); 18386 }, 18387 HasServerSideSelectedItem: function() { 18388 return typeof (this.serverSideSelectedItemPath) !== "undefined"; 18389 }, 18390 GetSelectedItemIndexPath: function() { 18391 return this.selectedItemIndexPath; 18392 }, 18393 SetSelectedItemInternal: function(indexPath, modifyHotTrackSelection) { 18394 if(modifyHotTrackSelection) 18395 this.SetHoverElement(null); 18396 this.DeselectItem(this.selectedItemIndexPath); 18397 this.selectedItemIndexPath = indexPath; 18398 var item = this.GetItemByIndexPath(indexPath); 18399 if(item == null || item.GetEnabled()) 18400 this.SelectItem(this.selectedItemIndexPath); 18401 if(modifyHotTrackSelection) { 18402 var element = this.GetItemContentElement(indexPath); 18403 if(element != null) 18404 this.SetHoverElement(element); 18405 } 18406 }, 18407 InitializeCheckedItems: function() { 18408 if(!this.allowCheckItems) return; 18409 var indexPathes = this.checkedState.split(";"); 18410 for(var i = 0; i < indexPathes.length; i++) { 18411 if(indexPathes[i] != "") { 18412 this.checkedItems.push(indexPathes[i]); 18413 this.SelectItem(indexPathes[i]); 18414 } 18415 } 18416 }, 18417 ChangeCheckedItem: function(indexPath) { 18418 this.SetHoverElement(null); 18419 var itemsGroup = this.GetItemsGroup(indexPath); 18420 if(itemsGroup != null) { 18421 if(itemsGroup.length > 1) { 18422 if(!this.IsCheckedItem(indexPath)) {
18423 for(var i = 0; i < itemsGroup.length; i++) { 18424 if(itemsGroup[i] == indexPath) continue; 18425 if(this.IsCheckedItem(itemsGroup[i])) { 18426 ASPx.Data.ArrayRemove(this.checkedItems, itemsGroup[i]); 18427 this.DeselectItem(itemsGroup[i]); 18428 } 18429 } 18430 this.SelectItem(indexPath); 18431 this.checkedItems.push(indexPath); 18432 } 18433 } 18434 else { 18435 if(this.IsCheckedItem(indexPath)) { 18436 ASPx.Data.ArrayRemove(this.checkedItems, indexPath); 18437 this.DeselectItem(indexPath); 18438 } 18439 else { 18440 this.SelectItem(indexPath); 18441 this.checkedItems.push(indexPath); 18442 } 18443 } 18444 } 18445 var element = this.GetItemContentElement(indexPath); 18446 if(element != null) 18447 this.SetHoverElement(element); 18448 }, 18449 GetItemsGroup: function(indexPath) { 18450 for(var i = 0; i < this.itemCheckedGroups.length; i++) { 18451 if(ASPx.Data.ArrayIndexOf(this.itemCheckedGroups[i], indexPath) > -1) 18452 return this.itemCheckedGroups[i]; 18453 } 18454 return null; 18455 }, 18456 IsCheckedItem: function(indexPath) { 18457 return ASPx.Data.ArrayIndexOf(this.checkedItems, indexPath) > -1; 18458 }, 18459 UpdateStateObject: function(){ 18460 this.UpdateStateObjectWithObject({ selectedItemIndexPath: this.selectedItemIndexPath, checkedState: this.GetCheckedState() }); 18461 }, 18462 GetCheckedState: function() { 18463 var state = ""; 18464 for(var i = 0; i < this.checkedItems.length; i++) { 18465 state += this.GetCheckedItemInfo(this.checkedItems[i]); 18466 if(i < this.checkedItems.length - 1) 18467 state += ";"; 18468 } 18469 return state; 18470 }, 18471 GetCheckedItemInfo: function(itemIndexPath) { 18472 return itemIndexPath; 18473 }, 18474 GetAnimationVerticalDirection: function(indexPath, popupPosition, isVertical) { 18475 var verticalDirection = (this.IsRootItem(indexPath) && !isVertical) ? -1 : 0; 18476 if(popupPosition.isInverted) verticalDirection *= -1; 18477 return verticalDirection; 18478 }, 18479 GetAnimationHorizontalDirection: function(indexPath, popupPosition, isVertical) { 18480 var horizontalDirection = (this.IsRootItem(indexPath) && !isVertical) ? 0 : -1; 18481 if(popupPosition.isInverted) horizontalDirection *= -1; 18482 return horizontalDirection; 18483 }, 18484 skipPopupMenuSizeInit: function() { 18485 return false; 18486 }, 18487 StartAnimation: function(animationDivElement, indexPath, horizontalPopupPosition, verticalPopupPosition, isVertical) { 18488 this.inSubmenuShowAnimation = true; 18489 var element = this.GetMenuMainElement(animationDivElement); 18490 var clientX = horizontalPopupPosition.position; 18491 var clientY = verticalPopupPosition.position; 18492 ASPx.PopupUtils.InitAnimationDiv(animationDivElement, clientX, clientY, this.OnAnimationFinished.aspxBind(this), this.skipPopupMenuSizeInit()); 18493 var verticalDirection = this.GetAnimationVerticalDirection(indexPath, verticalPopupPosition, isVertical); 18494 var horizontalDirection = this.GetAnimationHorizontalDirection(indexPath, horizontalPopupPosition, isVertical); 18495 var yPos = verticalDirection * element.offsetHeight; 18496 var xPos = horizontalDirection * element.offsetWidth; 18497 ASPx.SetStyles(element, { left: xPos, top: yPos }); 18498 ASPx.SetElementVisibility(animationDivElement, true); 18499 if(this.enableSubMenuFullWidth) 18500 this.ApplySubMenuFullWidth(animationDivElement); 18501 this.DoShowPopupMenuIFrame(animationDivElement, clientX, clientY, 0, 0, indexPath); 18502 this.DoShowPopupMenuBorderCorrector(animationDivElement, clientX, clientY, indexPath, 18503 horizontalPopupPosition.isInverted, verticalPopupPosition.isInverted); 18504 ASPx.PopupUtils.StartSlideAnimation(animationDivElement, element, this.GetMenuIFrameElement(indexPath), this.slideAnimationDuration, this.enableSubMenuFullWidth, false); 18505 }, 18506 OnAnimationFinished: function() { 18507 window.setTimeout(function() { this.inSubmenuShowAnimation = false; }.aspxBind(this), 100); 18508 }, 18509 OnItemClick: function(indexPath, evt) { 18510 var sourceElement = ASPx.Evt.GetEventSource(evt); 18511 var clickedLinkElement = ASPx.GetParentByTagName(sourceElement, "A"); 18512 var isLinkClicked = (clickedLinkElement != null && clickedLinkElement.href != ASPx.AccessibilityEmptyUrl); 18513 var element = this.GetItemContentElement(indexPath); 18514 var linkElement = (element != null) ? (element.tagName === "A" ? element : ASPx.GetNodeByTagName(element, "A", 0)) : null; 18515 if(linkElement != null && linkElement.href == ASPx.AccessibilityEmptyUrl) 18516 linkElement = null; 18517 if(this.allowSelectItem) 18518 this.SetSelectedItemInternal(indexPath, true); 18519 if(this.allowCheckItems || this.canCheckItem(element)) 18520 this.ChangeCheckedItem(indexPath); 18521 this.DoItemClick(indexPath, isLinkClicked || (linkElement != null), evt); 18522 if(!isLinkClicked && linkElement != null && !(ASPx.Browser.WebKitTouchUI && this.HasChildren(indexPath))) 18523 ASPx.Url.NavigateByLink(linkElement); 18524 }, 18525 canCheckItem: function (itemElement) { 18526 return false; 18527 }, 18528 OnItemDropDownClick: function(indexPath, evt) { 18529 if(this.IsItemEnabled(indexPath)) { 18530 if(this.IsAdaptiveItem(indexPath)) 18531 this.toggleAdaptiveSubmenu(indexPath); 18532 else 18533 this.keyboardHelper.ShowSubMenuAccessible(indexPath); 18534 } 18535 }, 18536 toggleAdaptiveSubmenu: function(indexPath) { 18537 var element = this.GetMenuElement(indexPath); 18538 if(ASPx.GetElementDisplay(element) && !this.IsAdaptiveItemAnimationActive()) 18539 this.DoHidePopupMenu(null, element); 18540 else 18541 this.keyboardHelper.ShowSubMenuAccessible(indexPath); 18542 }, 18543 AfterItemOverAllowed: function(hoverItem) { 18544 return hoverItem.name != "" && !this.lockHoverEvents; 18545 }, 18546 OnAfterItemOver: function(hoverItem, hoverElement) {
18547 if(!this.AfterItemOverAllowed(hoverItem)) return; 18548 if(!this.showSubMenus) { 18549 this.savedCallbackHoverItem = hoverItem; 18550 this.savedCallbackHoverElement = hoverElement; 18551 return; 18552 } 18553 this.ClearDisappearTimer(); 18554 this.ClearAppearTimer(); 18555 var indexPath = this.GetMenuIndexPathById(hoverItem.name); 18556 if(indexPath == "") { 18557 indexPath = this.GetItemIndexPathById(hoverItem.name); 18558 var canShowSubMenu = true; 18559 if(this.IsDropDownItem(indexPath)) { 18560 var popOutImageElement = this.GetItemPopOutElement(indexPath); 18561 if(popOutImageElement != null && popOutImageElement != hoverElement) { 18562 hoverItem.needRefreshBetweenElements = true; 18563 canShowSubMenu = false; 18564 } 18565 } 18566 var preventSubMenu = !(canShowSubMenu && hoverItem.enabled && hoverItem.kind == ASPx.HoverItemKind); 18567 this.SetAppearTimer(indexPath, preventSubMenu); 18568 this.RaiseItemMouseOver(indexPath); 18569 } 18570 }, 18571 OnBeforeItemOver: function(hoverItem, hoverElement) { 18572 if(ASPx.Browser.NetscapeFamily && ASPx.IsExists(hoverElement.offsetParent) && 18573 hoverElement.offsetParent.style.borderCollapse == "collapse") { 18574 hoverElement.offsetParent.style.borderCollapse = "separate"; 18575 hoverElement.offsetParent.style.borderCollapse = "collapse"; 18576 } 18577 var indexPath = this.GetItemIndexPathById(hoverItem.name); 18578 var element = this.GetMenuElement(indexPath); 18579 if(element) this.CancelSubMenuItemHoverItem(element); 18580 }, 18581 OnItemOverTimer: function(indexPath, preventSubMenu) { 18582 var element = this.GetMenuElement(indexPath); 18583 if(element == null || preventSubMenu) { 18584 var level = this.GetMenuLevel(indexPath); 18585 aspxGetMenuCollection().DoHidePopupMenus(null, level - 1, this.name, false, this.getExceptIdsForItemOverTimer(indexPath)); 18586 } 18587 if(this.IsAppearTimerActive() && !preventSubMenu) { 18588 this.ClearAppearTimer(); 18589 if(this.GetItemContentElement(indexPath) != null || this.GetItemPopOutElement(indexPath) != null) { 18590 this.ShowSubMenu(indexPath); 18591 } 18592 } 18593 }, 18594 getExceptIdsForItemOverTimer: function(indexPath) { 18595 var result = []; 18596 aspxGetMenuCollection().ForEachControl(function(menu) { 18597 var isPopupMenu = ASPx.IsExists(menu.popupAction) && ASPx.IsExists(menu.closeAction); 18598 if(isPopupMenu && menu.closeAction === "OuterMouseClick") 18599 result.push(menu.GetMainElementId()); 18600 }, this); 18601 return result; 18602 }, 18603 OnBeforeItemDisabled: function(disabledItem, disabledElement) { 18604 this.ClearAppearTimer(); 18605 var indexPath = this.GetItemIndexPathById(disabledElement.id); 18606 if(indexPath != "") { 18607 var element = this.GetMenuElement(indexPath); 18608 if(element != null) this.DoHidePopupMenu(null, element); 18609 } 18610 }, 18611 OnAfterItemOut: function(hoverItem, hoverElement, newHoverElement) { 18612 if(!this.showSubMenus) { 18613 this.savedCallbackHoverItem = null; 18614 this.savedCallbackHoverElement = null; 18615 } 18616 if(hoverItem.name == "" || this.lockHoverEvents) return; 18617 if(hoverItem.IsChildElement(newHoverElement)) return; 18618 var indexPath = this.GetItemIndexPathById(hoverItem.name); 18619 var element = this.GetMenuElement(indexPath); 18620 this.ClearDisappearTimer(); 18621 this.ClearAppearTimer(); 18622 if(element == null || !ASPx.GetIsParent(element, newHoverElement)) 18623 this.SetDisappearTimer(); 18624 if(element != null) 18625 this.ApplySubMenuItemHoverItem(element, hoverItem, hoverElement); 18626 if(indexPath != "") 18627 this.RaiseItemMouseOut(indexPath); 18628 }, 18629 OnItemOutTimer: function() { 18630 if(this.IsDisappearTimerActive()) { 18631 this.ClearDisappearTimer(); 18632 if(aspxGetMenuCollection().CheckFocusedElement()) 18633 this.SetDisappearTimer(); 18634 else 18635 this.OnHideByItemOut(); 18636 } 18637 }, 18638 OnHideByItemOut: function() { 18639 aspxGetMenuCollection().DoHidePopupMenus(null, 0, this.name, true, ""); 18640 }, 18641 TryFocusItem: function(itemIndex) { 18642 var item = this.GetItem(itemIndex); 18643 if(item.GetVisible() && item.GetEnabled()) { 18644 this.FocusItemByIndexPath(item.GetIndexPath()); 18645 return true; 18646 } 18647 return false; 18648 }, 18649 Focus: function() { 18650 if(this.rootItem != null) { 18651 for(var i = 0; i < this.GetItemCount() ; i++) { 18652 if(this.TryFocusItem(i)) 18653 return true; 18654 } 18655 } 18656 else 18657 this.keyboardHelper.FocusNextItem("-1"); 18658 }, 18659 FocusLastItem: function() { 18660 if(this.rootItem != null) { 18661 for(var i = this.GetItemCount() - 1; i >= 0; i--) { 18662 if(this.TryFocusItem(i)) 18663 return true; 18664 } 18665 } 18666 else 18667 this.keyboardHelper.FocusPrevItem(this.GetItemCount() - 1); 18668 }, 18669 FocusItemByIndexPath: function(indexPath) { 18670 this.keyboardHelper.FocusItemByIndexPath(indexPath); 18671 }, 18672 OnFocusedItemKeyDown: function(evt, focusedItem) { 18673 this.keyboardHelper.OnFocusedItemKeyDown(evt, focusedItem); 18674 }, 18675 ProcessLostFocus: function(evt) { 18676 if(!this.isContextMenu || !this.accessibilityCompliant) return; 18677 if(this.accessibleFocusElement) 18678 this.accessibleFocusElement.focus(); 18679 this.Hide(); 18680 if(evt) 18681 ASPx.Evt.PreventEventAndBubble(evt); 18682 }, 18683 OnCallback: function(result) { 18684 ASPx.InitializeScripts(); 18685 this.InitializeScrollableMenus(); 18686 for (var indexPath in result) { 18687 if(result.hasOwnProperty(indexPath)) { 18688 var menuElement = this.GetMenuElement(indexPath); 18689 if(menuElement) { 18690 var menuResult = result[indexPath]; 18691 if(aspxGetMenuCollection().IsSubMenuVisible(menuElement.id)) 18692 this.ShowPopupSubMenuAfterCallback(menuElement, menuResult); 18693 else 18694 this.SetSubMenuInnerHtml(menuElement, menuResult); 18695 } 18696 } 18697 } 18698 this.ClearVerticalAlignedElementsCache(); 18699 this.CorrectVerticalAlignment(ASPx.AdjustHeight, this.GetPopOutElements, "PopOut"); 18700 this.CorrectVerticalAlignment(ASPx.AdjustVerticalMargins, this.GetPopOutImages, "PopOutImg"); 18701 this.InitializeInternal(false); 18702 if(!this.showSubMenus) { 18703 this.showSubMenus = true; 18704 if(this.savedCallbackHoverItem != null && this.savedCallbackHoverElement != null) 18705 this.OnAfterItemOver(this.savedCallbackHoverItem, this.savedCallbackHoverElement); 18706 this.savedCallbackHoverItem = null; 18707 this.savedCallbackHoverElement = null; 18708 } 18709 }, 18710 SetSubMenuInnerHtml: function(menuElement, html) { 18711 ASPx.SetInnerHtml(this.GetMenuMainElement(menuElement), html); 18712 this.dropElementsCache = true; 18713 this.renderHelper.InlineInitializePopupMenuMenuElement(menuElement, this.GetIndexPathById(menuElement.id, true)); 18714 this.renderHelper.CalculateSubMenu(menuElement, true); 18715 }, 18716 ShowPopupSubMenuAfterCallback: function(element, callbackResult) {
18717 var indexPath = this.GetIndexPathById(element.id, true); 18718 var currentX = ASPx.PxToInt(element.style.left); 18719 var currentY = ASPx.PxToInt(element.style.top); 18720 var showedToTheTop = this.ShowedToTheTop(element, indexPath); 18721 var showedToTheLeft = this.ShowedToTheLeft(element, indexPath); 18722 ASPx.SetStyles(element, { 18723 left: ASPx.InvalidPosition, top: ASPx.InvalidPosition 18724 }); 18725 this.SetSubMenuInnerHtml(element, callbackResult); 18726 var vertPos = this.GetClientSubMenuPos(element, indexPath, ASPx.InvalidPosition, this.IsVertical(indexPath), false); 18727 var clientY = vertPos.position; 18728 var toTheTop = vertPos.isInverted; 18729 if(!this.IsVertical(indexPath) && showedToTheTop != toTheTop) { 18730 clientY = currentY; 18731 toTheTop = showedToTheTop; 18732 } 18733 clientY += this.GetScrollingCorrection(element, indexPath, clientY); 18734 ASPx.SetStyles(element, { left: currentX, top: clientY }); 18735 if(this.enableSubMenuFullWidth) 18736 this.ApplySubMenuFullWidth(element); 18737 this.DoShowPopupMenuIFrame(element, currentX, clientY, ASPx.InvalidDimension, ASPx.InvalidDimension, indexPath); 18738 this.DoShowPopupMenuBorderCorrector(element, currentX, clientY, indexPath, showedToTheLeft, toTheTop); 18739 ASPx.GetControlCollection().AdjustControls(element); 18740 }, 18741 GetScrollingCorrection: function(element, indexPath, clientY) { 18742 var scrollHelper = this.GetScrollHelper(indexPath); 18743 if(scrollHelper) { 18744 var yClientCorrection = this.GetScrollSubMenuYCorrection(element, scrollHelper, clientY); 18745 if(yClientCorrection > 0) 18746 return yClientCorrection; 18747 } 18748 return 0; 18749 }, 18750 ShowedToTheTop: function(element, indexPath) { 18751 var currentY = ASPx.PxToInt(element.style.top); 18752 var parentBottomY = this.GetSubMenuYPosition(indexPath, this.IsVertical(indexPath)); 18753 return currentY < parentBottomY; 18754 }, 18755 ShowedToTheLeft: function(element, indexPath) { 18756 var currentX = ASPx.PxToInt(element.style.left); 18757 var parentX = this.GetSubMenuXPosition(indexPath, this.IsVertical(indexPath)); 18758 return currentX < parentX; 18759 }, 18760 CreateItems: function(items) { 18761 if (items.length == 0) 18762 return; 18763 if(this.NeedCreateItemsOnClientSide()) 18764 this.CreateClientItems(items); 18765 else 18766 this.CreateServerItems(items); 18767 }, 18768 AddItem: function(item) { 18769 this.CreateClientItems([item]); 18770 }, 18771 CreateClientItems: function(items) { 18772 this.PreInitializeClientMenuItems(); 18773 this.rootItem.CreateItems(items); 18774 this.RenderItems(this.rootItem.items); 18775 this.InitializeClientItems(); 18776 }, 18777 CreateServerItems: function(items) { 18778 this.CreateRootItemIfRequired(); 18779 this.rootItem.CreateItems(items); 18780 }, 18781 PreInitializeClientMenuItems: function() { 18782 if(!this.rootMenuSample) 18783 this.InitializeMenuSamples(); 18784 this.CreateRootItemIfRequired(); 18785 if(!this.renderData) 18786 this.CreateRenderData(); 18787 }, 18788 InitializeClientItems: function() { 18789 this.dropElementsCache = true; 18790 this.renderHelper.InlineInitializeElements(); 18791 this.ApplyItemsProperties(this.rootItem.items); 18792 this.InitializeEnabledAndVisible(true); 18793 if(this.isPopupMenu) 18794 this.renderHelper.CalculateSubMenu(this.GetMainElement(), true); 18795 else 18796 this.renderHelper.CalculateMenuControl(this.GetMainElement(), true); 18797 }, 18798 ApplyItemsProperties: function(items) { 18799 var itemsCount = items.length; 18800 if(itemsCount == 0) 18801 return; 18802 for(var i = 0; i < itemsCount; i++) { 18803 var item = items[i]; 18804 this.ApplyItemProperties(item); 18805 this.ApplyItemsProperties(item.items); 18806 } 18807 }, 18808 ApplyItemProperties: function(item) { 18809 var indexPath = item.GetIndexPath(); 18810 if(item.imageUrl) 18811 this.SetItemImageUrl(indexPath, item.imageUrl); 18812 if(item.imageClassName) { 18813 this.AddItemImageClassName(indexPath, item.imageClassName); 18814 this.AddItemAdditionalImageClassName(indexPath, item.imageClassName); 18815 } 18816 if(item.navigateUrl) 18817 this.SetItemNavigateUrl(indexPath, item.navigateUrl, item.target); 18818 if(item.tooltip != "") 18819 this.SetItemTooltip(indexPath, item.tooltip); 18820 var textNode = this.FindTextNode(indexPath); 18821 if(textNode) 18822 textNode.parentNode.innerHTML = this.HtmlEncode(item.text); 18823 this.SetItemChecked(indexPath, item.checked); 18824 if(item.textTemplate) 18825 this.SetItemTextTemplate(indexPath, item.textTemplate); 18826 }, 18827 ProcessItemGroupName: function(item, groupName) { 18828 if(this.allowSelectItem || !groupName) 18829 return; 18830 this.allowCheckItems = true; 18831 var groupNames = this.itemCheckedGroups.groupNames; 18832 if(groupNames[groupName]) 18833 groupNames[groupName].push(item.indexPath); 18834 else { 18835 groupNames[groupName] = [item.indexPath]; 18836 this.itemCheckedGroups.push(groupNames[groupName]); 18837 } 18838 item.checkedGroup = groupNames[groupName]; 18839 }, 18840 CreateRootItemIfRequired: function() { 18841 if(!this.rootItem) { 18842 var itemType = this.GetClientItemType(); 18843 this.rootItem = new itemType(this, null, 0, ""); 18844 } 18845 }, 18846 ClearRootMenuElement: function() { 18847 var wrapperElement = this.GetMainElement().parentNode; 18848 wrapperElement.innerHTML = ""; 18849 wrapperElement.appendChild(this.rootMenuSample.cloneNode(true)); 18850 this.renderHelper.InlineInitializeScrollElements("", this.GetMainElement()); 18851 }, 18852 NeedAppendToRenderData: function(item) { 18853 return this.NeedCreateItemsOnClientSide() && item.visible || typeof(item.visible) == "undefined"; 18854 }, 18855 ClearItems: function() { 18856 this.PreInitializeClientMenuItems();
18857 this.ClearRootMenuElement(); 18858 this.ClearRenderData(); 18859 this.rootItem.items = []; 18860 this.checkedItems = []; 18861 }, 18862 GetSampleNode: function(sampleHtml) { 18863 return ASPx.CreateHtmlElementFromString(sampleHtml); 18864 }, 18865 GetParentItem: function(rootItemIndexPath) { 18866 if(!rootItemIndexPath) 18867 return this.rootItem; 18868 return this.GetItemByIndexPath(rootItemIndexPath); 18869 }, 18870 RenderItems: function(items) { 18871 for(var i=0; i < items.length; i++) { 18872 var item = items[i]; 18873 this.RenderItemIfRequired(item); 18874 this.RenderItems(item.items); 18875 } 18876 }, 18877 RenderItemIfRequired: function(item) { 18878 if(!this.GetItemElement(item.indexPath)) { 18879 var isRootItem = !this.GetItemElement(item.parent.indexPath); 18880 var rootMenuElement = this.GetOrRenderRootItem(item, isRootItem); 18881 this.RenderItemInternal(rootMenuElement, item, isRootItem); 18882 this.ApplyStylesToRenderItem(item, isRootItem); 18883 } 18884 }, 18885 ApplyStylesToRenderItem: function(item, isRootItem) { 18886 var styles = JSON.parse(JSON.stringify(isRootItem ? this.samples.itemsStyles : this.samples.subitemsStyles)); 18887 var hoverStyle = styles.hover; 18888 var disabledStyle = styles.disable; 18889 var selectedStyle = styles.select; 18890 var checkedStyle = styles.check; 18891 var itemElementId = this.GetItemElementId(item.indexPath); 18892 if(item.styles && item.styles.ho) { 18893 var itemHover = item.styles.ho; 18894 if(!!itemHover.style) 18895 hoverStyle.cssTexts[0] = itemHover.style; 18896 if(!!itemHover.cssClass) 18897 hoverStyle.classNames[0] += " " + itemHover.cssClass; 18898 } 18899 if(item.styles && item.styles.st) { 18900 var itemElement = this.GetItemElement(item.indexPath); 18901 var style = item.styles.st; 18902 itemElement.setAttribute("style", style.style); 18903 if(!!style.cssClass) 18904 ASPx.AddClassNameToElement(itemElement, style.cssClass); 18905 } 18906 ASPx.GetStateController().AddHoverItem(itemElementId, hoverStyle.classNames || [MenuCssClasses.ItemHovered], hoverStyle.cssTexts || [""], hoverStyle.postfixes || [""], item.imageHottrackSrc ? [item.imageHottrackSrc] : null, [Constants.ImagePostfix, Constants.PopupImagePostfix], false); 18907 ASPx.GetStateController().AddDisabledItem(itemElementId, disabledStyle.classNames || [MenuCssClasses.Disabled], disabledStyle.cssTexts || [""], disabledStyle.postfixes || [""], null, null, false); 18908 if(selectedStyle && this.allowSelectItem) 18909 ASPx.GetStateController().AddSelectedItem(itemElementId, selectedStyle.classNames || [MenuCssClasses.ItemSelected], selectedStyle.cssTexts || [""], selectedStyle.postfixes || [""], null, null, false); 18910 else if (checkedStyle && this.allowCheckItems && item.checkedGroup.length) { 18911 var checkedClassName = null; 18912 if(!item.imageClassName) 18913 checkedClassName = [this.samples.checkedClassName]; 18914 ASPx.GetStateController().AddSelectedItem(itemElementId, checkedStyle.classNames || [MenuCssClasses.ItemChecked], checkedStyle.cssTexts || [""], checkedStyle.postfixes || [""], checkedClassName, ['Img'], false); 18915 } 18916 }, 18917 GetOrRenderRootItem: function(item, isRootItem) { 18918 if(!isRootItem) { 18919 var rootMenuElement = this.GetMenuElement(item.parent.indexPath); 18920 return rootMenuElement ? rootMenuElement : this.RenderSubMenuItem(item.parent.indexPath); 18921 } else 18922 return this.GetMenuElement(""); 18923 }, 18924 RenderItemInternal: function(rootItem, item, isRootItem) { 18925 var contentElement = this.renderHelper.GetContentElement(rootItem); 18926 var element = this.CreateItemElement(item, isRootItem); 18927 this.RenderSeparatorElementIfRequired(contentElement, item); 18928 this.RenderSpaceElementIfRequired(contentElement, item); 18929 contentElement.appendChild(element); 18930 }, 18931 RenderSeparatorElementIfRequired: function(rootItem, item) { 18932 if(item.beginGroup && item.index > 0) { 18933 var separatorElement = this.CreateSeparatorElement(item.indexPath); 18934 rootItem.appendChild(separatorElement); 18935 } 18936 }, 18937 RenderSpaceElementIfRequired: function(rootItem, item) { 18938 if(!item.beginGroup && item.index > 0 && rootItem.childNodes.length > 0) { 18939 if(this.samples.spacing) { 18940 var spacingElement = this.CreateSpacingElement(item.indexPath); 18941 rootItem.appendChild(spacingElement); 18942 } 18943 } 18944 }, 18945 RenderSubMenuItem: function(indexPath) { 18946 var subMenuElement = this.CreateSubMenuElement(indexPath); 18947 this.GetMainElement().parentElement.appendChild(subMenuElement); 18948 return subMenuElement; 18949 }, 18950 HasSeparatorOnCurrentPosition: function(itemElements, position) { 18951 return itemElements[position - 1 >
18951 0 ? position - 1 : 0].className.indexOf(MenuCssClasses.Separator) > -1; 18952 }, 18953 CreateItemElement: function(item, isRootItem) { 18954 var itemSample = isRootItem ? this.GetRootItemSample(item) : this.GetSubitemSample(item); 18955 var itemElement = itemSample.cloneNode(true); 18956 itemElement.id = this.GetItemElementId(item.indexPath); 18957 return itemElement; 18958 }, 18959 GetRootItemSample: function(item) { 18960 return this.GetItemSample(this.samples.rootItems, item); 18961 }, 18962 GetSubitemSample: function(item) { 18963 return this.GetItemSample(this.samples.submenuItems, item); 18964 }, 18965 GetItemSample: function(samples, item) { 18966 var key = this.sampleItemsFlags.TextOnly; 18967 if(item.items.length > 0) 18968 key = key | this.sampleItemsFlags.SubItems; 18969 if(item.imageUrl) 18970 key = key | this.sampleItemsFlags.Image; 18971 if(item.navigateUrl) 18972 key = key | this.sampleItemsFlags.NavigateUrl; 18973 if(item.dropDownMode) 18974 key = key | this.sampleItemsFlags.DropDownMode; 18975 if(item.checkedGroup.length) 18976 key = key | this.sampleItemsFlags.CheckBox; 18977 if(item.imageClassName) 18978 key = key | this.sampleItemsFlags.ImageClassName; 18979 if(item.isSvg) 18980 key = key | this.sampleItemsFlags.Svg; 18981 return samples[key]; 18982 }, 18983 CreateSpacingElement: function(indexPath) { 18984 var item = this.samples.spacing.cloneNode(); 18985 item.id = this.GetItemIndentElementId(indexPath); 18986 return item; 18987 }, 18988 CreateSeparatorElement: function(indexPath) { 18989 var item = this.samples.separator.cloneNode(true); 18990 item.id = this.GetItemSeparatorElementId(indexPath); 18991 return item; 18992 }, 18993 CreateSubMenuElement: function(indexPath) { 18994 var subMenu = this.samples.submenu.cloneNode(true); 18995 subMenu.id = this.name + Constants.MMIdSuffix + indexPath + "_"; 18996 return subMenu; 18997 }, 18998 AppendToRenderData: function(rootItemIndexPath, index) { 18999 if(rootItemIndexPath) { 19000 if(!this.renderData[rootItemIndexPath]) 19001 this.renderData[rootItemIndexPath] = [[index]]; 19002 this.renderData[rootItemIndexPath][index] = [index]; 19003 } else { 19004 this.renderData[""].push([[index]]); 19005 } 19006 }, 19007 CreateRenderData: function() { 19008 this.renderData = {"" : []}; 19009 }, 19010 ClearRenderData: function() { 19011 this.renderData = null; 19012 }, 19013 GetClientItemType: function() { 19014 return ASPxClientMenuItem; 19015 }, 19016 GetItemByIndexPath: function(indexPath) { 19017 var item = this.rootItem; 19018 if(indexPath != "" && item != null) { 19019 var indexes = this.GetItemIndexes(indexPath); 19020 for(var i = 0; i < indexes.length; i++) 19021 item = item.GetItem(indexes[i]); 19022 } 19023 return item; 19024 }, 19025 GetLinkElementByIndexPath: function(indexPath) { 19026 var itemElement = this.GetItemElement(indexPath); 19027 return this.renderHelper.GetItemLinkElement(itemElement); 19028 }, 19029 SetItemChecked: function(indexPath, checked) { 19030 var itemsGroup = this.GetItemsGroup(indexPath); 19031 if(itemsGroup != null) { 19032 if(!checked && this.IsCheckedItem(indexPath)) { 19033 ASPx.Data.ArrayRemove(this.checkedItems, indexPath); 19034 this.DeselectItem(indexPath); 19035 } 19036 else if(checked && !this.IsCheckedItem(indexPath)) { 19037 if(itemsGroup.length > 1) { 19038 for(var i = 0; i < itemsGroup.length; i++) { 19039 if(itemsGroup[i] == indexPath) continue; 19040 if(this.IsCheckedItem(itemsGroup[i])) { 19041 ASPx.Data.ArrayRemove(this.checkedItems, itemsGroup[i]); 19042 this.DeselectItem(itemsGroup[i]); 19043 } 19044 } 19045 } 19046 this.SelectItem(indexPath); 19047 this.checkedItems.push(indexPath); 19048 } 19049 if(this.accessibilityCompliant) { 19050 var link = this.GetLinkElementByIndexPath(indexPath); 19051 if(link) 19052 ASPx.Attr.SetAttribute(link, "aria-checked", checked ? "true" : "false"); 19053 } 19054 } 19055 }, 19056 ChangeItemEnabledAttributes: function(indexPath, enabled) { 19057 this.renderHelper.ChangeItemEnabledAttributes(this.GetItemElement(indexPath), enabled, this.accessibilityCompliant); 19058 }, 19059 IsItemEnabled: function(indexPath) { 19060 var item = this.GetItemByIndexPath(indexPath); 19061 return (item != null) ? item.GetEnabled() : true; 19062 }, 19063 SetItemEnabled: function(indexPath, enabled, initialization) { 19064 if(indexPath == "" || !this.GetItemByIndexPath(indexPath).enabled) return; 19065 if(!enabled) { 19066 if(this.GetSelectedItemIndexPath() == indexPath) 19067 this.DeselectItem(indexPath); 19068 } 19069 if(!initialization || !enabled) 19070 this.ChangeItemEnabledStateItems(indexPath, enabled); 19071 this.ChangeItemEnabledAttributes(indexPath, enabled); 19072 if(enabled) { 19073 if(this.GetSelectedItemIndexPath() == indexPath) 19074 this.SelectItem(indexPath); 19075 } 19076 }, 19077 ChangeItemEnabledStateItems: function(indexPath, enabled) { 19078 if(!this.IsStateControllerEnabled()) return; 19079 var element = this.GetItemElement(indexPath); 19080 if(element) 19081 ASPx.GetStateController().SetElementEnabled(element, enabled); 19082 }, 19083 GetItemImageUrl: function(indexPath) { 19084 var image = this.GetItemImage(indexPath); 19085 if(image) 19086 return image.src; 19087 return ""; 19088 }, 19089 SetItemImageUrl: function(indexPath, url) { 19090 var image = this.GetItemImage(indexPath); 19091 if(image) 19092 image.src = url; 19093 }, 19094 AddItemImageClassName: function(indexPath, className) { 19095 var image = this.GetItemImage(indexPath); 19096 if(image) { 19097 var accessibilityElement = image.parentNode; 19098 if(accessibilityElement.tagName == "SPAN") 19099 ASPx.AddClassNameToElement(accessibilityElement, className); 19100 else 19101 ASPx.AddClassNameToElement(image, className); 19102 } 19103 else {
19104 var svgElement = this.getSvgElement(indexPath); 19105 if(svgElement) { 19106 ASPx.AddClassNameToElement(svgElement, className); 19107 var useElement = ASPx.GetNodeByTagName(svgElement, "use", 0); 19108 useElement.setAttributeNS('http://www.w3.org/1999/xlink', 'href', "#" + className); 19109 } 19110 } 19111 }, 19112 AddItemAdditionalImageClassName: function(indexPath) { 19113 }, 19114 getSvgElement: function(indexPath) { 19115 var element = this.GetItemContentElement(indexPath); 19116 if(element != null) { 19117 var svgElement = ASPx.GetNodeByTagName(element, "svg", 0); 19118 if(svgElement != null) { 19119 return svgElement; 19120 } 19121 } 19122 }, 19123 GetItemImage: function(indexPath) { 19124 var element = this.GetItemContentElement(indexPath); 19125 if(element != null) { 19126 var img = ASPx.GetNodeByTagName(element, "IMG", 0); 19127 if(img != null) 19128 return img; 19129 } 19130 }, 19131 GetItemNavigateUrl: function(indexPath) { 19132 var element = this.GetItemContentElement(indexPath); 19133 if(element != null && element.tagName === "A") 19134 return ASPx.Attr.GetAttribute(element, "savedhref") || element.href; 19135 if(element != null) { 19136 var link = ASPx.GetNodeByTagName(element, "A", 0); 19137 if(link != null) 19138 return ASPx.Attr.GetAttribute(link, "savedhref") || link.href; 19139 } 19140 return ""; 19141 }, 19142 SetUrl: function(link, url, target) { 19143 if(link != null) { 19144 if(ASPx.Attr.IsExistsAttribute(link, "savedhref")) 19145 ASPx.Attr.SetAttribute(link, "savedhref", url); 19146 else if(ASPx.Attr.IsExistsAttribute(link, "href")) 19147 link.href = url; 19148 if(!!target) 19149 link.target = target; 19150 } 19151 }, 19152 SetItemNavigateUrl: function(indexPath, url, target) { 19153 var element = this.GetItemContentElement(indexPath); 19154 if(element != null) { 19155 if(element.tagName === "A") 19156 this.SetUrl(element, url, target); 19157 else { 19158 this.SetUrl(ASPx.GetNodeByTagName(element, "A", 0), url, target); 19159 this.SetUrl(ASPx.GetNodeByTagName(element, "A", 1), url, target); 19160 } 19161 } 19162 }, 19163 FindTextNode: function(indexPath) { 19164 var contentElement = this.GetItemContentElement(indexPath); 19165 if(contentElement) { 19166 var link = this.GetLinkElementByIndexPath(indexPath); 19167 if(link) 19168 return ASPx.GetNormalizedTextNode(link); 19169 var textElement = this.GetContentTextElement(contentElement); 19170 if(textElement) 19171 return ASPx.GetNormalizedTextNode(textElement); 19172 return ASPx.GetNormalizedTextNode(contentElement); 19173 } 19174 return null; 19175 }, 19176 GetContentTextElement: function(contentElement) { 19177 return ASPx.GetChildByClassName(contentElement, MenuCssClasses.ItemTextElement, 0); 19178 }, 19179 GetItemText: function(indexPath) { 19180 var textNode = this.FindTextNode(indexPath); 19181 return textNode 19182 ? ASPx.Str.Trim(textNode.nodeValue) 19183 : ""; 19184 }, 19185 SetItemText: function(indexPath, text) { 19186 var textNode = this.FindTextNode(indexPath); 19187 if(textNode) { 19188 textNode.nodeValue = text; 19189 var menuElement = this.GetMenuElement(this.GetParentIndexPath(indexPath)); 19190 if(menuElement && (!this.IsRootItem(indexPath) || this.isPopupMenu)) 19191 this.renderHelper.CalculateSubMenu(menuElement, true); 19192 if(this.IsRootItem(indexPath) && !this.isPopupMenu) { 19193 var itemElement = this.GetItemElement(indexPath); 19194 if(itemElement) 19195 this.renderHelper.CalculateItemMinSize(itemElement, true); 19196 } 19197 this.AdjustControl(); 19198 } 19199 }, 19200 SetItemTextTemplate: function(indexPath, textTemplate) { 19201 var contentElement = this.GetItemContentElement(indexPath); 19202 var textElement = this.GetContentTextElement(contentElement); 19203 if(textElement) { 19204 var container = document.createElement("DIV"); 19205 container.innerHTML = textTemplate; 19206 contentElement.replaceChild(container.firstChild, textElement); 19207 } 19208 }, 19209 SetItemTooltip: function(indexPath, tooltip) { 19210 var itemElement = this.GetItemElement(indexPath); 19211 if(itemElement && tooltip) 19212 itemElement.title = tooltip; 19213 }, 19214 SetItemVisible: function(indexPath, visible, initialization) { 19215 var item = this.GetItemByIndexPath(indexPath); 19216 if(indexPath == "" || !item.visible) return; 19217 if(visible && initialization) return; 19218 var element = this.GetItemElement(indexPath); 19219 if(element != null) 19220 this.SetElementDisplay(element, visible); 19221 this.SetIndentsVisiblility(indexPath); 19222 var parentIndexPath = this.GetParentIndexPath(indexPath); 19223 if(this.isPopupMenu && this.inPopUpHandler) 19224 this.postponeSetItemVisible(parentIndexPath); 19225 else 19226 this.SetSeparatorsVisiblility(parentIndexPath); 19227 if(!this.IsItemInAdaptiveMenu(item))
19228 this.UpdateItemCssClasses(indexPath, visible); 19229 var parent = this.GetItemByIndexPath(indexPath).parent; 19230 var parentHasVisibleItems = this.HasVisibleItems(parent); 19231 if(this.IsRootItem(indexPath) && !this.isPopupMenu) { 19232 if(this.clientVisible) 19233 this.SetElementDisplay(this.GetMainElement(), parentHasVisibleItems); 19234 } 19235 else 19236 this.SetPopOutElementVisible(parent.indexPath, parentHasVisibleItems); 19237 if(this.GetMenuLevel(parentIndexPath) !== 0 || this.isPopupMenu && !this.inPopUpHandler) 19238 this.calculateSubMenuByIndexPath(parentIndexPath); 19239 if(this.IsRootItem(indexPath) && !this.isPopupMenu) 19240 this.renderHelper.CalculateMenuControl(this.GetMainElement(), true); 19241 }, 19242 SetElementDisplay: function (element, visible) { 19243 ASPx.SetElementDisplay(element, visible); 19244 }, 19245 prepareSideMenuCssClasses: function(addClass) { 19246 if(this.sideMenuModeOn) { 19247 this.MarkPrecedingItemCore(this.GetSelectedItemIndexPath(), PRE_SELECTED_ELEMENT_CLASS_NAME, addClass, false); 19248 if(this.hoverItemName) 19249 this.MarkPrecedingItemCore(this.hoverItemName, PRE_HOVERED_ELEMENT_CLASS_NAME, addClass, true); 19250 } 19251 }, 19252 calculateSubMenuByIndexPath: function(indexPath) { 19253 var menuElement = this.GetMenuElement(indexPath); 19254 if(menuElement) 19255 this.renderHelper.CalculateSubMenu(menuElement, true); 19256 }, 19257 postponeSetItemVisible: function(indexPath) { 19258 if(!this.postponedIndexPath) 19259 this.postponedIndexPath = []; 19260 for(var i = 0; i < this.postponedIndexPath.length; i++) { 19261 if(this.postponedIndexPath[i] === indexPath) 19262 return; 19263 } 19264 this.postponedIndexPath.push(indexPath); 19265 }, 19266 postponedSetItemVisible: function() { 19267 if(!!this.postponedIndexPath && this.postponedIndexPath.length > 0) 19268 ASPx.Data.ForEach(this.postponedIndexPath, function(indexPath) { 19269 this.SetSeparatorsVisiblility(indexPath); 19270 this.calculateSubMenuByIndexPath(indexPath); 19271 }.aspxBind(this)); 19272 this.postponedIndexPath = []; 19273 }, 19274 SetIndentsVisiblility: function(indexPath) { 19275 var parent = this.GetItemByIndexPath(indexPath).parent; 19276 for(var i = 0; i < parent.GetItemCount(); i++) { 19277 var item = parent.GetItem(i); 19278 var separatorVisible = this.HasPrevVisibleItems(parent, i) && item.GetVisible(); 19279 var element = this.GetItemIndentElement(item.GetIndexPath()); 19280 if(element != null) ASPx.SetElementDisplay(element, separatorVisible); 19281 } 19282 }, 19283 SetSeparatorsVisiblility: function(indexPath) { 19284 var parent = this.GetItemByIndexPath(indexPath); 19285 for(var i = 0; i < parent.GetItemCount(); i++) { 19286 var item = parent.GetItem(i); 19287 var separatorVisible = this.HasPrevVisibleItems(parent, i) && (item.GetVisible() || this.HasNextVisibleItemInGroup(parent, i)); 19288 var element = this.GetItemSeparatorElement(item.GetIndexPath()); 19289 if(element != null) ASPx.SetElementDisplay(element, separatorVisible); 19290 } 19291 }, 19292 UpdateItemCssClasses: function(indexPath, visible) { 19293 }, 19294 SetPopOutElementVisible: function(indexPath, visible) { 19295 var popOutElement = this.GetItemPopOutElement(indexPath); 19296 if(popOutElement) 19297 popOutElement.style.display = visible ? 'block' : 'none'; 19298 }, 19299 GetPrevVisibleItemInGroup: function(parent, index, skipItemsInAdaptiveMenu) { 19300 if(this.IsItemBeginsGroup(parent.GetItem(index))) 19301 return null; 19302 for(var i = index - 1; i >= 0; i--) { 19303 var item = parent.GetItem(i); 19304 if(item.GetVisible() && !this.IsAdaptiveItem(item.indexPath) && (!skipItemsInAdaptiveMenu || !this.IsItemInAdaptiveMenu(item))) 19305 return item; 19306 if(this.IsItemBeginsGroup(item)) 19307 return null; 19308 } 19309 return null; 19310 }, 19311 GetNextVisibleItemInGroup: function(parent, index, skipItemsInAdaptiveMenu) { 19312 for(var i = index + 1; i < parent.GetItemCount(); i++) { 19313 var item = parent.GetItem(i); 19314 if(this.IsItemBeginsGroup(item)) 19315 return null; 19316 if(item.GetVisible() && !this.IsAdaptiveItem(item.indexPath) && (!skipItemsInAdaptiveMenu || !this.IsItemInAdaptiveMenu(item))) 19317 return item; 19318 } 19319 return null; 19320 }, 19321 HasNextVisibleItemInGroup: function(parent, index, skipItemsInAdaptiveMenu) { 19322 return !!this.GetNextVisibleItemInGroup(parent, index, skipItemsInAdaptiveMenu); 19323 }, 19324 IsItemBeginsGroup: function(item) { 19325 var itemSeparator = this.GetItemSeparatorElement(item.GetIndexPath()); 19326 return itemSeparator && ASPx.ElementContainsCssClass(itemSeparator, this.get
19326SeparatorCssClass()); 19327 }, 19328 getSeparatorCssClass: function() { 19329 return MenuCssClasses.Separator; 19330 }, 19331 getAdaptiveMenuItemCssClass: function() { 19332 return MenuCssClasses.AdaptiveMenuItem; 19333 }, 19334 getAdaptiveMenuItemSpacingCssClass: function() { 19335 return MenuCssClasses.AdaptiveMenuItemSpacing; 19336 }, 19337 getAdaptiveMenuCssClass: function() { 19338 return MenuCssClasses.AdaptiveMenu; 19339 }, 19340 IsItemInAdaptiveMenu: function(item) { 19341 return this.enableAdaptivity ? this.renderHelper.IsItemInAdaptiveMenu(item.index) : false; 19342 }, 19343 HasVisibleItems: function(parent) { 19344 for(var i = 0; i < parent.GetItemCount() ; i++) { 19345 if(parent.GetItem(i).GetVisible()) 19346 return true; 19347 } 19348 return false; 19349 }, 19350 HasNextVisibleItems: function(parent, index, skipItemsInAdaptiveMenu) { 19351 for(var i = index + 1; i < parent.GetItemCount() ; i++) { 19352 var item = parent.GetItem(i); 19353 if(item.GetVisible() && (!skipItemsInAdaptiveMenu || !this.IsItemInAdaptiveMenu(item))) 19354 return true; 19355 } 19356 return false; 19357 }, 19358 HasPrevVisibleItems: function(parent, index, skipItemsInAdaptiveMenu) { 19359 for(var i = index - 1; i >= 0; i--) { 19360 var item = parent.GetItem(i); 19361 if(item.GetVisible() && (!skipItemsInAdaptiveMenu || !this.IsItemInAdaptiveMenu(item))) 19362 return true; 19363 } 19364 return false; 19365 }, 19366 NeedCollapseControlCore: function() { 19367 return this.enableAdaptivity || ASPxClientControl.prototype.NeedCollapseControlCore.call(this); 19368 }, 19369 GetItemIndentElement: function(indexPath) { 19370 return ASPx.GetElementById(this.GetItemIndentElementId(indexPath)); 19371 }, 19372 GetItemSeparatorElement: function(indexPath) { 19373 return ASPx.GetElementById(this.GetItemSeparatorElementId(indexPath)); 19374 }, 19375 CreateItemClickEventArgs: function(processOnServer, item, htmlElement, htmlEvent) { 19376 return new ASPxClientMenuItemClickEventArgs(processOnServer, item, htmlElement, htmlEvent); 19377 }, 19378 CreateItemMouseEventArgs: function(item, htmlElement) { 19379 return new ASPxClientMenuItemMouseEventArgs(item, htmlElement); 19380 }, 19381 CreateItemEventArgs: function(item) { 19382 return new ASPxClientMenuItemEventArgs(item); 19383 }, 19384 RaiseItemClick: function(indexPath, htmlEvent) { 19385 var processOnServer = this.autoPostBack || this.IsServerEventAssigned("ItemClick"); 19386 if(!this.ItemClick.IsEmpty()) { 19387 var item = this.GetItemByIndexPath(indexPath); 19388 var htmlElement = this.GetItemElement(indexPath); 19389 var args = this.CreateItemClickEventArgs(processOnServer, item, htmlElement, htmlEvent); 19390 this.ItemClick.FireEvent(this, args); 19391 processOnServer = args.processOnServer; 19392 } 19393 return processOnServer; 19394 }, 19395 RaiseItemMouseOver: function(indexPath) { 19396 if(!this.ItemMouseOver.IsEmpty()) { 19397 var item = this.GetItemByIndexPath(indexPath); 19398 var htmlElement = this.GetItemContentElement(indexPath); 19399 var args = this.CreateItemMouseEventArgs(item, htmlElement); 19400 this.ItemMouseOver.FireEvent(this, args); 19401 } 19402 }, 19403 RaiseItemMouseOut: function(indexPath) { 19404 if(!this.ItemMouseOut.IsEmpty()) { 19405 var item = this.GetItemByIndexPath(indexPath); 19406 var htmlElement = this.GetItemContentElement(indexPath); 19407 var args = this.CreateItemMouseEventArgs(item, htmlElement); 19408 this.ItemMouseOut.FireEvent(this, args); 19409 } 19410 }, 19411 RaisePopUp: function(indexPath) { 19412 var item = this.GetItemByIndexPath(indexPath); 19413 if(!this.PopUp.IsEmpty()) { 19414 var args = this.CreateItemEventArgs(item); 19415 this.inPopUpHandler = true; 19416 this.PopUp.FireEvent(this, args); 19417 this.inPopUpHandler = false; 19418 this.postponedSetItemVisible(); 19419 } 19420 }, 19421 RaiseCloseUp: function(indexPath) { 19422 var item = this.GetItemByIndexPath(indexPath); 19423 if(!this.CloseUp.IsEmpty()) { 19424 var args = this.CreateItemEventArgs(item); 19425 this.CloseUp.FireEvent(this, args); 19426 } 19427 }, 19428 SetEnabled: function(enabled) { 19429 for(var i = this.GetItemCount() - 1; i >= 0; i--) { 19430 var item = this.GetItem(i); 19431 item.SetEnabled(enabled); 19432 } 19433 }, 19434 SetVisible: function(visible) { 19435 ASPxClientControl.prototype.SetVisible.call(this, visible); 19436 if(visible && !this.HasVisibleItems(this)) 19437 ASPx.SetElementDisplay(this.GetMainElement(), false); 19438 }, 19439 GetItemCount: function() { 19440 return (this.rootItem != null) ? this.rootItem.GetItemCount() : 0; 19441 }, 19442 GetItem: function(index) { 19443 return (this.rootItem != null) ? this.rootItem.GetItem(index) : null; 19444 }, 19445 GetItemByName: function(name) { 19446 return (this.rootItem != null) ? this.rootItem.GetItemByName(name) : null; 19447 }, 19448 GetSelectedItem: function() { 19449 var indexPath = this.GetSelectedItemIndexPath(); 19450 if(indexPath != "") 19451 return this.GetItemByIndexPath(indexPath); 19452 return null; 19453 }, 19454 SetSelectedItem: function(item) { 19455 var indexPath = (item != null) ? item.GetIndexPath() : ""; 19456 this.SetSelectedItemInternal(indexPath, false); 19457 }, 19458 GetRootItem: function() { 19459 return this.rootItem; 19460 } 19461}); 19462ASPxClientMenuBase.GetMenuCollection = function() { 19463 return aspxGetMenuCollection(); 19464}; 19465var ASPxMenuKeyboardHelper = ASPx.CreateClass(null, { 19466 constructor: function(menu) { 19467 this.menu = menu; 19468 this.accessibilityCompliant = menu.accessibilityCompliant; 19469 this.isContextMenu = menu.isContextMenu; 19470 this.rtl = menu.rtl; 19471 }, 19472 OnFocusedItemKeyDown: function(evt, focusedItem) { 19473 var indexPath = this.menu.GetItemIndexPathById(focusedItem.name); 19474 if(!this.IsAllowedItemAction(evt, focusedItem.enabled, indexPath)) 19475 ASPx.Evt.PreventEventAndBubble(evt); 19476 else 19477 this.OnFocusedItemKeyDownInternal(evt, indexPath); 19478 }, 19479 OnFocusedItemKeyDownInternal: function(evt, indexPath) { 19480 if(!indexPath) 19481 return; 19482 var keyKode = ASPx.Evt.GetKeyCode(evt); 19483 switch (keyKode) { 19484 case ASPx.Key.Tab: 19485 this.OnTab(indexPath, evt); 19486 break; 19487 case ASPx.Key.Down: 19488 this.OnArrowDown(indexPath, evt); 19489 break; 19490 case ASPx.Key.Up: 19491 this.OnArrowUp(indexPath, evt); 19492 break; 19493 case ASPx.Key.Left: 19494 if(this.rtl) 19495 this.OnArrowRight(indexPath, evt); 19496 else 19497 this.OnArrowLeft(indexPath, evt); 19498 break; 19499 case ASPx.Key.Right: 19500 if(this.rtl) 19501 this.OnArrowLeft(indexPath, evt); 19502 else 19503 this.OnArrowRight(indexPath, evt); 19504 break; 19505 case ASPx.Key.Esc: 19506 this.OnEscape(indexPath, evt); 19507 break; 19508 case ASPx.Key.Space: break; 19509 case ASPx.Key.Enter: break; 19510 case ASPx.Key.Shift: break; 19511 case ASPx.Key.Alt: break; 19512 case ASPx.Key.Ctrl: break; 19513 default: 19514 ASPx.Evt.PreventEventAndBubble(evt); 19515 break; 19516 } 19517 }, 19518 OnTab: function(indexPath, evt) {
19519 var isRootItem = this.IsRootItem(indexPath); 19520 if(isRootItem && !this.accessibilityCompliant) return; 19521 if(this.IsLostFocus(indexPath, evt)) 19522 this.menu.ProcessLostFocus(evt); 19523 else 19524 this.ProcessTab(indexPath, evt); 19525 }, 19526 ProcessTab: function(indexPath, evt) { 19527 if(this.IsRootItem(indexPath)) 19528 this.FocusRootItem(indexPath, evt); 19529 else 19530 this.FocusSubmenuItem(indexPath, evt); 19531 }, 19532 OnArrowDown: function(indexPath, evt) { 19533 if(this.menu.IsVertical(indexPath)) 19534 this.FocusNextItem(indexPath); 19535 else 19536 this.ShowSubMenuAccessible(indexPath); 19537 ASPx.Evt.PreventEventAndBubble(evt); 19538 }, 19539 OnArrowUp: function(indexPath, evt) { 19540 if(this.menu.IsVertical(indexPath)) 19541 this.FocusPrevItem(indexPath); 19542 else 19543 this.ShowSubMenuAccessible(indexPath); 19544 ASPx.Evt.PreventEventAndBubble(evt); 19545 }, 19546 OnArrowLeft: function(indexPath, evt) { 19547 var isVertical = this.menu.IsVertical(indexPath); 19548 if(isVertical) { 19549 var isRootItem = this.IsRootItem(indexPath); 19550 if(isRootItem) 19551 this.FocusPrevItem(indexPath); 19552 else 19553 this.FocusItemByIndexPathAccessible(this.GetLeftParentIndexPath(indexPath)); 19554 } else 19555 this.FocusPrevItem(indexPath); 19556 ASPx.Evt.PreventEventAndBubble(evt); 19557 }, 19558 OnArrowRight: function(indexPath, evt) { 19559 var isVertical = this.menu.IsVertical(indexPath); 19560 if(isVertical) { 19561 var hasChildren = this.menu.HasChildren(indexPath); 19562 if(hasChildren) 19563 this.ShowSubMenuAccessible(indexPath); 19564 else 19565 this.FocusItemByIndexPathAccessible(this.GetRightRootParentIndexPath(indexPath)); 19566 } 19567 else 19568 this.FocusNextItem(indexPath); 19569 ASPx.Evt.PreventEventAndBubble(evt); 19570 }, 19571 OnEscape: function(indexPath, evt) { 19572 var needPreventEvent = true; 19573 if(this.IsRootItem(indexPath)) { 19574 aspxGetMenuCollection().DoHidePopupMenus(null, -1, this.name, false, ""); 19575 this.menu.ProcessLostFocus(evt); 19576 } 19577 else { 19578 var parentIndexPath = this.menu.GetParentIndexPath(indexPath); 19579 this.FocusItemByIndexPathAccessible(parentIndexPath); 19580 var element = this.menu.GetMenuElement(parentIndexPath); 19581 if(element != null) 19582 this.menu.DoHidePopupMenu(null, element); 19583 else 19584 needPreventEvent = false; 19585 } 19586 if(needPreventEvent) 19587 ASPx.Evt.PreventEventAndBubble(evt); 19588 }, 19589 IsLostFocus: function(indexPath, evt) { 19590 var keyCode = ASPx.Evt.GetKeyCode(evt); 19591 var isRootItem = this.IsRootItem(indexPath); 19592 if(keyCode !== ASPx.Key.Tab || !isRootItem) 19593 return false; 19594 var canPrevItemGetFocus = evt.shiftKey && this.GetPrevSiblingIndexPath(indexPath); 19595 var canNextItemGetFocus = !evt.shiftKey && this.GetNextSiblingIndexPath(indexPath); 19596 return !canPrevItemGetFocus && !canNextItemGetFocus; 19597 }, 19598 FocusRootItem: function(indexPath, evt) { 19599 if(evt.shiftKey) 19600 this.FocusPrevItem(indexPath, evt); 19601 else 19602 this.FocusNextItem(indexPath, evt); 19603 var isFocusElementChanged = ASPx.Evt.GetEventSource(evt) !== document.activeElement; 19604 if(isFocusElementChanged) 19605 ASPx.Evt.PreventEventAndBubble(evt); 19606 }, 19607 FocusSubmenuItem: function(indexPath, evt) { 19608 if(evt.shiftKey) 19609 this.FocusPreviousSubmenuItem(indexPath, evt); 19610 else 19611 this.FocusNextSubmenuItem(indexPath, evt); 19612 }, 19613 FocusPreviousSubmenuItem: function(indexPath, evt) { 19614 if(!this.GetPrevSiblingIndexPath(indexPath)) { 19615 var parentIndexPath = this.menu.GetParentIndexPath(indexPath); 19616 this.FocusItemByIndexPathAccessible(parentIndexPath); 19617 } else 19618 this.FocusPrevItem(indexPath); 19619 ASPx.Evt.PreventEventAndBubble(evt); 19620 }, 19621 FocusNextSubmenuItem: function(indexPath, evt) { 19622 var nextIndexPath = this.GetNextIndexPath(indexPath); 19623 if(nextIndexPath) { 19624 var isLevelChanged = this.IsLevelChanged(indexPath, nextIndexPath); 19625 this.FocusItemCore(nextIndexPath, isLevelChanged); 19626 ASPx.Evt.PreventEventAndBubble(evt); 19627 } else 19628 this.menu.ProcessLostFocus(evt); 19629 }, 19630 GetNextIndexPath: function(indexPath) { 19631 var result = this.GetNextSiblingIndexPath(indexPath); 19632 if(!result) { 19633 var parentIndexPath = this.menu.GetParentIndexPath(indexPath); 19634 if(parentIndexPath) 19635 result = this.GetNextIndexPath(parentIndexPath); 19636 } 19637 return result; 19638 }, 19639 GetRightRootParentIndexPath: function(indexPath) { 19640 var parentIndexPath = this.GetParentRootIndexPath(indexPath); 19641 return this.GetNextFocusableItemIndexPath(parentIndexPath); 19642 }, 19643 GetLeftParentIndexPath: function(indexPath) { 19644 var parentIndexPath = this.menu.GetParentIndexPath(indexPath); 19645 if(!this.menu.IsVertical(parentIndexPath)) 19646 parentIndexPath = this.GetPrevFocusableItemIndexPath(parentIndexPath); 19647 return parentIndexPath; 19648 }, 19649 GetParentRootIndexPath: function(indexPath) { 19650 while(!this.IsRootItem(indexPath)) 19651 indexPath = this.menu.GetParentIndexPath(indexPath); 19652 return indexPath; 19653 }, 19654 ShowSubMenuAccessible: function(indexPath) { 19655 var newIndexPath = this.GetFirstChildIndexPath(indexPath), 19656 element = this.menu.GetMenuElement(indexPath); 19657 if(element && !this.menu.isSubMenuElementVisible(element)) 19658 this.menu.ShowSubMenu(indexPath); 19659 if(!!newIndexPath) 19660 this.FocusItemByIndexPathAccessible(newIndexPath); 19661 }, 19662 FocusItemByIndexPathAccessible: function(indexPath) { 19663 this.FocusItemCore(indexPath, true); 19664 }, 19665 IsAllowedItemAction: function(evt, isEnabled, indexPath) { 19666 var isVertical = this.menu.IsVertical(indexPath); 19667 return !this.accessibilityCompliant || 19668 isEnabled || 19669 this.IsAllowedFocusMoving(evt) || 19670 this.IsAllowedHorizontalFocusMoving(evt, isVertical) || 19671 this.IsAllowedVerticalFocusMoving(evt, isVertical); 19672 }, 19673 IsAllowedFocusMoving: function(evt) { 19674 return evt.keyCode == ASPx.Key.Tab || evt.keyCode == ASPx.Key.Esc; 19675 }, 19676 IsAllowedHorizontalFocusMoving: function(evt, isVertical) { 19677 return !isVertical && (evt.keyCode == ASPx.Key.Left || evt.keyCode == ASPx.Key.Right); 19678 }, 19679 IsAllowedVerticalFocusMoving: function(evt, isVertical) { 19680 return isVertical && (evt.keyCode == ASPx.Key.Up || evt.keyCode == ASPx.Key.Down); 19681 }, 19682 FocusItemByIndexPath: function(indexPath) { 19683 var link = this.menu.GetLinkElementByIndexPath(indexPath); 19684 if(link != null) { 19685 if(this.accessibilityCompliant && !link.href) 19686 link.href = ASPx.AccessibilityEmptyUrl; 19687 ASPx.SetFocus(link); 19688 } else 19689 this.FocusTemplateItemActionElement(indexPath); 19690 }, 19691 FocusTemplateItemActionElement: function(indexPath) { 19692 var element = this.menu.GetItemElement(indexPath); 19693 var focusableElement = ASPx.FindFirstChildActionElement(element); 19694 if(focusableElement) 19695 ASPx.SetFocus(focusableElement); 19696 else { 19697 var parentIndexPath = this.menu.GetParentIndexPath(indexPath); 19698 this.tryFocusColorPickerByIndexPath(parentIndexPath); 19699 } 19700 }, 19701 tryFocusColorPickerByIndexPath: function(indexPath) { 19702 var colorPicker = this.getColorPickerByIndexPath(indexPath); 19703 if(colorPicker) 19704 colorPicker.Focus(); 19705 }, 19706 getColorPickerByIndexPath: function(indexPath) { 19707 var menuItem = this.menu.GetItemByIndexPath(indexPath); 19708 return menuItem.colorPicker; 19709 }, 19710 PronounceItemDescription: function(indexPath) { 19711 var link = this.menu.GetLinkElementByIndexPath(indexPath); 19712 var span = ASPx.GetNodeByTagName(link, "SPAN", 0); 19713 if(!link) return; 19714 if(!!span && !span.id) { 19715 var spanID = this.GetAccessibilityTextSpanID(indexPath); 19716 span.id = spanID; 19717 ASPx.Attr.SetAttribute(link, "aria-describedby", spanID); 19718 } 19719 ASPx.Attr.SetAttribute(link, "aria-label", this.GetAccessibilityItemDescription(indexPath)); 19720 }, 19721 RemoveAccessibilityDescription: function(indexPath) { 19722 var link = this.menu.GetLinkElementByIndexPath(indexPath); 19723 if(link && ASPx.Attr.GetAttribute(link, "aria-label")) 19724 ASPx.Attr.RemoveAttribute(link, "aria-label"); 19725 }, 19726 GetAccessibilityTextSpanID: function(indexPath) { 19727 return this.name + Constants.ATSIdSuffix + indexPath; 19728 }, 19729 GetAccessibilityItemDescription: function(indexPath) { 19730 var descriptionParts = []; 19731 descriptionParts.push(this.menu.IsVertical(indexPath) ? ASPx.AccessibilitySR.MenuVerticalText : ASPx.AccessibilitySR.MenuHorizontalText); 19732 descriptionParts.push(this.IsRootItem(indexPath) ? ASPx.AccessibilitySR.MenuBarText : ASPx.AccessibilitySR.MenuText); 19733 descriptionParts.push(this.menu.GetMenuLevel(indexPath)); 19734 descriptionParts.push(ASPx.AccessibilitySR.MenuLevelText); 19735 return descriptionParts.join(' '); 19736 }, 19737 FocusNextItem: function(indexPath) { 19738 var newIndexPath = this.GetNextFocusableItemIndexPath(indexPath); 19739 if(newIndexPath) 19740 this.FocusItemCore(newIndexPath, false); 19741 }, 19742 FocusPrevItem: function(indexPath) { 19743 var newIndexPath = this.GetPrevFocusableItemIndexPath(indexPath); 19744 if(newIndexPath) 19745 this.FocusItemCore(newIndexPath, false); 19746 }, 19747 FocusItemCore: function(indexPath, needDescription) { 19748 if(this.accessibilityCompliant) { 19749 if(needDescription) 19750 this.PronounceItemDescription(indexPath); 19751 else 19752 this.RemoveAccessibilityDescription(indexPath); 19753 } 19754 this.FocusItemByIndexPath(indexPath); 19755 }, 19756 GetNextFocusableItemIndexPath: function(indexPath) { 19757 var newIndexPath = this.GetNextSiblingIndexPath(indexPath); 19758 if(newIndexPath == null) 19759 newIndexPath = this.GetFirstSiblingIndexPath(indexPath); 19760 if(indexPath != newIndexPath) 19761 return newIndexPath; 19762 }, 19763 GetPrevFocusableItemIndexPath: function(indexPath) { 19764 var newIndexPath = this.GetPrevSiblingIndexPath(indexPath); 19765 if(newIndexPath == null) 19766 newIndexPath = this.GetLastSiblingIndexPath(indexPath); 19767 if(indexPath != newIndexPath) 19768 return newIndexPath; 19769 }, 19770 GetFirstChildIndexPath: function(indexPath) { 19771 var indexes = this.menu.GetItemIndexes(indexPath); 19772 indexes[indexes.length] = 0;
19773 var newIndexPath = this.menu.GetItemIndexPath(indexes); 19774 return this.GetFirstSiblingIndexPath(newIndexPath); 19775 }, 19776 GetFirstSiblingIndexPath: function(indexPath) { 19777 var indexes = this.menu.GetItemIndexes(indexPath); 19778 var i = 0; 19779 while(true) { 19780 indexes[indexes.length - 1] = i; 19781 var newIndexPath = this.menu.GetItemIndexPath(indexes); 19782 if(!this.IsItemExist(newIndexPath)) 19783 return null; 19784 if(this.IsFocusableItem(newIndexPath)) 19785 return newIndexPath; 19786 i++; 19787 } 19788 return null; 19789 }, 19790 GetLastSiblingIndexPath: function(indexPath) { 19791 var indexes = this.menu.GetItemIndexes(indexPath); 19792 var parentItem = this.menu.GetItemByIndexPath(this.menu.GetParentIndexPath(indexPath)); 19793 var i = parentItem ? parentItem.GetItemCount() - 1 : 0; 19794 while(true) { 19795 indexes[indexes.length - 1] = i; 19796 var newIndexPath = this.menu.GetItemIndexPath(indexes); 19797 if(!this.IsItemExist(newIndexPath)) 19798 return null; 19799 if(this.IsFocusableItem(newIndexPath)) 19800 return newIndexPath; 19801 i--; 19802 } 19803 return null; 19804 }, 19805 GetNextSiblingIndexPath: function(indexPath) { 19806 if(this.menu.IsLastItem(indexPath)) return null; 19807 var indexes = this.menu.GetItemIndexes(indexPath); 19808 var i = indexes[indexes.length - 1] + 1; 19809 while(true) { 19810 indexes[indexes.length - 1] = i; 19811 var newIndexPath = this.menu.GetItemIndexPath(indexes); 19812 if(!this.IsItemExist(newIndexPath)) 19813 return null; 19814 if(this.IsFocusableItem(newIndexPath)) 19815 return newIndexPath; 19816 i++; 19817 } 19818 return null; 19819 }, 19820 GetPrevSiblingIndexPath: function(indexPath) { 19821 if(this.menu.IsFirstItem(indexPath)) return null; 19822 var indexes = this.menu.GetItemIndexes(indexPath); 19823 var i = indexes[indexes.length - 1] - 1; 19824 while(true) { 19825 indexes[indexes.length - 1] = i; 19826 var newIndexPath = this.menu.GetItemIndexPath(indexes); 19827 if(!this.IsItemExist(newIndexPath)) 19828 return null; 19829 if(this.IsFocusableItem(newIndexPath)) 19830 return newIndexPath; 19831 i--; 19832 } 19833 return null; 19834 }, 19835 IsItemExist: function(indexPath) { 19836 return !!this.menu.GetItemByIndexPath(indexPath); 19837 }, 19838 IsItemVisible: function(indexPath) { 19839 var item = this.menu.GetItemByIndexPath(indexPath); 19840 return item ? item.GetVisible() : false; 19841 }, 19842 IsFocusableItem: function(indexPath) { 19843 return this.IsItemVisible(indexPath) && (this.menu.IsItemEnabled(indexPath) || this.IsItemAccessibleEnabled(indexPath)); 19844 }, 19845 IsRootItem: function(indexPath) { 19846 return this.menu.IsRootItem(indexPath); 19847 }, 19848 IsItemAccessibleEnabled: function(indexPath) { 19849 var item = this.menu.GetItemByIndexPath(indexPath); 19850 return this.accessibilityCompliant && item && item.enabled; 19851 }, 19852 IsLevelChanged: function(firstIndexPath, secondIndexPath) { 19853 return this.menu.GetMenuLevel(firstIndexPath) !== this.menu.GetMenuLevel(secondIndexPath); 19854 } 19855}); 19856var ASPxClientMenuCollection = ASPx.CreateClass(ASPxClientControlCollection, { 19857 constructor: function() { 19858 this.constructor.prototype.constructor.call(this); 19859 this.appearTimerID = -1; 19860 this.disappearTimerID = -1; 19861 this.currentShowingPopupMenuName = null; 19862 this.visibleSubMenusMenuName = ""; 19863 this.visibleSubMenuIds = []; 19864 this.overXPos = -1; 19865 this.overYPos = -1; 19866 }, 19867 GetCollectionType: function(){ 19868 return "Menu"; 19869 }, 19870 Remove: function(element) { 19871 if(element.name === this.visibleSubMenusMenuName) { 19872 this.visibleSubMenusMenuName = ""; 19873 this.visibleSubMenuIds = [ ]; 19874 } 19875 ASPxClientControlCollection.prototype.Remove.call(this, element); 19876 }, 19877 RegisterVisiblePopupMenu: function(name, id) { 19878 this.visibleSubMenuIds.push(id); 19879 this.visibleSubMenusMenuName = name; 19880 }, 19881 UnregisterVisiblePopupMenu: function(name, id) { 19882 ASPx.Data.ArrayRemove(this.visibleSubMenuIds, id); 19883 if(this.visibleSubMenuIds.length == 0) 19884 this.visibleSubMenusMenuName = ""; 19885 }, 19886 IsSubMenuVisible: function(subMenuId) { 19887 for(var i = 0; i < this.visibleSubMenuIds.length; i++) { 19888 if(this.visibleSubMenuIds[i] == subMenuId) 19889 return true; 19890 } 19891 return false; 19892 }, 19893 GetMenu: function(id) { 19894 return this.Get(this.GetMenuName(id)); 19895 }, 19896 GetMenuName: function(id) { 19897 return this.GetMenuNameBySuffixes(id, [Constants.MMIdSuffix, Constants.MIIdSuffix]); 19898 }, 19899 GetMenuNameBySuffixes: function(id, idSuffixes) { 19900 for(var i = 0; i < idSuffixes.length; i++) { 19901 var pos = id.lastIndexOf(idSuffixes[i]); 19902 if(pos > -1) 19903 return id.substring(0, pos); 19904 } 19905 return id; 19906 }, 19907 ClearCurrentShowingPopupMenuName: function() { 19908 this.SetCurrentShowingPopupMenuName(null); 19909 }, 19910 SetCurrentShowingPopupMenuName: function(value) { 19911 this.currentShowingPopupMenuName = value; 19912 }, 19913 NowPopupMenuIsShowing: function() { 19914 return this.currentShowingPopupMenuName != null; 19915 }, 19916 GetMenuLevelById: function(id) { 19917 var indexPath = this.GetIndexPathById(id, Constants.MMIdSuffix); 19918 var menu = this.GetMenu(id); 19919 return menu.GetMenuLevel(indexPath); 19920 }, 19921 GetIndexPathById: function(id, idSuffix) { 19922 var pos = id.lastIndexOf(idSuffix); 19923 if(pos > -1) { 19924 id = id.substring(pos + idSuffix.length); 19925 pos = id.lastIndexOf("_"); 19926 if(pos > -1) 19927 return id.substring(0, pos); 19928 } 19929 return ""; 19930 },
19931 GetItemIndexPath: function(indexes) { 19932 var indexPath = ""; 19933 for(var i = 0; i < indexes.length; i++) { 19934 indexPath += indexes[i]; 19935 if(i < indexes.length - 1) 19936 indexPath += ASPx.ItemIndexSeparator; 19937 } 19938 return indexPath; 19939 }, 19940 GetItemIndexes: function(indexPath) { 19941 var indexes = indexPath.split(ASPx.ItemIndexSeparator); 19942 for(var i = 0; i < indexes.length; i++) 19943 indexes[i] = parseInt(indexes[i]); 19944 return indexes; 19945 }, 19946 ClearAppearTimer: function() { 19947 this.appearTimerID = ASPx.Timer.ClearTimer(this.appearTimerID); 19948 }, 19949 ClearDisappearTimer: function() { 19950 this.disappearTimerID = ASPx.Timer.ClearTimer(this.disappearTimerID); 19951 }, 19952 IsAppearTimerActive: function() { 19953 return this.appearTimerID > -1; 19954 }, 19955 IsDisappearTimerActive: function() { 19956 return this.disappearTimerID > -1; 19957 }, 19958 SetAppearTimer: function(name, indexPath, timeout, preventSubMenu) { 19959 var menu = aspxGetMenuCollection().Get(name); 19960 if(menu && !menu.sideMenuModeOn) 19961 this.appearTimerID = window.setTimeout(function() { 19962 var menu = aspxGetMenuCollection().Get(name); 19963 if(menu != null) menu.OnItemOverTimer(indexPath, preventSubMenu); 19964 }, timeout); 19965 }, 19966 SetDisappearTimer: function(name, timeout) { 19967 var menu = aspxGetMenuCollection().Get(name); 19968 if(menu && !menu.sideMenuModeOn) 19969 this.disappearTimerID = window.setTimeout(function() { 19970 var menu = aspxGetMenuCollection().Get(name); 19971 if(menu != null) 19972 menu.OnItemOutTimer(); 19973 }, timeout); 19974 }, 19975 GetMouseDownMenuLevel: function(evt) { 19976 var srcElement = ASPx.Evt.GetEventSource(evt); 19977 for(var i = this.visibleSubMenuIds.length - 1; i >= 0; i--) { 19978 var element = ASPx.GetParentById(srcElement, this.visibleSubMenuIds[i]); 19979 if(element != null) 19980 return this.GetMenuLevelById(this.visibleSubMenuIds[i]) + 1; 19981 } 19982 if(this.visibleSubMenusMenuName != "") { 19983 var element = ASPx.GetParentById(srcElement, this.visibleSubMenusMenuName); 19984 if(element != null) return 1; 19985 } 19986 if(ASPx.GetParentByClassName(srcElement, MenuCssClasses.AdaptiveMenuItem)) 19987 return 1; 19988 return -1; 19989 }, 19990 CheckFocusedElement: function() { 19991 var isValid = false; 19992 try { 19993 var activeElement = document.activeElement; 19994 if(activeElement != null) { 19995 for(var i = 0; i < this.visibleSubMenuIds.length; i++) { 19996 var menuElement = ASPx.GetElementById(this.visibleSubMenuIds[i]); 19997 if(menuElement != null && ASPx.GetIsParent(menuElement, activeElement)) { 19998 var tagName = activeElement.tagName; 19999 if(tagName != "A" || 20000 !ASPx.ElementHasCssClass(activeElement, MenuCssClasses.ContentContainer) || 20001 this.GetMenu(this.visibleSubMenusMenuName).accessibilityCompliant) 20002 isValid = true; 20003 break; 20004 } 20005 } 20006 } 20007 } catch (e) { 20008 } 20009 return isValid; 20010 }, 20011 LockMenusVisibility: function() { 20012 this.visibilityLocked = true; 20013 this.visibilityLockedIds = []; 20014 for(var i = this.visibleSubMenuIds.length - 1; i >= 0 ; i--) 20015 this.visibilityLockedIds.push(this.visibleSubMenuIds[i]); 20016 }, 20017 UnlockMenusVisibility: function() { 20018 this.visibilityLocked = false; 20019 this.visibilityLockedIds = []; 20020 }, 20021 CanHideSubMenu: function(subMenuId) { 20022 return !this.visibilityLocked || this.visibilityLocked && this.visibilityLockedIds.indexOf(subMenuId) > -1; 20023 }, 20024 DoHidePopupMenus: function(evt, level, name, leavePopups, exceptIds) { 20025 exceptIds = typeof exceptIds === 'string' ? [exceptIds] : (exceptIds || []); 20026 for(var i = this.visibleSubMenuIds.length - 1; i >= 0 ; i--) { 20027 var subMenuId = this.visibleSubMenuIds[i]; 20028 if(this.CanHideSubMenu(subMenuId)) { 20029 var menu = this.GetMenu(subMenuId); 20030 if(menu != null && !menu.sideMenuModeOn) { 20031 var menuLevel = this.GetMenuLevelById(subMenuId); 20032 if((!leavePopups || menuLevel > 0) && ASPx.Data.ArrayIndexOf(exceptIds, subMenuId) === -1) { 20033 if(menuLevel > level || (menu.name != name && name != "")) { 20034 var element = ASPx.GetElementById(subMenuId); 20035 if(element != null) 20036 menu.DoHidePopupMenu(evt, element); 20037 } 20038 } 20039 } 20040 } 20041 } 20042 }, 20043 DoShowAtCurrentPos: function(name, indexPath) { 20044 var pc = this.Get(name); 20045 var element = pc.GetMainElement(); 20046 if(pc != null && !ASPx.GetElementDisplay(element)) 20047 pc.DoShowPopupMenu(element, this.overXPos, this.overYPos, indexPath); 20048 }, 20049 SaveCurrentMouseOverPos: function(evt, popupElement) { 20050 if(!this.NowPopupMenuIsShowing()) return; 20051 var currentShowingPopupMenu = this.Get(this.currentShowingPopupMenuName); 20052 if(currentShowingPopupMenu.popupElement == popupElement) 20053 if(!currentShowingPopupMenu.IsMenuVisible()) { 20054 this.overXPos = ASPx.Evt.GetEventX(evt); 20055 this.overYPos = ASPx.Evt.GetEventY(evt); 20056 } 20057 }, 20058 OnMouseDown: function(evt) { 20059 var menuLevel = this.GetMouseDownMenuLevel(evt); 20060 this.DoHidePopupMenus(evt, menuLevel, "", false, ""); 20061 if (ASPx.Browser.TouchUI && menuLevel == -1) 20062 ASPx.SetHoverState(null); 20063 }, 20064 RecalculateAll: function() { 20065 var visibleSubMenusLength = this.visibleSubMenuIds.length; 20066 for(var i = 0; i < visibleSubMenusLength; i++) { 20067 var menu = this.GetMenu(this.visibleSubMenuIds[i]); 20068 if(menu != null) { 20069 var element = ASPx.GetElementById(this.visibleSubMenuIds[i]); 20070 if(element != null) { 20071 var indexPath = this.GetIndexPathById(this.visibleSubMenuIds[i], Constants.MMIdSuffix); 20072 menu.CalculateSubMenuPosition(element, ASPx.InvalidPosition, ASPx.InvalidPosition, indexPath, false); 20073 } 20074 } 20075 } 20076 }, 20077 HideAll: function() { 20078 this.DoHidePopupMenus(null, -1, "", false, ""); 20079 }, 20080 IsAnyMenuVisible: function() { 20081 return this.visibleSubMenuIds.length != 0; 20082 } 20083}); 20084var menuCollection = null; 20085function aspxGetMenuCollection() { 20086 if(menuCollection == null) 20087 menuCollection = new ASPxClientMenuCollection(); 20088 return menuCollection; 20089} 20090var ASPxClientMenuItem = ASPx.CreateClass(null, { 20091 constructor: function(menu, parent, index, name) { 20092 this.menu = menu; 20093 this.parent = parent; 20094 this.index = index; 20095 this.name = name; 20096 this.indexPath = ""; 20097 this.text = ""; 20098 this.imageUrl = ""; 20099 this.imageClassName = ""; 20100 this.tooltip = ""; 20101 this.target = ""; 20102 this.beginGroup = false; 20103 this.dropDownMode = false; 20104 if(parent) { 20105 this.indexPath = this.CreateItemIndexPath(parent); 20106 } 20107 this.enabled = true; 20108 this.clientEnabled = true; 20109 this.visible = true; 20110 this.clientVisible = true; 20111 this.items = []; 20112 this.colorPicker = null; 20113 this.checkedGroup = []; 20114 this.checked = false; 20115 }, 20116 CreateItemIndexPath: function(parent) { 20117 return parent.indexPath ? parent.indexPath + ASPx.ItemIndexSeparator + this.index.toString() : this.index.toString(); 20118 }, 20119 ClearRenderedChildItems: function() { 20120 if(this.items.length > 0) { 20121 var parentNode = this.menu.GetItemElement(this.items[0].indexPath).parentNode; 20122 parentNode.innerHTML = ""; 20123 this.items = []; 20124 } 20125 },
20126 CreateItems: function(itemsProperties) { 20127 for(var i = 0, len = itemsProperties.length; i < len; i++) { 20128 var itemProperties = itemsProperties[i], 20129 item = this.CreateItemInternal(itemProperties); 20130 if(itemProperties.items && itemProperties.items.length > 0) 20131 item.CreateItems(itemProperties.items); 20132 } 20133 }, 20134 CreateItemInternal: function(itemProperties) { 20135 var itemName = itemProperties.name || ""; 20136 var index = this.items.length; 20137 var itemType = this.menu.GetClientItemType(); 20138 var item = new itemType(this.menu, this, index, itemName); 20139 if(ASPx.IsExists(itemProperties.text)) 20140 item.text = itemProperties.text; 20141 if(ASPx.IsExists(itemProperties.imageUrl)) 20142 item.imageUrl = itemProperties.imageUrl; 20143 if(ASPx.IsExists(itemProperties.imageHottrackSrc)) 20144 item.imageHottrackSrc = itemProperties.imageHottrackSrc; 20145 if(ASPx.IsExists(itemProperties.imageClassName)) 20146 item.imageClassName = itemProperties.imageClassName; 20147 if(ASPx.IsExists(itemProperties.navigateUrl)) 20148 item.navigateUrl = itemProperties.navigateUrl; 20149 if(ASPx.IsExists(itemProperties.beginGroup)) 20150 item.beginGroup = itemProperties.beginGroup; 20151 if(ASPx.IsExists(itemProperties.enabled) && !this.menu.NeedCreateItemsOnClientSide()) 20152 item.enabled = itemProperties.enabled; 20153 if((ASPx.IsExists(itemProperties.clientEnabled) && !itemProperties.clientEnabled) || (ASPx.IsExists(itemProperties.enabled) && !itemProperties.enabled)) 20154 item.clientEnabled = false; 20155 if(ASPx.IsExists(itemProperties.visible)) 20156 item.visible = itemProperties.visible; 20157 if(ASPx.IsExists(itemProperties.clientVisible)) 20158 item.clientVisible = itemProperties.clientVisible; 20159 if(ASPx.IsExists(itemProperties.groupName)) { 20160 this.menu.ProcessItemGroupName(item, itemProperties.groupName); 20161 item.checked = !!itemProperties.checked; 20162 } 20163 if(ASPx.IsExists(itemProperties.tooltip)) 20164 item.tooltip = itemProperties.tooltip; 20165 if(ASPx.IsExists(itemProperties.target)) 20166 item.target = itemProperties.target; 20167 if(ASPx.IsExists(itemProperties.dropDownMode)) 20168 item.dropDownMode = itemProperties.dropDownMode; 20169 if(ASPx.IsExists(itemProperties.textTemplate)) 20170 item.textTemplate = itemProperties.textTemplate; 20171 if(ASPx.IsExists(itemProperties.styles)) 20172 item.styles = itemProperties.styles; 20173 if(ASPx.IsExists(itemProperties.isSvg)) 20174 item.isSvg = itemProperties.isSvg; 20175 if(this.menu.NeedAppendToRenderData(item)) 20176 this.menu.AppendToRenderData(this.indexPath, index); 20177 this.items.push(item); 20178 return item; 20179 }, 20180 GetIndexPath: function() { 20181 return this.indexPath; 20182 }, 20183 GetItemCount: function() { 20184 return this.items.length; 20185 }, 20186 GetItem: function(index) { 20187 return (0 <= index && index < this.items.length) ? this.items[index] : null; 20188 }, 20189 GetItemByName: function(name) { 20190 for(var i = 0; i < this.items.length; i++) 20191 if(this.items[i].name == name) return this.items[i]; 20192 for(var i = 0; i < this.items.length; i++) { 20193 var item = this.items[i].GetItemByName(name); 20194 if(item != null) return item; 20195 } 20196 return null; 20197 }, 20198 GetChecked: function() { 20199 var indexPath = this.GetIndexPath(); 20200 return this.menu.IsCheckedItem(indexPath); 20201 }, 20202 SetChecked: function(value) { 20203 var indexPath = this.GetIndexPath(); 20204 this.menu.SetItemChecked(indexPath, value); 20205 }, 20206 GetEnabled: function() { 20207 return this.enabled && this.clientEnabled; 20208 }, 20209 SetEnabled: function(value) { 20210 if(this.clientEnabled != value) { 20211 this.clientEnabled = value; 20212 this.menu.SetItemEnabled(this.GetIndexPath(), value, false); 20213 } 20214 }, 20215 GetImage: function() { 20216 return this.menu.GetItemImage(this.GetIndexPath()); 20217 }, 20218 GetImageUrl: function() { 20219 return this.menu.GetItemImageUrl(this.GetIndexPath()); 20220 }, 20221 SetImageUrl: function(value) { 20222 var indexPath = this.GetIndexPath(); 20223 this.menu.SetItemImageUrl(indexPath, value); 20224 }, 20225 GetNavigateUrl: function() { 20226 var indexPath = this.GetIndexPath(); 20227 return this.menu.GetItemNavigateUrl(indexPath); 20228 }, 20229 SetNavigateUrl: function(value) { 20230 var indexPath = this.GetIndexPath(); 20231 this.menu.SetItemNavigateUrl(indexPath, value); 20232 }, 20233 GetText: function() { 20234 var indexPath = this.GetIndexPath(); 20235 return this.menu.GetItemText(indexPath); 20236 }, 20237 SetText: function(value) { 20238 var indexPath = this.GetIndexPath(); 20239 this.menu.SetItemText(indexPath, value); 20240 }, 20241 GetVisible: function() { 20242 return this.visible && this.clientVisible; 20243 }, 20244 SetVisible: function(value) { 20245 if(this.clientVisible != value) { 20246 this.setClientVisibleInternal(value); 20247 this.menu.SetItemVisible(this.GetIndexPath(), value, false); 20248 } 20249 }, 20250 InitializeEnabledAndVisible: function(recursive) { 20251 this.menu.SetItemEnabled(this.GetIndexPath(), this.clientEnabled, true); 20252 this.menu.SetItemVisible(this.GetIndexPath(), this.clientVisible, true); 20253 if(recursive) { 20254 for(var i = 0; i < this.items.length; i++) 20255 this.items[i].InitializeEnabledAndVisible(recursive); 20256 } 20257 }, 20258 setClientVisibleInternal: function(value) {
20259 this.menu.prepareSideMenuCssClasses(false); 20260 this.clientVisible = value; 20261 this.menu.prepareSideMenuCssClasses(true); 20262 }, 20263 GetOwnProperties: function() { 20264 return { 20265 menuItem: this, 20266 focusableElement: this.GetFocusableElement() 20267 }; 20268 }, 20269 GetFocusableElement: function() { 20270 return this.menu.GetLinkElementByIndexPath(this.indexPath); 20271 } 20272}); 20273var subMenuStack = function() { 20274 this.stack = []; 20275 this.hasItems = function() { 20276 return this.stack.length > 1; 20277 }; 20278 this.count = function() { 20279 return this.stack.length; 20280 }; 20281 this.last = function() { 20282 return this.stack[this.stack.length - 1].element; 20283 }; 20284 this.push = function(element, text) { 20285 this.stack.push({element: element, text: text}); 20286 }; 20287 this.pop = function() { 20288 return this.stack.pop().element; 20289 }; 20290 this.text = function() { 20291 return this.stack[this.stack.length - 1].text; 20292 }; 20293}; 20294var appearPanelAction = ASPx.CreateClass({ 20295 constructor: function(menu) { 20296 this.menu = menu; 20297 this.expanded = false; 20298 this.cashedHtmlOverflow = ''; 20299 this.bodyLeftMargin = 0; 20300 this.clearWidth = 0; 20301 this.animationInProgress = false; 20302 this.panel = this.menu.GetMainElement().parentNode; 20303 this.burgerButton = this.createBurgerButton(); 20304 this.overlayPanel = this.createOverlayElement(); 20305 this.afterCollapsePanel = new ASPxClientEvent(); 20306 ASPx.Evt.AttachEventToElement(this.burgerButton, 'click', function() { this.toggleExpanded(); }.bind(this), true); 20307 ASPx.Evt.AttachEventToElement(this.overlayPanel, 'click', function() { this.toggleExpanded(); }.bind(this), true); 20308 }, 20309 get isLeftPosition() { 20310 return this.menu.position == 'left'; 20311 }, 20312 createBurgerButton: function() { 20313 var button = document.createElement('DIV'); 20314 button.className = BURGER_CLASS_NAME; 20315 if(!!this.menu.hamburgerClass) 20316 ASPx.AddClassNameToElement(button, this.menu.hamburgerClass); 20317 var line = document.createElement('DIV'); 20318 button.appendChild(line); 20319 this.panel.parentNode.appendChild(button); 20320 return button; 20321 }, 20322 createOverlayElement: function() { 20323 var panel = document.createElement('DIV'); 20324 panel.className = OVERLAY_PANEL_CLASS_NAME; 20325 this.panel.parentNode.appendChild(panel); 20326 return panel; 20327 }, 20328 toggleExpanded: function() { 20329 this.setExpanded(!this.getExpanded()); 20330 }, 20331 getExpanded: function() { 20332 return this.expanded; 20333 }, 20334 setExpanded: function(value) { 20335 if(this.expanded != value && !this.isAnimationInProgress()) { 20336 this.expanded = value; 20337 this.setExpandedCore(); 20338 } 20339 }, 20340 setExpandedCore: function() { 20341 if(this.expanded) { 20342 this.prepareForAnimateIn(); 20343 this.animateIn(); 20344 } 20345 else 20346 this.animateOut(); 20347 }, 20348 collapse: function() { 20349 this.expanded = false; 20350 this.rollbackAfterAnimateOut(); 20351 }, 20352 isAnimationInProgress: function() { 20353 return !!this.animationInProgress; 20354 }, 20355 prepareForAnimateIn: function() { 20356 this.prepareDocument(); 20357 this.prepareOverlayPanel(); 20358 this.prepareSlidePanel(); 20359 }, 20360 prepareDocument: function() { 20361 this.cashedHtmlOverflow = document.documentElement.style.overflow; 20362 document.documentElement.style.overflow = 'hidden'; 20363 }, 20364 prepareOverlayPanel: function() { 20365 ASPx.SetStyles(this.overlayPanel, { 20366 opacity: '0', 20367 zIndex: SIDE_MENU_ZINDEX_VALUE, 20368 display: 'block' 20369 }); 20370 ASPx.SetStyles(this.overlayPanel, { 20371 marginLeft: -ASPx.GetAbsoluteX(this.overlayPanel), 20372 marginTop: -ASPx.GetAbsoluteY(this.overlayPanel), 20373 }); 20374 }, 20375 prepareSlidePanel: function() { 20376 ASPx.SetStyles(this.panel, { display: 'block', width: '100%', zIndex: SIDE_MENU_ZINDEX_VALUE + 1 }); 20377 this.menu.AdjustControl(); 20378 var size = this.menu.calculateMaxSize(); 20379 this.clearWidth = size.width; 20380 var width = size.width; 20381 var overflowY = ''; 20382 if(size.height > window.innerHeight) { 20383 overflowY = 'scroll'; 20384 width = size.width + ASPx.GetVerticalScrollBarWidth(); 20385 } 20386 ASPx.SetStyles(this.panel, { 20387 className: this.panel.className + ' ' + SLIDE_PANEL_EXPANDED_CLASS_NAME, 20388 overflowY: overflowY, 20389 width: width 20390 }); 20391 }, 20392 createTransition: function(element, obj) { 20393 return transition = ASPx.AnimationHelper.createAnimationTransition(element, { 20394 property: obj.property, unit: obj.unit, duration: SLIDE_DURATION_VALUE, transition: ASPx.AnimationConstants.Transitions.POW_EASE_OUT, onComplete: obj.onComplete 20395 }); 20396 }, 20397 getInTransitions: function() { 20398 var arr = []; 20399 arr.push({ 20400 trans: this.createTransition(this.panel, { property: this.isLeftPosition ? 'left' : 'right', unit: 'px' }), 20401 start: -this.panel.offsetWidth, 20402 end: 0 20403 }); 20404 arr.push({ 20405 trans: this.createTransition(this.overlayPanel, { 20406 property: 'opacity', 20407 onComplete: function() { 20408 this.animationInProgress = false; 20409 }.aspxBind(this) 20410 }), 20411 start: 0, 20412 end: 100 20413 }); 20414 return arr; 20415 }, 20416 getOutTransitions: function() { 20417 var arr = []; 20418 arr.push({ 20419 trans: this.createTransition(this.panel, { property: this.isLeftPosition ? 'left' : 'right', unit: 'px' }), 20420 start: 0, 20421 end: -this.panel.offsetWidth 20422 }); 20423 arr.push({ 20424 trans: this.createTransition(this.overlayPanel, { 20425 property: 'opacity', 20426 onComplete: function() { 20427 window.setTimeout(function() { 20428 this.rollbackAfterAnimateOut(); 20429 this.animationInProgress = false; 20430 }.aspxBind(this), 0); 20431 }.aspxBind(this) 20432 }), 20433 start: 100, 20434 end: 0 20435 }); 20436 return arr; 20437 }, 20438 animateIn: function() { 20439 this.animate(this.getInTransitions()); 20440 }, 20441 animateOut: function() { 20442 this.animate(this.getOutTransitions()); 20443 }, 20444 animate: function(transitions) { 20445 this.animationInProgress = true; 20446 for(var i = 0, obj; obj = transitions[i]; i++) 20447 obj.trans.Start(obj.start, obj.end); 20448 }, 20449 resetPanelStyle: function() { 20450 ASPx.SetStyles(this.panel, { 20451 className: this.panel.className.replace(SLIDE_PANEL_EXPANDED_CLASS_NAME, ''),
20452 left: '', width: '', display: '', zIndex: '' 20453 }); 20454 }, 20455 resetOverlayPanelStyle: function() { 20456 ASPx.SetStyles(this.overlayPanel, { 20457 display: '', 20458 zIndex: '', 20459 marginLeft: 0, 20460 marginTop: 0 20461 }); 20462 }, 20463 rollbackAfterAnimateOut: function() { 20464 this.resetPanelStyle(); 20465 this.resetOverlayPanelStyle(); 20466 document.documentElement.style.overflow = this.cashedHtmlOverflow; 20467 this.afterCollapsePanel.FireEvent(); 20468 } 20469}); 20470var appearPanelWithShiftBodyAction = ASPx.CreateClass(appearPanelAction, { 20471 constructor: function(menu) { 20472 this.cashedBodyMargin = ''; 20473 this.cashedBodyWidth = ''; 20474 this.constructor.prototype.constructor.call(this, menu); 20475 }, 20476 getInTransitions: function() { 20477 var arr = appearPanelAction.prototype.getInTransitions.call(this); 20478 arr.push({ 20479 trans: this.createTransition(document.body, { property: 'marginLeft', unit: 'px' }), 20480 start: this.bodyLeftMargin, 20481 end: (this.isLeftPosition ? 1 : -1) * (this.bodyLeftMargin + this.panel.offsetWidth) 20482 }); 20483 return arr; 20484 }, 20485 getOutTransitions: function() { 20486 var arr = appearPanelAction.prototype.getOutTransitions.call(this); 20487 arr.push({ 20488 trans: this.createTransition(document.body, { property: 'marginLeft', unit: 'px' }), 20489 start: (this.isLeftPosition ? 1 : -1) * (this.bodyLeftMargin + this.panel.offsetWidth), 20490 end: this.bodyLeftMargin 20491 }); 20492 return arr; 20493 }, 20494 prepareForAnimateIn: function() { 20495 this.bodyLeftMargin = ASPx.PxToInt(ASPx.GetCurrentStyle(document.body).marginLeft); 20496 this.cashedBodyWidth = document.body.style.width; 20497 this.cashedBodyMargin = document.body.style.marginLeft; 20498 document.body.style.width = document.body.offsetWidth + 'px'; 20499 appearPanelAction.prototype.prepareForAnimateIn.call(this); 20500 }, 20501 rollbackAfterAnimateOut: function() { 20502 document.body.style.width = this.cashedBodyWidth; 20503 document.body.style.marginLeft = this.cashedBodyMargin; 20504 appearPanelAction.prototype.rollbackAfterAnimateOut.call(this); 20505 } 20506}); 20507var ASPxClientMenu = ASPx.CreateClass(ASPxClientMenuBase, { 20508 constructor: function(name) { 20509 this.constructor.prototype.constructor.call(this, name); 20510 this.isVertical = false; 20511 this.orientationChanged = false; 20512 this.firstSubMenuDirection = "Auto"; 20513 this.enableSideMenu = false; 20514 this.sideMenuWindowInnerWidth = ASPx.MaxMobileWindowWidth; 20515 this.enableCollapseToIcons = false; 20516 this.collapseToIconsWindowInnerWidth = ASPx.MaxMobileWindowWidth; 20517 this.showPopOutImages = false; 20518 this.sideMenuModeOn = false; 20519 this.iconsViewModeOn = false; 20520 this.position = 'left'; 20521 this.expandMode = 0; 20522 this.direction = this.position == 'left' ? 1 : -1; 20523 this.appearAction = null; 20524 this.subMenuStack = null; 20525 this.breadCrumb = null; 20526 }, 20527 InlineInitialize: function() { 20528 var mainElement = this.GetMainElement(); 20529 if(this.enableSideMenu) { 20530 mainElement.parentNode.className += ' dxm-' + this.position; 20531 this.subMenuStack = new subMenuStack(); 20532 this.subMenuStack.push(this.GetMainElement()); 20533 this.appearAction = this.createAppearAction(); 20534 this.breadCrumb = this.createBreadCrumbs(); 20535 this.updateBreadCrumbsText('TEMP'); 20536 this.switchMenuView(true); 20537 } 20538 this.switchBetweenTextAndIcons(); 20539 this.renderHelper.ApplyItemsVerticalAlignment(mainElement); 20540 ASPxClientMenuBase.prototype.InlineInitialize.call(this); 20541 }, 20542 BrowserWindowResizeSubscriber: function() { 20543 return ASPxClientMenuBase.prototype.BrowserWindowResizeSubscriber.call(this) || this.enableSideMenu || this.enableCollapseToIcons; 20544 }, 20545 SetData: function(data){ 20546 ASPxClientMenuBase.prototype.SetData.call(this, data); 20547 if(data.adaptiveModeData) 20548 this.SetAdaptiveMode(data.adaptiveModeData); 20549 }, 20550 IsVertical: function(indexPath) { 20551 return this.isVertical || !this.IsRootItem(indexPath) || this.IsAdaptiveMenuItem(indexPath); 20552 }, 20553 IsSidePanelExpanded: function() { 20554 return this.enableSideMenu && this.appearAction.getExpanded(); 20555 }, 20556 IsCorrectionDisableMethodRequired: function(indexPath) { 20557 return (indexPath.indexOf("i") == -1) && (this.firstSubMenuDirection == "RightOrBottom" || this.firstSubMenuDirection == "LeftOrTop"); 20558 }, 20559 SetAdaptiveMode: function(data) { 20560 this.enableAdaptivity = true; 20561 if(ASPx.Ident.IsArray(data)) 20562 this.adaptiveItemsOrder = data; 20563 else 20564 for(var i = data - 1; i >= 0; i--) 20565 this.adaptiveItemsOrder.push(i.toString()); 20566 }, 20567 OnBrowserWindowResize: function(e) { 20568 if(e && e.virtualKeyboardShownOnAndroid) return; 20569 this.switchMenuView(); 20570 this.switchBetweenTextAndIcons(); 20571 this.AdjustControl(); 20572 }, 20573 AdjustControlCore: function() { 20574 this.CorrectVerticalAlignment(ASPx.ClearHeight, this.GetPopOutElements, "PopOut", true); 20575 this.CorrectVerticalAlignment(ASPx.ClearVerticalMargins, this.GetPopOutImages, "PopOutImg", true); 20576 if(this.orientationChanged){ 20577 this.renderHelper.ChangeOrientaion(this.GetMainElement(), this.isVertical); 20578 this.orientationChanged = false; 20579 } 20580 else 20581 this.renderHelper.CalculateMenuControl(this.GetMainElement()); 20582 this.CorrectVerticalAlignment(ASPx.AdjustHeight, this.GetPopOutElements, "PopOut", true); 20583 this.CorrectVerticalAlignment(ASPx.AdjustVerticalMargins, this.GetPopOutImages, "PopOutImg", true); 20584 }, 20585 GetCorrectionDisabledResult: function(x, toLeftX) { 20586 switch (this.firstSubMenuDirection) { 20587 case "RightOrBottom": { 20588 this.popupToLeft = false; 20589 return x; 20590 } 20591 case "LeftOrTop": { 20592 this.popupToLeft = true; 20593 return toLeftX;
20594 } 20595 } 20596 }, 20597 IsHorizontalSubmenuNeedInversion: function(subMenuBottom, docClientHeight, menuItemTop, subMenuHeight, itemHeight) { 20598 if(this.firstSubMenuDirection == "Auto") 20599 return ASPxClientMenuBase.prototype.IsHorizontalSubmenuNeedInversion.call(this, subMenuBottom, docClientHeight, menuItemTop, subMenuHeight, itemHeight); 20600 return this.firstSubMenuDirection == "LeftOrTop"; 20601 }, 20602 createAppearAction: function() { 20603 var appearAction = this.expandMode == 0 ? new appearPanelWithShiftBodyAction(this) : new appearPanelAction(this); 20604 appearAction.afterCollapsePanel.AddHandler(function() { 20605 while(this.subMenuStack.hasItems()) 20606 this.performBack(true); 20607 ASPx.SetStyles(this.subMenuStack.last(), { left: '', opacity: '', display: '' }); 20608 ASPx.RemoveElement(this.breadCrumb); 20609 }.aspxBind(this)); 20610 return appearAction; 20611 }, 20612 createBreadCrumbs: function() { 20613 var element = document.createElement('DIV'); 20614 element.className = BREAD_CRUMBS_CLASS_NAME; 20615 ASPx.Evt.AttachEventToElement(element, 'click', function() { this.performBack(); }.bind(this), true); 20616 var breadCrumbsBackImage = document.createElement('IMG'); 20617 breadCrumbsBackImage.src = ASPx.EmptyImageUrl; 20618 breadCrumbsBackImage.className = BACK_ICON_CLASS_NAME; 20619 element.appendChild(breadCrumbsBackImage); 20620 var breadCrumbsTitle = document.createElement('SPAN'); 20621 element.appendChild(breadCrumbsTitle); 20622 return element; 20623 }, 20624 updateBreadCrumbsText: function() { 20625 var text = this.subMenuStack.text(); 20626 if(text) 20627 this.breadCrumb.children[1].innerHTML = this.subMenuStack.text(); 20628 }, 20629 calculateMaxSize: function() { 20630 var mainElement = this.GetMainElement(); 20631 var cachedWidth = mainElement.style.width; 20632 mainElement.style.width = ''; 20633 var size = { width: mainElement.offsetWidth, height: mainElement.offsetHeight }; 20634 this.foreachSubMenus(function(item, element) { 20635 if(!element) return; 20636 element.className += ' ' + TEMPORARY_VISIBILITY_CLASS_NAME; 20637 if(element.offsetWidth > size.width) 20638 size.width = element.offsetWidth; 20639 if(element.offsetHeight > size.height) 20640 size.height = element.offsetHeight; 20641 element.className = element.className.replace(' ' + TEMPORARY_VISIBILITY_CLASS_NAME, ''); 20642 }.bind(this)); 20643 mainElement.style.width = cachedWidth; 20644 return size; 20645 }, 20646 foreachSubMenus: function(menuItem, callback) { 20647 if(arguments.length == 1) { 20648 callback = menuItem; 20649 menuItem = this.GetRootItem(); 20650 } 20651 for(var i = 0, item; item = menuItem.items[i]; i++) 20652 this.foreachSubMenus(item, callback); 20653 if(menuItem.indexPath && menuItem.items.length) 20654 callback(menuItem, this.GetMenuElement(menuItem.indexPath)); 20655 }, 20656 switchMenuView: function(force) { 20657 if(this.enableSideMenu) { 20658 aspxGetMenuCollection().DoHidePopupMenus(null, 0, this.name, true, ""); 20659 var prevSideMenuOn = this.sideMenuModeOn; 20660 this.sideMenuModeOn = window.innerWidth < this.sideMenuWindowInnerWidth; 20661 if(this.sideMenuModeOn != prevSideMenuOn || force) 20662 this.switchMenuViewCore(); 20663 } 20664 }, 20665 switchBetweenTextAndIcons: function() { 20666 if(this.enableCollapseToIcons) { 20667 var newIconsViewModeOn = window.innerWidth <= this.collapseToIconsWindowInnerWidth; 20668 if(this.iconsViewModeOn != newIconsViewModeOn) 20669 this.ToggleRootItemsCollapsed(); 20670 } 20671 }, 20672 ToggleRootItemsCollapsed: function() { 20673 this.iconsViewModeOn = !this.iconsViewModeOn; 20674 ASPx.ToggleClassNameToElement(this.GetMainElement(), "dxm-onlyIcons", this.iconsViewModeOn); 20675 if(this.isInitialized) { 20676 this.renderHelper.ResetMinSize(); 20677 this.renderHelper.CalculateMenuControl(this.GetMainElement(), true); 20678 } 20679 }, 20680 switchMenuViewCore: function() { 20681 if(this.sideMenuModeOn) 20682 this.switchToSideMenuView(); 20683 else 20684 this.switchToDefaultMenuView(); 20685 }, 20686 switchToSideMenuView: function() { 20687 this.SetOrientation('Vertical'); 20688 this.switchSideMenuClass(); 20689 if(!this.showPopOutImages) { 20690 var mainElement = this.GetMainElement(); 20691 this.replacePopupOutImages(MenuCssClasses.ItemWithoutSubMenu, MenuCssClasses.ItemWithSubMenu); 20692 mainElement.className = mainElement.className.replace(NO_MAIN_POP_OUT_CLASS_NAME, ''); 20693 } 20694 }, 20695 switchToDefaultMenuView: function() { 20696 if(!this.showPopOutImages) { 20697 var mainElement = this.GetMainElement();
20698 this.replacePopupOutImages(MenuCssClasses.ItemWithSubMenu, MenuCssClasses.ItemWithoutSubMenu); 20699 if(mainElement.className.indexOf(NO_MAIN_POP_OUT_CLASS_NAME) == -1) 20700 mainElement.className += ' ' + NO_MAIN_POP_OUT_CLASS_NAME; 20701 } 20702 this.SetOrientation('Horizontal'); 20703 this.switchSideMenuClass(); 20704 this.appearAction.collapse(); 20705 }, 20706 switchSideMenuClass: function() { 20707 var rootElement = this.GetMainElement().parentNode.parentNode; 20708 if(this.sideMenuModeOn) { 20709 if(rootElement.className.indexOf(SIDE_MENU_CLASS_NAME) == -1) 20710 rootElement.className += ' ' + SIDE_MENU_CLASS_NAME; 20711 } 20712 else 20713 rootElement.className = rootElement.className.replace(' ' + SIDE_MENU_CLASS_NAME, ''); 20714 }, 20715 replacePopupOutImages: function(firstClass, secondClass) { 20716 var elements = this.renderHelper.GetItemElements(this.GetMainElement()); 20717 for(var i = 0, item = null; item = elements[i]; i++) { 20718 if(item.className.indexOf(firstClass)) 20719 item.className = item.className.replace(firstClass, secondClass); 20720 } 20721 }, 20722 CalculateSubMenuPosition: function(element, x, y, indexPath, enableAnimation) { 20723 if(this.sideMenuModeOn) 20724 this.performForward(indexPath); 20725 else 20726 ASPxClientMenuBase.prototype.CalculateSubMenuPosition.call(this, element, x, y, indexPath, enableAnimation); 20727 }, 20728 startPanelAnimation: function(element, props, onComplete) { 20729 ASPx.AnimationHelper.createMultipleAnimationTransition(element, { 20730 duration: SLIDE_DURATION_VALUE, 20731 transition: ASPx.AnimationConstants.Transitions.POW_EASE_OUT, 20732 onComplete: onComplete 20733 }).Start(props); 20734 }, 20735 changeBreadCrumbsParent: function(parent) { 20736 if(this.subMenuStack.count() == 1 && !parent.querySelector('.' + BREAD_CRUMBS_CLASS_NAME)) 20737 parent.appendChild(this.breadCrumb); 20738 }, 20739 performForward: function(indexPath) { 20740 var element = this.GetMenuElement(indexPath); 20741 if(element != null) { 20742 var currentSubMenu = this.subMenuStack.last(); 20743 var currentSubMenuWidth = currentSubMenu.offsetWidth; 20744 var nextSubMenu = this.GetMenuElement(indexPath); 20745 this.setSubMenuVisible(nextSubMenu); 20746 this.changeBreadCrumbsParent(nextSubMenu); 20747 this.subMenuStack.push(nextSubMenu, this.GetItemByIndexPath(indexPath).GetText()); 20748 this.updateBreadCrumbsText(); 20749 this.setSubMenuSize(indexPath, nextSubMenu); 20750 this.startPanelAnimation(currentSubMenu, { 20751 left: { from: 0, to: this.direction * -(currentSubMenuWidth / 3), unit: "px" }, 20752 opacity: { from: 1, to: 0 } 20753 }, function(el) { el.style.display = 'none'; el.style.opacity = ''; }); 20754 window.setTimeout(function() { 20755 this.startPanelAnimation(nextSubMenu, { 20756 left: { from: this.direction * currentSubMenuWidth, to: 0, unit: "px" }, 20757 opacity: { from: 0, to: 1 } 20758 }, function(element) { this.onNextSubmenuAnimationEnd(element); }.bind(this)); 20759 }.bind(this), SLIDE_DURATION_VALUE / 3); 20760 } 20761 }, 20762 setSubMenuVisible: function(subMenu) { 20763 ASPx.SetStyles(subMenu, { 20764 top: '', display: '', visibility: '', opacity: 0 20765 }); 20766 }, 20767 setSubMenuSize: function(indexPath, subMenu) { 20768 var menuElement = this.GetMenuElement(indexPath); 20769 menuElement.style.width = this.appearAction.clearWidth + 'px'; 20770 subMenu.children[0].style.top = this.breadCrumb.offsetHeight + 'px'; 20771 }, 20772 onNextSubmenuAnimationEnd: function(element) { 20773 if(element.children.length > 1) 20774 element.parentNode.appendChild(this.breadCrumb); 20775 }, 20776 performBack: function(skipAnimation) { 20777 if(this.subMenuStack.hasItems()) { 20778 var currentSubMenu = this.subMenuStack.pop(); 20779 var prevSubMenu = this.subMenuStack.last(); 20780 if(skipAnimation) 20781 this.performBackWithoutAnimation(currentSubMenu, prevSubMenu); 20782 else 20783 this.performBackWithAnimation(currentSubMenu, prevSubMenu); 20784 } 20785 }, 20786 performBackWithoutAnimation: function(currentSubMenu, prevSubMenu) { 20787 this.DoHidePopupMenu(null, currentSubMenu); 20788 }, 20789 performBackWithAnimation: function(currentSubMenu, prevSubMenu) { 20790 this.updateBreadCrumbsText(); 20791 this.changeBreadCrumbsParent(currentSubMenu); 20792 var width = currentSubMenu.offsetWidth; 20793 prevSubMenu.style.opacity = '0'; 20794 prevSubMenu.style.display = ''; 20795 this.startPanelAnimation(currentSubMenu, {
20796 left: { from: 0, to: this.direction * (width / 3), unit: "px" }, 20797 opacity: { from: 1, to: 0 } 20798 }, function(el) { el.style.opacity = ''; el.style.display = 'none'; this.DoHidePopupMenu(null, el); }.bind(this)); 20799 window.setTimeout(function() { 20800 this.startPanelAnimation(prevSubMenu, { 20801 left: { from: this.direction * -width, to: 0, unit: "px" }, 20802 opacity: { from: 0, to: 1 } 20803 }); 20804 }.bind(this), SLIDE_DURATION_VALUE / 3); 20805 }, 20806 GetOrientation: function() { 20807 return this.isVertical ? "Vertical" : "Horizontal"; 20808 }, 20809 SetOrientation: function(orientation) { 20810 var isVertical = orientation === "Vertical"; 20811 if(this.isVertical !== isVertical){ 20812 this.isVertical = isVertical; 20813 this.orientationChanged = true; 20814 this.ResetControlAdjustment(); 20815 this.AdjustControl(); 20816 } 20817 }, 20818 ToggleSideMenu: function() { 20819 if(this.sideMenuModeOn) 20820 this.appearAction.toggleExpanded(); 20821 } 20822}); 20823ASPx.Ident.scripts.ASPxClientMenu = true; 20824ASPxClientMenu.Cast = ASPxClientControl.Cast; 20825var ASPxClientMenuExt = ASPx.CreateClass(ASPxClientMenu, { 20826 constructor: function(name) { 20827 this.constructor.prototype.constructor.call(this, name); 20828 }, 20829 NeedCreateItemsOnClientSide: function() { 20830 return true; 20831 } 20832}); 20833var ASPxClientMenuItemEventArgs = ASPx.CreateClass(ASPxClientEventArgs, { 20834 constructor: function(item) { 20835 this.constructor.prototype.constructor.call(this); 20836 this.item = item; 20837 } 20838}); 20839var ASPxClientMenuItemMouseEventArgs = ASPx.CreateClass(ASPxClientMenuItemEventArgs, { 20840 constructor: function(item, htmlElement) { 20841 this.constructor.prototype.constructor.call(this, item); 20842 this.htmlElement = htmlElement; 20843 } 20844}); 20845var ASPxClientMenuItemClickEventArgs = ASPx.CreateClass(ASPxClientProcessingModeEventArgs, { 20846 constructor: function(processOnServer, item, htmlElement, htmlEvent) { 20847 this.constructor.prototype.constructor.call(this, processOnServer); 20848 this.item = item; 20849 this.htmlElement = htmlElement; 20850 this.htmlEvent = htmlEvent; 20851 } 20852}); 20853ASPx.Evt.AttachEventToDocument(ASPx.TouchUIHelper.touchMouseDownEventName, function(evt) { 20854 return aspxGetMenuCollection().OnMouseDown(evt); 20855}); 20856function aspxAMIMOver(source, args) { 20857 var menu = aspxGetMenuCollection().GetMenu(args.item.name); 20858 if(menu != null) menu.OnAfterItemOver(args.item, args.element); 20859} 20860function aspxBMIMOver(source, args) { 20861 var menu = aspxGetMenuCollection().GetMenu(args.item.name); 20862 if(menu != null) menu.OnBeforeItemOver(args.item, args.element); 20863} 20864function aspxAMIMOut(source, args) { 20865 var menu = aspxGetMenuCollection().GetMenu(args.item.name); 20866 if(menu != null) menu.OnAfterItemOut(args.item, args.element, args.toElement); 20867} 20868function aspxMSBOver(source, args) { 20869 var menu = MenuScrollHelper.GetMenuByScrollButtonId(args.element.id); 20870 if(menu != null) menu.ClearDisappearTimer(); 20871} 20872ASPx.AddAfterSetFocusedState(aspxAMIMOver); 20873ASPx.AddAfterClearFocusedState(aspxAMIMOut); 20874ASPx.AddAfterSetHoverState(aspxAMIMOver); 20875ASPx.AddAfterClearHoverState(aspxAMIMOut); 20876ASPx.AddBeforeSetFocusedState(aspxBMIMOver); 20877ASPx.AddBeforeSetHoverState(aspxBMIMOver); 20878ASPx.AddAfterSetHoverState(aspxMSBOver); 20879ASPx.AddAfterSetPressedState(aspxMSBOver); 20880ASPx.AddBeforeDisabled(function(source, args) { 20881 var menu = aspxGetMenuCollection().GetMenu(args.item.name); 20882 if(menu != null) 20883 menu.OnBeforeItemDisabled(args.item, args.element); 20884}); 20885ASPx.AddFocusedItemKeyDown(function(source, args) { 20886 var menu = aspxGetMenuCollection().GetMenu(args.item.name); 20887 if(menu != null) 20888 menu.OnFocusedItemKeyDown(args.htmlEvent, args.item); 20889}); 20890ASPx.AddAfterClearHoverState(function(source, args) { 20891 var menu = MenuScrollHelper.GetMenuByScrollButtonId(args.element.id); 20892 if(menu != null) menu.SetDisappearTimer(); 20893}); 20894ASPx.AddAfterSetPressedState(function(source, args) { 20895 var menu = MenuScrollHelper.GetMenuByScrollButtonId(args.element.id); 20896 if(menu) menu.StartScrolling(args.element.id, 1, 4); 20897}); 20898ASPx.AddAfterClearPressedState(function(source, args) { 20899 var menu = MenuScrollHelper.GetMenuByScrollButtonId(args.element.id);
20900 if(menu) menu.StopScrolling(args.element.id); 20901}); 20902if(!ASPx.Browser.TouchUI) { 20903 ASPx.AddAfterSetHoverState(function(source, args) { 20904 var menu = MenuScrollHelper.GetMenuByScrollButtonId(args.element.id); 20905 if(menu) menu.StartScrolling(args.element.id, 15, 1); 20906 if(!menu) 20907 menu = aspxGetMenuCollection().GetMenu(args.item.name); 20908 if(menu && menu.sideMenuModeOn && menu.IsItemElement(args.element)) { 20909 menu.hoverItemName = args.item.name; 20910 menu.MarkPrecedingItem(args.item.name, PRE_HOVERED_ELEMENT_CLASS_NAME, true); 20911 } 20912 }); 20913 ASPx.AddAfterClearHoverState(function(source, args) { 20914 var menu = MenuScrollHelper.GetMenuByScrollButtonId(args.element.id); 20915 if(menu) menu.StopScrolling(args.element.id); 20916 if(!menu) 20917 menu = aspxGetMenuCollection().GetMenu(args.item.name); 20918 if(menu && menu.sideMenuModeOn && menu.IsItemElement(args.element)) { 20919 menu.hoverItemName = null; 20920 menu.UnmarkPrecedingItem(args.item.name, PRE_HOVERED_ELEMENT_CLASS_NAME, true); 20921 } 20922 }); 20923} 20924ASPx.MIClick = function(evt, name, indexPath) { 20925 if(ASPx.TouchUIHelper.isMouseEventFromScrolling) return; 20926 var menu = aspxGetMenuCollection().Get(name); 20927 if(menu != null) menu.OnItemClick(indexPath, evt); 20928}; 20929ASPx.MIDDClick = function(evt, name, indexPath) { 20930 var menu = aspxGetMenuCollection().Get(name); 20931 if(menu != null) menu.OnItemDropDownClick(indexPath, evt); 20932 if(!ASPx.Browser.NetscapeFamily) 20933 evt.cancelBubble = true; 20934}; 20935ASPx.GetMenuCollection = aspxGetMenuCollection; 20936ASPx.MenuRenderHelper = MenuRenderHelper; 20937ASPx.MenuItemClasses = MenuCssClasses; 20938window.ASPxClientMenuBase = ASPxClientMenuBase; 20939window.ASPxClientMenuCollection = ASPxClientMenuCollection; 20940window.ASPxClientMenuItem = ASPxClientMenuItem; 20941window.ASPxClientMenu = ASPxClientMenu; 20942window.ASPxClientMenuExt = ASPxClientMenuExt; 20943window.ASPxClientMenuItemEventArgs = ASPxClientMenuItemEventArgs; 20944window.ASPxClientMenuItemMouseEventArgs = ASPxClientMenuItemMouseEventArgs; 20945window.ASPxClientMenuItemClickEventArgs = ASPxClientMenuItemClickEventArgs; 20946})(); 20947 20948(function() { 20949var ASPxClientEditBase = ASPx.CreateClass(ASPxClientControl, { 20950 constructor: function(name) { 20951 this.constructor.prototype.constructor.call(this, name); 20952 this.EnabledChanged = new ASPxClientEvent(); 20953 this.captionPosition = ASPx.Position.Left; 20954 this.showCaptionColon = true; 20955 this.scPrefix = "dxe"; 20956 }, 20957 InlineInitialize: function(){ 20958 ASPxClientControl.prototype.InlineInitialize.call(this); 20959 this.InitializeEnabled(); 20960 this.InitializeEvents(); 20961 }, 20962 InitializeEnabled: function() { 20963 this.SetEnabledInternal(this.clientEnabled, true); 20964 }, 20965 InitializeEvents: function() { }, 20966 AddDefaultReadOnlyStateControllerItem: function(cssClass, mainElementId) { 20967 ASPx.AddReadOnlyItems(mainElementId, [[[cssClass], [''], ['']]]); 20968 }, 20969 AddDefaultDisabledStateControllerItem: function(cssClass, mainElementId) { 20970 ASPx.AddDisabledItems(mainElementId, [[[cssClass], [''], ['']]]); 20971 }, 20972 GetValue: function() { 20973 var element = this.GetMainElement(); 20974 if(ASPx.IsExistsElement(element)) 20975 return element.innerHTML; 20976 return ""; 20977 }, 20978 GetValueString: function(){ 20979 var value = this.GetValue(); 20980 return (value == null) ? null : value.toString(); 20981 }, 20982 EnsureValueStringIsActual: function() { 20983 if(this.maskInfo != null) 20984 this.ParseValue(); 20985 }, 20986 SetValue: function(value) { 20987 if(value == null) 20988 value = ""; 20989 var element = this.GetMainElement(); 20990 if(ASPx.IsExistsElement(element)) 20991 element.innerHTML = value; 20992 }, 20993 GetEnabled: function(){ 20994 return this.enabled && this.clientEnabled; 20995 }, 20996 SetEnabled: function(enabled){ 20997 if(this.clientEnabled != enabled) { 20998 var errorFrameRequiresUpdate = this.GetIsValid && !this.GetIsValid(); 20999 if(errorFrameRequiresUpdate && !enabled) 21000 this.UpdateErrorFrameAndFocus(false , null , true ); 21001 this.clientEnabled = enabled; 21002 this.SetEnabledInternal(enabled, false); 21003 if(errorFrameRequiresUpdate && enabled) 21004 this.UpdateErrorFrameAndFocus(false ); 21005 this.RaiseEnabledChangedEvent(); 21006 } 21007 }, 21008 SetEnabledInternal: function(enabled, initialization){ 21009 if(!this.enabled) return; 21010 if(!initialization || !enabled) 21011 this.ChangeEnabledStateItems(enabled); 21012 this.ChangeEnabledAttributes(enabled); 21013 if(ASPx.Browser.Chrome) { 21014 var mainElement = this.GetMainElement(); 21015 if(mainElement) 21016 mainElement.className = mainElement.className; 21017 } 21018 }, 21019 ChangeEnabledAttributes: function(enabled){ 21020 }, 21021 ChangeEnabledStateItems: function(enabled){ 21022 }, 21023 RaiseEnabledChangedEvent: function(){ 21024 if(!this.EnabledChanged.IsEmpty()){ 21025 var args = new ASPxClientEventArgs(); 21026 this.EnabledChanged.FireEvent(this, args); 21027 } 21028 }, 21029 GetDecodeValue: function (value) { 21030 if(typeof (value) == "string" && value.length > 1) 21031 value = this.SimpleDecodeHtml(value); 21032 return value; 21033 }, 21034 SimpleDecodeHtml: function (html) { 21035 return ASPx.Str.ApplyReplacement(html, [ 21036 [/</g, '<'], 21037 [/&/g, '&'], 21038 [/"/g, '"'], 21039 [/'/g, '\''], 21040 [/ /g, ' '] 21041 ]); 21042 }, 21043 GetCachedElementById: function(idSuffix) { 21044 return ASPx.CacheHelper.GetCachedElementById(this, this.name + idSuffix); 21045 }, 21046 GetCaptionCell: function() { 21047 return this.GetCachedElementById(EditElementSuffix.CaptionCell); 21048 }, 21049 GetExternalTable: function() { 21050 return this.GetCachedElementById(EditElementSuffix.ExternalTable); 21051 }, 21052 getCaptionRelatedCellCount: function() { 21053 if(!this.captionRelatedCellCount) 21054 this.captionRelatedCellCount = ASPx.GetNodesByClassName(this.GetExternalTable(), CaptionRelatedCellClassName).length; 21055 return this.captionRelatedCellCount; 21056 }, 21057 addCssClassToCaptionRelatedCells: function() { 21058 if(this.captionPosition == ASPx.Position.Left || this.captionPosition == ASPx.Position.Right) { 21059 var captionRelatedCellsIndex = this.captionPosition == ASPx.Position.Left ? 0 : this.GetCaptionCell().cellIndex; 21060 for(var i = 0; i < this.GetExternalTable().rows.length; i++) 21061 ASPx.AddClassNameToElement(this.GetExternalTable().rows[i].cells[captionRelatedCellsIndex], CaptionRelatedCellClassName); 21062 } 21063 if(this.captionPosition == ASPx.Position.Top || this.captionPosition == ASPx.Position.Bottom) 21064 for(var i = 0; i < this.GetCaptionCell().parentNode.cells.length; i++) 21065 ASPx.AddClassNameToElement(this.GetCaptionCell().parentNode.cells[i], CaptionRelatedCellClassName); 21066 }, 21067 GetCaption: function() { 21068 if(ASPx.IsExists(this.GetCaptionCell())) 21069 return this.getCaptionInternal(); 21070 return ""; 21071 }, 21072 SetCaption: function(caption) { 21073 if(!ASPx.IsExists(this.GetCaptionCell())) 21074 return; 21075 if(this.getCaptionRelatedCellCount() == 0) 21076 this.addCssClassToCaptionRelatedCells();
21077 if(caption !== "") 21078 ASPx.RemoveClassNameFromElement(this.GetExternalTable(), ASPxEditExternalTableClassNames.TableWithEmptyCaptionClassName); 21079 else 21080 ASPx.AddClassNameToElement(this.GetExternalTable(), ASPxEditExternalTableClassNames.TableWithEmptyCaptionClassName); 21081 this.setCaptionInternal(caption); 21082 }, 21083 getCaptionTextNode: function() { 21084 var captionElement = ASPx.GetNodesByPartialClassName(this.GetCaptionCell(), CaptionElementPartialClassName)[0]; 21085 return ASPx.GetNormalizedTextNode(captionElement); 21086 }, 21087 getCaptionInternal: function() { 21088 var captionText = this.getCaptionTextNode().nodeValue; 21089 if(captionText !== "" && captionText[captionText.length - 1] == ":") 21090 captionText = captionText.substring(0, captionText.length - 1); 21091 return captionText; 21092 }, 21093 setCaptionInternal: function(caption) { 21094 caption = ASPx.Str.Trim(caption); 21095 var captionTextNode = this.getCaptionTextNode(); 21096 if(this.showCaptionColon && caption[caption.length - 1] != ":" && caption !== "") 21097 caption += ":"; 21098 captionTextNode.nodeValue = caption; 21099 }, 21100 onVirtualKeyboardUITouchStart: function(evt) { } 21101}); 21102var ValidationPattern = ASPx.CreateClass(null, { 21103 constructor: function(errorText) { 21104 this.errorText = errorText; 21105 } 21106}); 21107var RequiredFieldValidationPattern = ASPx.CreateClass(ValidationPattern, { 21108 constructor: function(errorText) { 21109 this.constructor.prototype.constructor.call(this, errorText); 21110 }, 21111 EvaluateIsValid: function(value) { 21112 return value != null && (value.constructor == Array || ASPx.Str.Trim(value.toString()) != ""); 21113 } 21114}); 21115var RegularExpressionValidationPattern = ASPx.CreateClass(ValidationPattern, { 21116 constructor: function(errorText, pattern) { 21117 this.constructor.prototype.constructor.call(this, errorText); 21118 this.pattern = pattern; 21119 }, 21120 EvaluateIsValid: function(value) { 21121 if(value == null) 21122 return true; 21123 var strValue = value.toString(); 21124 if(ASPx.Str.Trim(strValue).length == 0) 21125 return true; 21126 var regEx = new RegExp(this.pattern); 21127 var matches = regEx.exec(strValue); 21128 return matches != null && strValue == matches[0]; 21129 } 21130}); 21131function _aspxIsEditorFocusable(inputElement) { 21132 return ASPx.IsFocusableCore(inputElement, function(container) { 21133 return container.getAttribute("errorFrame") == "errorFrame"; 21134 }); 21135} 21136var invalidEditorToBeFocused = null; 21137var ValidationType = { 21138 PersonalOnValueChanged: "ValueChanged", 21139 PersonalViaScript: "CalledViaScript", 21140 MassValidation: "MassValidation" 21141}; 21142var ErrorFrameDisplay = { 21143 None: "None", 21144 Static: "Static", 21145 Dynamic: "Dynamic" 21146}; 21147var EditElementSuffix = { 21148 ExternalTable: "_ET", 21149 ControlCell: "_CC", 21150 ErrorCell: "_EC", 21151 ErrorTextCell: "_ETC", 21152 ErrorImage: "_EI", 21153 CaptionCell: "_CapC", 21154 AccessibilityAdditionalTextRow: "_AHTR" 21155}; 21156var ASPxEditExternalTableClassNames = { 21157 ValidStaticTableClassName: "dxeValidStEditorTable", 21158 ValidDynamicTableClassName: "dxeValidDynEditorTable", 21159 TableWithSeparateBordersClassName: "tableWithSeparateBorders", 21160 TableWithEmptyCaptionClassName: "tableWithEmptyCaption" 21161}; 21162var CaptionRelatedCellClassName = "dxeCaptionRelatedCell"; 21163var CaptionElementPartialClassName = "dxeCaption"; 21164var AccessibilityAssistantID = "AcAs"; 21165var ASPxClientEdit = ASPx.CreateClass(ASPxClientEditBase, { 21166 constructor: function(name) { 21167 this.constructor.prototype.constructor.call(this, name); 21168 this.isASPxClientEdit = true; 21169 this.inputElement = null; 21170 this.convertEmptyStringToNull = true; 21171 this.readOnly = false; 21172 this.clientReadOnly = false; 21173 this.focused = false; 21174 this.focusEventsLocked = false; 21175 this.receiveGlobalMouseWheel = true; 21176 this.styleDecoration = null; 21177 this.heightCorrectionRequired = false; 21178 this.customValidationEnabled = false; 21179 this.display = ErrorFrameDisplay.Static; 21180 this.initialErrorText = ""; 21181 this.causesValidation = false; 21182 this.validateOnLeave = true; 21183 this.validationGroup = ""; 21184 this.sendPostBackWithValidation = null; 21185 this.validationPatterns = []; 21186 this.setFocusOnError = false; 21187 this.errorDisplayMode = "it"; 21188 this.errorText = ""; 21189 this.isValid = true; 21190 this.errorImageIsAssigned = false; 21191 this.notifyValidationSummariesToAcceptNewError = false; 21192 this.isErrorFrameRequired = false; 21193 this.enterProcessed = false; 21194 this.keyDownHandlers = {}; 21195 this.keyPressHandlers = {}; 21196 this.keyUpHandlers = {}; 21197 this.specialKeyboardHandlingUsed = false;
21198 this.onKeyDownHandler = null; 21199 this.onKeyPressHandler = null; 21200 this.onKeyUpHandler = null; 21201 this.onGotFocusHandler = null; 21202 this.onLostFocusHandler = null; 21203 this.GotFocus = new ASPxClientEvent(); 21204 this.LostFocus = new ASPxClientEvent(); 21205 this.Validation = new ASPxClientEvent(); 21206 this.ValueChanged = new ASPxClientEvent(); 21207 this.KeyDown = new ASPxClientEvent(); 21208 this.KeyPress = new ASPxClientEvent(); 21209 this.KeyUp = new ASPxClientEvent(); 21210 this.eventHandlersInitialized = false; 21211 this.errorCellVisibilityChanged = new ASPxClientEvent(); 21212 this.ariaExplanatoryTextManager = null; 21213 }, 21214 SetData: function(data){ 21215 if(data.decorationStyles){ 21216 for(var i = 0; i < data.decorationStyles.length; i++) 21217 this.AddDecorationStyle(data.decorationStyles[i].key, 21218 data.decorationStyles[i].className, 21219 data.decorationStyles[i].cssText); 21220 } 21221 }, 21222 Initialize: function() { 21223 this.initialErrorText = this.errorText; 21224 ASPxClientEditBase.prototype.Initialize.call(this); 21225 this.InitializeKeyHandlers(); 21226 this.UpdateClientValidationState(); 21227 this.UpdateValidationSummaries(null , true ); 21228 }, 21229 InlineInitialize: function() { 21230 ASPxClientEditBase.prototype.InlineInitialize.call(this); 21231 this.UpdateStyleDecorations(); 21232 var externalTable = this.GetExternalTable(); 21233 if(externalTable && ASPx.IsPercentageSize(externalTable.style.width)) { 21234 this.width = "100%"; 21235 this.GetMainElement().style.width = "100%"; 21236 if(this.isErrorFrameRequired) 21237 externalTable.setAttribute("errorFrame", "errorFrame"); 21238 } 21239 this.ariaExplanatoryTextManager = this.CreateAriaExplanatoryTextManager(); 21240 if(this.clientReadOnly) 21241 this.SetReadOnlyInternal(true); 21242 this.UpdateErrorCellParentRowVisibility(); 21243 }, 21244 AfterInitialize: function() { 21245 this.ariaExplanatoryTextManager.SetCaptionAssociating(); 21246 this.ariaExplanatoryTextManager.UpdateText(); 21247 this.ariaExplanatoryTextManager.UpdateValidationState(); 21248 ASPxClientEditBase.prototype.AfterInitialize.call(this); 21249 }, 21250 UpdateStyleDecorations: function() { 21251 if(this.styleDecoration) 21252 this.styleDecoration.Update(); 21253 }, 21254 InitSpecialKeyboardHandling: function(){ 21255 var name = this.name; 21256 this.onKeyDownHandler = function(evt) { ASPx.KBSIKeyDown(name,evt); }; 21257 this.onKeyPressHandler = function(evt) { ASPx.KBSIKeyPress(name, evt); }; 21258 this.onKeyUpHandler = function(evt) { ASPx.KBSIKeyUp(name, evt); }; 21259 this.onGotFocusHandler = function(evt) { ASPx.ESGotFocus(name); }; 21260 this.onLostFocusHandler = function(evt) { ASPx.ESLostFocus(name); }; 21261 this.specialKeyboardHandlingUsed = true; 21262 this.InitializeDelayedSpecialFocus(); 21263 }, 21264 InitializeKeyHandlers: function() { 21265 }, 21266 AddKeyDownHandler: function(key, handler) { 21267 this.keyDownHandlers[key] = handler; 21268 }, 21269 AddKeyPressHandler: function(key, handler) { 21270 this.keyPressHandlers[key] = handler; 21271 }, 21272 ChangeSpecialInputEnabledAttributes: function(element, method, doNotChangeAutoComplete){ 21273 if(!doNotChangeAutoComplete) 21274 element.autocomplete = "off"; 21275 if(this.onKeyDownHandler != null) 21276 method(element, "keydown", this.onKeyDownHandler); 21277 if(this.onKeyPressHandler != null) 21278 method(element, "keypress", this.onKeyPressHandler); 21279 if(this.onKeyUpHandler != null) 21280 method(element, "keyup", this.onKeyUpHandler); 21281 if(this.onGotFocusHandler != null) 21282 method(element, "focus", this.onGotFocusHandler); 21283 if(this.onLostFocusHandler != null) 21284 method(element, "blur", this.onLostFocusHandler); 21285 }, 21286 CreateAriaExplanatoryTextManager: function() { 21287 if(this.accessibilityCompliant) 21288 return new EditAccessibilityExplanatoryTextManager(this); 21289 else 21290 return new DisableAccessibilityExplanatoryTextManager(this); 21291 }, 21292 UpdateClientValidationState: function() { 21293 if(!this.customValidationEnabled) 21294 return; 21295 var mainElement = this.GetMainElement(); 21296 if(mainElement) { 21297 var validationState = !this.GetIsValid() ? ("-" + this.GetErrorText()) : ""; 21298 this.UpdateStateObjectWithObject({ validationState: validationState }); 21299 } 21300 }, 21301 UpdateValidationSummaries: function(validationType, initializing) { 21302 if(ASPx.Ident.scripts.ASPxClientValidationSummary) { 21303 var summaryCollection = ASPx.GetClientValidationSummaryCollection(); 21304 summaryCollection.OnEditorIsValidStateChanged(this, validationType, initializing && this.notifyValidationSummariesToAcceptNewError); 21305 } 21306 }, 21307 FindInputElement: function(){ 21308 return null; 21309 }, 21310 GetInputElement: function(){ 21311 if(!ASPx.IsExistsElement(this.inputElement)) 21312 this.inputElement = this.FindInputElement(); 21313 return this.inputElement; 21314 }, 21315 GetFocusableInputElement: function() { 21316 return this.GetInputElement(); 21317 }, 21318 GetAccessibilityActiveElements: function() { 21319 return [this.GetInputElement()]; 21320 }, 21321 GetAccessibilityFirstActiveElement: function() { 21322 return this.accessibilityHelper ? 21323 this.accessibilityHelper.getMainElement() : 21324 this.GetAccessibilityActiveElements()[0]; 21325 }, 21326 GetAccessibilityAssistantElement: function() { 21327 return this.GetChildElement(AccessibilityAssistantID); 21328 }, 21329 GetErrorImage: function() { 21330 return this.GetCachedElementById(EditElementSuffix.ErrorImage); 21331 }, 21332 GetControlCell: function() { 21333 return this.GetCachedElementById(EditElementSuffix.ControlCell); 21334 }, 21335 GetErrorCell: function() { 21336 return this.GetCachedElementById(EditElementSuffix.ErrorCell); 21337 }, 21338 GetErrorTextCell: function() { 21339 return this.GetCachedElementById(this.errorImageIsAssigned ? EditElementSuffix.ErrorTextCell : EditElementSuffix.ErrorCell); 21340 }, 21341 GetReadOnly: function() { 21342 return this.readOnly || this.clientReadOnly; 21343 }, 21344 SetReadOnly: function(readOnly) { 21345 readOnly = !!readOnly; 21346 if(this.clientReadOnly === readOnly || this.readOnly) 21347 return; 21348 this.SetReadOnlyInternal(readOnly); 21349 }, 21350 SetReadOnlyInternal: function(readOnly) { 21351 this.clientReadOnly = readOnly; 21352 this.ChangeReadOnlyStateItems(readOnly); 21353 }, 21354 ChangeReadOnlyStateItems: function(readOnly) { 21355 ASPx.GetStateController().SetElementReadOnly(this.GetMainElement(), readOnly); 21356 }, 21357 SetVisible: function (isVisible) { 21358 if(this.clientVisible == isVisible) 21359 return; 21360 var externalTable = this.GetExternalTable(); 21361 if(externalTable) { 21362 ASPx.SetElementDisplay(externalTable, isVisible); 21363 if(this.customValidationEnabled) { 21364 var isValid = !isVisible ? true : void (0); 21365 this.UpdateErrorFrameAndFocus(false , true , isValid ); 21366 } 21367 } 21368 ASPxClientControl.prototype.SetVisible.call(this, isVisible); 21369 }, 21370 GetStateHiddenFieldName: function() { 21371 return this.uniqueID + "$State"; 21372 }, 21373 GetValueInputToValidate: function() { 21374 return this.GetInputElement(); 21375 }, 21376 IsVisible: function() { 21377 if(!this.clientVisible) 21378 return false; 21379 var element = this.GetMainElement(); 21380 if(!element) 21381 return false; 21382 while(element && element.tagName != "BODY") { 21383 if(element.getAttribute("errorFrame") != "errorFrame" && (!ASPx.GetElementVisibility(element) || !ASPx.GetElementDisplay(element))) 21384 return false; 21385 element = element.parentNode; 21386 } 21387 return true; 21388 }, 21389 AdjustControlCore: function() { 21390 this.CollapseEditor(); 21391 this.UnstretchInputElement(); 21392 if(this.heightCorrectionRequired) 21393 this.CorrectEditorHeight(); 21394 }, 21395 CorrectEditorHeight: function() { 21396 }, 21397 UnstretchInputElement: function() { 21398 }, 21399 UseDelayedSpecialFocus: function() { 21400 return false; 21401 }, 21402 GetDelayedSpecialFocusTriggers: function() { 21403 return [ this.GetMainElement() ]; 21404 }, 21405 InitializeDelayedSpecialFocus: function() { 21406 if(!this.UseDelayedSpecialFocus()) 21407 return; 21408 this.specialFocusTimer = -1; 21409 var handler = function(evt) { this.OnDelayedSpecialFocusMouseDown(evt); }.aspxBind(this); 21410 var triggers = this.GetDelayedSpecialFocusTriggers(); 21411 for(var i = 0; i < triggers.length; i++) 21412 ASPx.Evt.AttachEventToElement(triggers[i], "mousedown", handler); 21413 }, 21414 OnDelayedSpecialFocusMouseDown: function(evt) { 21415 window.setTimeout(function() { this.SetFocus(); }.aspxBind(this), 0); 21416 }, 21417 IsFocusEventsLocked: function() { 21418 return this.focusEventsLocked; 21419 }, 21420 LockFocusEvents: function() { 21421 if(!this.focused) return; 21422 this.focusEventsLocked = true; 21423 }, 21424 UnlockFocusEvents: function() { 21425 this.focusEventsLocked = false; 21426 }, 21427 ForceRefocusEditor: function(evt, isNativeFocus) { 21428 if(ASPx.Browser.VirtualKeyboardSupported && !this.ownerListBox) { 21429 var focusedEditor = ASPx.VirtualKeyboardUI.getFocusedEditor(); 21430 if(ASPx.VirtualKeyboardUI.getInputNativeFocusLocked() && (!focusedEditor || focusedEditor === this)) 21431 return; 21432 ASPx.VirtualKeyboardUI.setInputNativeFocusLocked(!isNativeFocus); 21433 }
21434 this.LockFocusEvents(); 21435 this.BlurInputElement(); 21436 window.setTimeout(function() { 21437 if(ASPx.Browser.VirtualKeyboardSupported && !this.ownerListBox) { 21438 ASPx.VirtualKeyboardUI.setFocusEditorCore(this); 21439 } else { 21440 this.SetFocus(); 21441 } 21442 }.aspxBind(this), 0); 21443 }, 21444 BlurInputElement: function() { 21445 var inputElement = this.GetFocusableInputElement(); 21446 if(inputElement && inputElement.blur) 21447 inputElement.blur(); 21448 }, 21449 IsEditorElement: function(element) { 21450 return this.GetMainElement() == element || ASPx.GetIsParent(this.GetMainElement(), element); 21451 }, 21452 IsClearButtonElement: function(element) { 21453 return false; 21454 }, 21455 IsElementBelongToInputElement: function(element) { 21456 return this.GetInputElement() == element; 21457 }, 21458 OnFocusCore: function() { 21459 if(this.UseDelayedSpecialFocus()) 21460 window.clearTimeout(this.specialFocusTimer); 21461 if(!this.IsFocusEventsLocked()){ 21462 this.focused = true; 21463 ASPx.SetFocusedEditor(this); 21464 if(this.styleDecoration) 21465 this.styleDecoration.Update(); 21466 if(this.isInitialized) 21467 this.RaiseFocus(); 21468 } 21469 else 21470 this.UnlockFocusEvents(); 21471 }, 21472 OnLostFocusCore: function() { 21473 if(!this.IsFocusEventsLocked()){ 21474 this.focused = false; 21475 if(ASPx.GetFocusedEditor() === this) 21476 ASPx.SetFocusedEditor(null); 21477 if(this.styleDecoration) 21478 this.styleDecoration.Update(); 21479 this.RaiseLostFocus(); 21480 } 21481 }, 21482 OnFocus: function() { 21483 if(!this.specialKeyboardHandlingUsed) 21484 this.OnFocusCore(); 21485 }, 21486 OnLostFocus: function() { 21487 if(this.isInitialized && !this.specialKeyboardHandlingUsed) 21488 this.OnLostFocusCore(); 21489 }, 21490 OnSpecialFocus: function() { 21491 if(this.isInitialized) 21492 this.OnFocusCore(); 21493 }, 21494 OnSpecialLostFocus: function() { 21495 if(this.isInitialized) 21496 this.OnLostFocusCore(); 21497 }, 21498 OnMouseWheel: function(evt){ 21499 }, 21500 OnValidation: function(validationType) { 21501 if(this.customValidationEnabled && this.isInitialized && ASPx.IsExistsElement(this.GetMainElement()) && 21502 (!this.IsErrorFrameDisplayed() || this.GetElementRequiredForErrorFrame())) { 21503 this.BeginErrorFrameUpdate(); 21504 try { 21505 if(this.validateOnLeave || validationType != ValidationType.PersonalOnValueChanged) { 21506 this.SetIsValid(true, true ); 21507 this.SetErrorText(this.initialErrorText, true ); 21508 this.ValidateWithPatterns(); 21509 this.RaiseValidation(); 21510 } 21511 this.UpdateErrorFrameAndFocus(this.editorFocusingRequired(validationType)); 21512 } finally { 21513 this.EndErrorFrameUpdate(); 21514 } 21515 this.UpdateValidationSummaries(validationType); 21516 this.ariaExplanatoryTextManager.UpdateValidationState(validationType); 21517 } 21518 }, 21519 GetElementRequiredForErrorFrame: function() { 21520 return this.GetExternalTable(); 21521 }, 21522 editorFocusingRequired: function(validationType) { 21523 return !this.GetIsValid() && 21524 validationType == ValidationType.PersonalViaScript && this.setFocusOnError; 21525 }, 21526 OnValueChanged: function() { 21527 if(this.getProcessOnServerOnValueChanged()) 21528 this.SendPostBackInternal(""); 21529 }, 21530 getProcessOnServerOnValueChanged: function() { 21531 var processOnServer = this.RaiseValidationInternal(); 21532 return this.RaiseValueChangedEvent() && processOnServer; 21533 }, 21534 ParseValue: function() { 21535 }, 21536 RaisePersonalStandardValidation: function() { 21537 if(ASPx.IsFunction(window.ValidatorOnChange)) { 21538 var inputElement = this.GetValueInputToValidate(); 21539 if(inputElement && inputElement.Validators) 21540 window.ValidatorOnChange({ srcElement: inputElement }); 21541 } 21542 }, 21543 RaiseValidationInternal: function() { 21544 if(this.isPostBackAllowed() && this.causesValidation && this.validateOnLeave) 21545 return ASPxClientEdit.ValidateGroup(this.validationGroup); 21546 else { 21547 this.OnValidation(ValidationType.PersonalOnValueChanged); 21548 return this.GetIsValid(); 21549 } 21550 }, 21551 RaiseValueChangedEvent: function(){ 21552 return this.RaiseValueChanged(); 21553 }, 21554 SendPostBackInternal: function(postBackArg) { 21555 if(ASPx.IsFunction(this.sendPostBackWithValidation)) 21556 this.sendPostBackWithValidation(postBackArg); 21557 else 21558 this.SendPostBack(postBackArg); 21559 }, 21560 SetElementToBeFocused: function() { 21561 if(this.IsVisible()) 21562 invalidEditorToBeFocused = this; 21563 }, 21564 GetFocusSelectAction: function() { 21565 return null; 21566 }, 21567 SetFocus: function() { 21568 var inputElement = this.GetFocusableInputElement(); 21569 if(!inputElement) return; 21570 var isIE9 = ASPx.Browser.IE && ASPx.Browser.Version >= 9; 21571 if((ASPx.GetActiveElement() != inputElement || isIE9) && _aspxIsEditorFocusable(inputElement)) 21572 ASPx.SetFocus(inputElement, this.GetFocusSelectAction()); 21573 }, 21574 SetFocusOnError: function() { 21575 if(invalidEditorToBeFocused == this) { 21576 this.SetFocus(); 21577 invalidEditorToBeFocused = null; 21578 } 21579 }, 21580 BeginErrorFrameUpdate: function() { 21581 if(!this.errorFrameUpdateLocked) 21582 this.errorFrameUpdateLocked = true; 21583 }, 21584 EndErrorFrameUpdate: function() { 21585 this.errorFrameUpdateLocked = false; 21586 var args = this.updateErrorFrameAndFocusLastCallArgs; 21587 if(args) { 21588 this.UpdateErrorFrameAndFocus(args[0], args[1]); 21589 delete this.updateErrorFrameAndFocusLastCallArgs; 21590 } 21591 }, 21592 UpdateErrorFrameAndFocus: function(setFocusOnError, ignoreVisibilityCheck, isValid) { 21593 if(!this.GetEnabled() || !ignoreVisibilityCheck && !this.GetVisible()) 21594 return; 21595 if(this.errorFrameUpdateLocked) { 21596 this.updateErrorFrameAndFocusLastCallArgs = [ setFocusOnError, ignoreVisibilityCheck ]; 21597 return; 21598 } 21599 if(this.styleDecoration) 21600 this.styleDecoration.Update(); 21601 if(typeof(isValid) == "undefined") 21602 isValid = this.GetIsValid(); 21603 if(isValid && this.IsErrorFrameDisplayed()) 21604 this.ChangeErrorFrameVisibility(false); 21605 else { 21606 var editorLocatedWithinVisibleContainer = this.IsVisible(); 21607 if(this.IsErrorFrameDisplayed()) { 21608 this.UpdateErrorCellContent(); 21609 this.ChangeErrorFrameVisibility(true); 21610 } 21611 if(editorLocatedWithinVisibleContainer) { 21612 if(setFocusOnError && this.setFocusOnError && invalidEditorToBeFocused == null) { 21613 this.SetElementToBeFocused(); 21614 this.SetFocusOnError(); 21615 } 21616 } 21617 } 21618 }, 21619 ChangeErrorFrameVisibility: function(visible) { 21620 var externalTable = this.GetExternalTable(); 21621 var isStaticDisplay = this.display == ErrorFrameDisplay.Static; 21622 if(!isStaticDisplay && visible) { 21623 this.EnsureControlCellStylesLoaded(); 21624 this.RestoreControlCellStyles(); 21625 } 21626 this.ChangeErrorCellVisibility(visible, isStaticDisplay); 21627 if(!isStaticDisplay && !visible) { 21628 this.EnsureControlCellStylesLoaded(); 21629 this.ClearControlCellStyles(); 21630 }
21631 var validExternalTableClassName = isStaticDisplay ? ASPxEditExternalTableClassNames.ValidStaticTableClassName 21632 : ASPxEditExternalTableClassNames.ValidDynamicTableClassName; 21633 ASPx.ToggleClassNameToElement(externalTable, validExternalTableClassName, !visible); 21634 this.UpdateErrorCellParentRowVisibility(); 21635 }, 21636 ChangeErrorCellVisibility: function(visible, useVisibilityAttribute) { 21637 var errorCell = this.GetErrorCell(); 21638 if(errorCell) { 21639 if(useVisibilityAttribute) 21640 ASPx.SetElementVisibility(errorCell, visible); 21641 else { 21642 ASPx.SetElementDisplay(errorCell, visible); 21643 this.raiseErrorCellVisibilityChanged(); 21644 } 21645 } 21646 }, 21647 raiseErrorCellVisibilityChanged: function() { 21648 if(!this.errorCellVisibilityChanged.IsEmpty()) 21649 this.errorCellVisibilityChanged.FireEvent(this); 21650 }, 21651 UpdateErrorCellParentRowVisibility: function() { 21652 var errorCell = this.GetErrorCell(); 21653 if(!errorCell || this.display == ErrorFrameDisplay.Static) 21654 return; 21655 var displayedCellCount = 0; 21656 var errorCellParentRow = errorCell.parentNode; 21657 for(var i = 0; i < errorCellParentRow.cells.length; i++) { 21658 var cell = errorCellParentRow.cells[i]; 21659 if(ASPx.GetElementDisplay(cell)) 21660 displayedCellCount++; 21661 } 21662 ASPx.SetElementDisplay(errorCellParentRow, displayedCellCount > 0); 21663 }, 21664 EnsureControlCellStylesLoaded: function() { 21665 if(typeof(this.controlCellStyles) == "undefined") { 21666 var controlCell = this.GetControlCell(); 21667 this.controlCellStyles = { 21668 cssClass: controlCell.className,
21669 style: this.ExtractElementStyleStringIgnoringVisibilityProps(controlCell) 21670 }; 21671 } 21672 }, 21673 ClearControlCellStyles: function() { 21674 this.ClearElementStyle(this.GetControlCell()); 21675 }, 21676 RestoreControlCellStyles: function() { 21677 var controlCell = this.GetControlCell(); 21678 var externalTable = this.GetExternalTable(); 21679 if(ASPx.Browser.WebKitFamily) 21680 this.MakeBorderSeparateForTable(externalTable); 21681 controlCell.className = this.controlCellStyles.cssClass; 21682 controlCell.style.cssText = this.controlCellStyles.style; 21683 if(ASPx.Browser.WebKitFamily) 21684 this.UndoBorderSeparateForTable(externalTable); 21685 }, 21686 MakeBorderSeparateForTable: function(table) { 21687 ASPx.AddClassNameToElement(table, ASPxEditExternalTableClassNames.TableWithSeparateBordersClassName); 21688 }, 21689 UndoBorderSeparateForTable: function(table) { 21690 setTimeout(function () { 21691 ASPx.RemoveClassNameFromElement(table, ASPxEditExternalTableClassNames.TableWithSeparateBordersClassName); 21692 }, 0); 21693 }, 21694 ExtractElementStyleStringIgnoringVisibilityProps: function(element) { 21695 var savedVisibility = element.style.visibility; 21696 var savedDisplay = element.style.display; 21697 element.style.visibility = ""; 21698 element.style.display = ""; 21699 var styleStr = element.style.cssText; 21700 element.style.visibility = savedVisibility; 21701 element.style.display = savedDisplay; 21702 return styleStr; 21703 }, 21704 ClearElementStyle: function(element) { 21705 if(!element) 21706 return; 21707 element.className = ""; 21708 var excludedAttrNames = [ 21709 "width", "display", "visibility", 21710 "position", "left", "top", "z-index", 21711 "margin", "margin-top", "margin-right", "margin-bottom", "margin-left", 21712 "float", "clear" 21713 ]; 21714 var savedAttrValues = { }; 21715 for(var i = 0; i < excludedAttrNames.length; i++) { 21716 var attrName = excludedAttrNames[i]; 21717 var attrValue = element.style[attrName]; 21718 if(attrValue) 21719 savedAttrValues[attrName] = attrValue; 21720 } 21721 element.style.cssText = ""; 21722 for(var styleAttrName in savedAttrValues) 21723 if(savedAttrValues.hasOwnProperty(styleAttrName)) 21724 element.style[styleAttrName] = savedAttrValues[styleAttrName]; 21725 }, 21726 Clear: function() { 21727 this.SetValue(null); 21728 this.SetIsValid(true); 21729 return true; 21730 }, 21731 ResetEditorState: function() { }, 21732 UpdateErrorCellContent: function() { 21733 if(this.errorDisplayMode.indexOf("t") > -1) 21734 this.UpdateErrorText(); 21735 if(this.errorDisplayMode == "i") 21736 this.UpdateErrorImage(); 21737 }, 21738 UpdateErrorImage: function() { 21739 var image = this.GetErrorImage(); 21740 if(ASPx.IsExistsElement(image)) { 21741 if(this.accessibilityCompliant) { 21742 ASPx.Attr.SetAttribute(image, "aria-label", this.errorText); 21743 var innerImg = ASPx.GetNodeByTagName(image, "IMG", 0); 21744 if(ASPx.IsExists(innerImg)) 21745 innerImg.alt = this.errorText; 21746 } 21747 image.alt = this.errorText; 21748 image.title = this.errorText; 21749 } else { 21750 this.UpdateErrorText(); 21751 } 21752 }, 21753 UpdateErrorText: function() { 21754 var errorTextCell = this.GetErrorTextCell(); 21755 if(ASPx.IsExistsElement(errorTextCell)) 21756 errorTextCell.innerHTML = this.HtmlEncode(this.errorText); 21757 }, 21758 ValidateWithPatterns: function() { 21759 if(this.validationPatterns.length > 0) { 21760 var value = this.GetValue(); 21761 for(var i = 0; i < this.validationPatterns.length; i++) { 21762 var validator = this.validationPatterns[i]; 21763 if(!validator.EvaluateIsValid(value)) { 21764 this.SetIsValid(false, true ); 21765 this.SetErrorText(validator.errorText, true ); 21766 return; 21767 } 21768 } 21769 } 21770 }, 21771 OnSpecialKeyDown: function(evt){ 21772 this.RaiseKeyDown(evt); 21773 var handler = this.keyDownHandlers[evt.keyCode]; 21774 if(handler) 21775 return this[handler](evt); 21776 return false; 21777 }, 21778 OnSpecialKeyPress: function(evt){ 21779 this.RaiseKeyPress(evt); 21780 var handler = this.keyPressHandlers[evt.keyCode]; 21781 if(handler) 21782 return this[handler](evt); 21783 if(ASPx.Browser.NetscapeFamily || ASPx.Browser.Opera){ 21784 if(evt.keyCode == ASPx.Key.Enter) 21785 return this.enterProcessed; 21786 } 21787 return false; 21788 }, 21789 OnSpecialKeyUp: function(evt){ 21790 this.RaiseKeyUp(evt); 21791 var handler = this.keyUpHandlers[evt.keyCode]; 21792 if(handler) 21793 return this[handler](evt); 21794 return false; 21795 }, 21796 OnKeyDown: function(evt) { 21797 if(!this.specialKeyboardHandlingUsed)
21798 this.RaiseKeyDown(evt); 21799 }, 21800 OnKeyPress: function(evt) { 21801 if(!this.specialKeyboardHandlingUsed) 21802 this.RaiseKeyPress(evt); 21803 }, 21804 OnKeyUp: function(evt) { 21805 if(!this.specialKeyboardHandlingUsed) 21806 this.RaiseKeyUp(evt); 21807 }, 21808 RaiseKeyDown: function(evt){ 21809 if(!this.KeyDown.IsEmpty()){ 21810 var args = new ASPxClientEditKeyEventArgs(evt); 21811 this.KeyDown.FireEvent(this, args); 21812 } 21813 }, 21814 RaiseKeyPress: function(evt){ 21815 if(!this.KeyPress.IsEmpty()){ 21816 var args = new ASPxClientEditKeyEventArgs(evt); 21817 this.KeyPress.FireEvent(this, args); 21818 } 21819 }, 21820 RaiseKeyUp: function(evt){ 21821 if(!this.KeyUp.IsEmpty()){ 21822 var args = new ASPxClientEditKeyEventArgs(evt); 21823 this.KeyUp.FireEvent(this, args); 21824 } 21825 }, 21826 RaiseFocus: function(){ 21827 if(!this.GotFocus.IsEmpty()){ 21828 var args = new ASPxClientEventArgs(); 21829 this.GotFocus.FireEvent(this, args); 21830 } 21831 }, 21832 RaiseLostFocus: function(){ 21833 if(!this.LostFocus.IsEmpty()){ 21834 var args = new ASPxClientEventArgs(); 21835 this.LostFocus.FireEvent(this, args); 21836 } 21837 }, 21838 RaiseValidation: function() { 21839 if(this.customValidationEnabled && !this.Validation.IsEmpty()) { 21840 var currentValue = this.GetValue(); 21841 var args = new ASPxClientEditValidationEventArgs(currentValue, this.errorText, this.GetIsValid()); 21842 this.Validation.FireEvent(this, args); 21843 this.SetErrorText(args.errorText, true ); 21844 this.SetIsValid(args.isValid, true ); 21845 if(args.value != currentValue) 21846 this.SetValue(args.value); 21847 } 21848 }, 21849 RaiseValueChanged: function(){ 21850 var processOnServer = this.isPostBackAllowed(); 21851 if(!this.ValueChanged.IsEmpty()){ 21852 var args = new ASPxClientProcessingModeEventArgs(processOnServer); 21853 this.ValueChanged.FireEvent(this, args); 21854 processOnServer = args.processOnServer; 21855 } 21856 return processOnServer; 21857 }, 21858 isPostBackAllowed: function() { 21859 return this.autoPostBack; 21860 }, 21861 AddDecorationStyle: function(key, className, cssText) { 21862 if(!this.styleDecoration) 21863 this.RequireStyleDecoration(); 21864 this.styleDecoration.AddStyle(key, className, cssText); 21865 }, 21866 RequireStyleDecoration: function() { 21867 this.styleDecoration = this.CreateStyleDecoration(); 21868 this.PopulateStyleDecorationPostfixes(); 21869 }, 21870 CreateStyleDecoration: function() { 21871 return new ASPx.EditorStyleDecoration(this); 21872 }, 21873 PopulateStyleDecorationPostfixes: function() { 21874 this.styleDecoration.AddPostfix(""); 21875 }, 21876 LockStyleDecorationUpdate: function() { 21877 if(this.styleDecoration) 21878 this.styleDecoration.LockUpdate(); 21879 }, 21880 UnlockStyleDecorationUpdate: function() { 21881 if(this.styleDecoration) 21882 this.styleDecoration.UnlockUpdate(); 21883 }, 21884 Focus: function(){ 21885 this.SetFocus(); 21886 }, 21887 GetIsValid: function() { 21888 var hasRequiredInputElement = !this.RequireInputElementToValidate() || ASPx.IsExistsElement(this.GetInputElement()); 21889 if(!hasRequiredInputElement || this.IsErrorFrameDisplayed() && !ASPx.IsExistsElement(this.GetElementRequiredForErrorFrame())) 21890 return true; 21891 return this.isValid; 21892 }, 21893 RequireInputElementToValidate: function() { 21894 return true; 21895 }, 21896 IsErrorFrameDisplayed: function() { 21897 return this.display !== ErrorFrameDisplay.None; 21898 }, 21899 GetErrorText: function(){ 21900 return this.errorText; 21901 }, 21902 SetIsValid: function(isValid, validating){ 21903 if(this.customValidationEnabled && this.isValid != isValid) { 21904 this.isValid = isValid; 21905 this.UpdateErrorFrameAndFocus(false ); 21906 this.UpdateClientValidationState(); 21907 if(!validating) 21908 this.UpdateValidationSummaries(ValidationType.PersonalViaScript); 21909 } 21910 }, 21911 SetErrorText: function(errorText, validating){ 21912 if(this.customValidationEnabled && this.errorText != errorText) { 21913 this.errorText = errorText; 21914 this.UpdateErrorFrameAndFocus(false ); 21915 this.UpdateClientValidationState(); 21916 if(!validating) 21917 this.UpdateValidationSummaries(ValidationType.PersonalViaScript); 21918 } 21919 }, 21920 Validate: function(){ 21921 this.ParseValue(); 21922 this.OnValidation(ValidationType.PersonalViaScript); 21923 }, 21924 GetModifyEvent: function() { 21925 return this.ValueChanged; 21926 }, 21927 EnsureRequiredNativeAttributesExists: function() { } 21928}); 21929ASPx.Ident.scripts.ASPxClientEdit = true; 21930ASPx.focusedEditorName = ""; 21931ASPx.GetFocusedEditor = function() { 21932 var focusedEditor = ASPx.GetControlCollection().Get(ASPx.focusedEditorName); 21933 if(focusedEditor && !focusedEditor.focused){ 21934 ASPx.SetFocusedEditor(null); 21935 focusedEditor = null; 21936 } 21937 return focusedEditor; 21938}; 21939ASPx.SetFocusedEditor = function(editor) { 21940 ASPx.focusedEditorName = editor ? editor.name : ""; 21941}; 21942ASPx.FindAssociatedLabelElements = function(editor) { 21943 var assocciatedLabels = []; 21944 var inputElement = editor.GetInputElement();
21945 if(!ASPx.IsExists(inputElement) || !inputElement.id) 21946 return assocciatedLabels; 21947 var labels = ASPx.GetNodesByTagName(document, "LABEL"); 21948 for(var i = 0; i < labels.length; i++) { 21949 if(!!labels[i].htmlFor && labels[i].htmlFor === inputElement.id) 21950 assocciatedLabels.push(labels[i]); 21951 } 21952 return assocciatedLabels; 21953}; 21954var DisableAccessibilityExplanatoryTextManager = ASPx.CreateClass(null, { 21955 constructor: function(editor) { 21956 this.editor = editor; 21957 }, 21958 GetAdditionalTextRowId: function() { 21959 return this.editor.name + EditElementSuffix.AccessibilityAdditionalTextRow; 21960 }, 21961 GetErrorTextElement: function () { 21962 return !!this.editor.GetErrorTextCell() ? this.editor.GetErrorTextCell() : this.editor.GetErrorImage(); 21963 }, 21964 GetTextElement: function() { return null; }, 21965 SetCaptionAssociating: function() { }, 21966 UpdateText: function() { }, 21967 UpdateValidationState: function(validationType) { }, 21968 ToggleErrorAlert: function() { }, 21969 SetOrRemoveText: function(accessibilityElements, textElement, setText, isLabel, isFirst) { } 21970}); 21971var EditAccessibilityExplanatoryTextManager = ASPx.CreateClass(DisableAccessibilityExplanatoryTextManager, { 21972 constructor: function(editor) { 21973 this.constructor.prototype.constructor.call(this, editor); 21974 this.invisibleRowCssClassName = "dxAIR"; 21975 }, 21976 GetTextElement: function() { 21977 var mainElement = this.editor.GetMainElement(); 21978 if(!mainElement) return null; 21979 var explanatoryText = ""; 21980 var explanatoryTextElement = null; 21981 if(!!this.editor.nullText) 21982 explanatoryText = this.editor.nullText; 21983 else if(!!this.editor.helpTextObj) 21984 explanatoryTextElement = this.editor.helpTextObj.helpTextElement; 21985 else if(!!mainElement.title) 21986 explanatoryText = mainElement.title; 21987 if(explanatoryText && mainElement.tagName == "TABLE") { 21988 var assistantElement = this.editor.GetAccessibilityFirstActiveElement(); 21989 if(assistantElement) 21990 ASPx.Attr.Aria.AppendLabel(assistantElement, explanatoryText, true); 21991 } 21992 return explanatoryTextElement; 21993 }, 21994 SetCaptionAssociating: function() { 21995 var captionCell = this.editor.GetCaptionCell(); 21996 if(!captionCell || captionCell.childNodes[0].tagName == "LABEL") return; 21997 var labelElement = captionCell.childNodes[0]; 21998 ASPx.EditAccessibilityExplanatoryTextManager.SetLabelAssociating(this.editor, this.editor.GetAccessibilityFirstActiveElement(), labelElement); 21999 }, 22000 UpdateText: function() { 22001 var additionalTextElement = this.GetTextElement(); 22002 if(ASPx.IsExists(additionalTextElement)) { 22003 var pronounceElement = this.editor.GetAccessibilityFirstActiveElement(); 22004 var hasAnyLabel = !!ASPx.Attr.GetAttribute(pronounceElement, "aria-label") || 22005 !!ASPx.Attr.GetAttribute(pronounceElement, "aria-labelledby") || 22006 ASPx.FindAssociatedLabelElements(this.editor).length > 0; 22007 this.SetOrRemoveText([pronounceElement], additionalTextElement, true, !hasAnyLabel, false); 22008 } 22009 }, 22010 UpdateValidationState: function(validationType) { 22011 if(validationType == ValidationType.PersonalOnValueChanged && this.editor.accessibilityHelper) return; 22012 var accessibilityElements = this.editor.GetAccessibilityActiveElements(); 22013 var errorTextElement = this.GetErrorTextElement(); 22014 this.SetOrRemoveText(accessibilityElements, errorTextElement, !this.editor.isValid, false, true); 22015 if(accessibilityElements.length > 0 && !!errorTextElement) { 22016 for(var i = 0; i < accessibilityElements.length; i++) { 22017 if(!ASPx.IsExists(accessibilityElements[i])) continue; 22018 ASPx.Attr.SetOrRemoveAttribute(accessibilityElements[i], "aria-invalid", !this.editor.isValid); 22019 } 22020 } 22021 }, 22022 ToggleErrorAlert: function() { 22023 var errorTextElement = this.GetErrorTextElement(); 22024 ASPx.SetElementDisplay(errorTextElement, false); 22025 ASPx.Attr.SetAttribute(errorTextElement, 'role', 'alert'); 22026 ASPx.SetElementDisplay(errorTextElement, true); 22027 setTimeout(function() { ASPx.Attr.RemoveAttribute(errorTextElement, 'role'); }, 500); 22028 }, 22029 SetOrRemoveText: function(accessibilityElements, textElement, setText, isLabel, isFirst) { 22030 var idsRefAttribute = isLabel ? ASPx.Attr.Aria.labelled : ASPx.Attr.Aria.described; 22031 if(!textElement) return; 22032 var textId = !!textElement.id ? textElement.id : textElement.parentNode.id; 22033 for(var i = 0; i < accessibilityElements.length; i++) { 22034 if(!accessibilityElements[i]) continue; 22035 var descRefString = ASPx.Attr.GetAttribute(accessibilityElements[i], idsRefAttribute); 22036 var descRefIds = !!descRefString ? descRefString.split(" ") : [ ]; 22037 var descIndex = descRefIds.indexOf(textId); 22038 if(setText && descIndex == -1) { 22039 if(isFirst) 22040 descRefIds.unshift(textId); 22041 else 22042 descRefIds.push(textId); 22043 } 22044 else if(!setText && descIndex > -1) 22045 descRefIds.splice(descIndex, 1); 22046 ASPx.Attr.SetOrRemoveAttribute(accessibilityElements[i], idsRefAttribute, descRefIds.join(" ")); 22047 } 22048 } 22049}); 22050ASPx.DisableAccessibilityExplanatoryTextManager = DisableAccessibilityExplanatoryTextManager;
22051ASPx.EditAccessibilityExplanatoryTextManager = EditAccessibilityExplanatoryTextManager; 22052ASPx.EditAccessibilityExplanatoryTextManager.SetLabelAssociating = function(editor, activeElement, labelElement) { 22053 var clickHandler = function(evt) { 22054 if(editor && editor.OnAssociatedLabelClick) 22055 editor.OnAssociatedLabelClick(evt); 22056 else 22057 activeElement.click(); 22058 }; 22059 ASPx.Evt.AttachEventToElement(labelElement, "click", clickHandler); 22060 if(!!editor) { 22061 var hasAriaLabel = !!ASPx.Attr.GetAttribute(activeElement, "aria-label"); 22062 editor.ariaExplanatoryTextManager.SetOrRemoveText([activeElement], labelElement, true, !hasAriaLabel, true); 22063 } 22064}; 22065ASPxClientEdit.ClearEditorsInContainer = function(container, validationGroup, clearInvisibleEditors) { 22066 invalidEditorToBeFocused = null; 22067 ASPx.ProcessEditorsInContainer(container, ASPx.ClearProcessingProc, ASPx.ClearChoiceCondition, validationGroup, clearInvisibleEditors, true ); 22068 ASPxClientEdit.ClearExternalControlsInContainer(container, validationGroup, clearInvisibleEditors, true ); 22069}; 22070ASPxClientEdit.ClearEditorsInContainerById = function(containerId, validationGroup, clearInvisibleEditors) { 22071 var container = document.getElementById(containerId); 22072 this.ClearEditorsInContainer(container, validationGroup, clearInvisibleEditors); 22073}; 22074ASPxClientEdit.ClearGroup = function(validationGroup, clearInvisibleEditors) { 22075 return this.ClearEditorsInContainer(null, validationGroup, clearInvisibleEditors); 22076}; 22077ASPxClientEdit.ValidateEditorsInContainer = function(container, validationGroup, validateInvisibleEditors) { 22078 var summaryCollection; 22079 if(ASPx.Ident.scripts.ASPxClientValidationSummary) { 22080 summaryCollection = ASPx.GetClientValidationSummaryCollection(); 22081 summaryCollection.AllowNewErrorsAccepting(validationGroup); 22082 } 22083 var validationResult = ASPx.ProcessEditorsInContainer(container, ASPx.ValidateProcessingProc, _aspxValidateChoiceCondition, validationGroup, validateInvisibleEditors, 22084 false ); 22085 validationResult.isValid = ASPxClientEdit.ValidateExternalControlsInContainer(container, validationGroup, validateInvisibleEditors, 22086 false ) && validationResult.isValid; 22087 if(typeof(validateInvisibleEditors) == "undefined") 22088 validateInvisibleEditors = false; 22089 if(typeof(validationGroup) == "undefined") 22090 validationGroup = null; 22091 validationResult.isValid = ASPx.GetControlCollection().RaiseValidationCompleted(container, validationGroup, 22092 validateInvisibleEditors, validationResult.isValid, validationResult.firstInvalid, validationResult.firstVisibleInvalid); 22093 if(summaryCollection) 22094 summaryCollection.ForbidNewErrorsAccepting(validationGroup); 22095 if(!validationResult.isValid && !!validationResult.firstVisibleInvalid && validationResult.firstVisibleInvalid.accessibilityCompliant && !validationResult.firstVisibleInvalid.setFocusOnError) { 22096 var accessInvalidControl = validationResult.firstVisibleInvalid; 22097 if(!summaryCollection && !accessInvalidControl.focused) { 22098 var beforeDelayActiveElement = ASPx.GetActiveElement(); 22099 setTimeout(function() { 22100 var currentActiveElement = ASPx.GetActiveElement(); 22101 if(accessInvalidControl.focused || (currentActiveElement != beforeDelayActiveElement && ASPx.Attr.IsExistsAttribute(currentActiveElement, 'role'))) 22102 return; 22103 accessInvalidControl.ariaExplanatoryTextManager.ToggleErrorAlert(); 22104 }, 500); 22105 } 22106 } 22107 return validationResult.isValid; 22108}; 22109ASPxClientEdit.ValidateEditorsInContainerById = function(containerId, validationGroup, validateInvisibleEditors) { 22110 var container = document.getElementById(containerId); 22111 return this.ValidateEditorsInContainer(container, validationGroup, validateInvisibleEditors); 22112}; 22113ASPxClientEdit.ValidateGroup = function(validationGroup, validateInvisibleEditors) { 22114 return this.ValidateEditorsInContainer(null, validationGroup, validateInvisibleEditors); 22115}; 22116ASPxClientEdit.AreEditorsValid = function(containerOrContainerId, validationGroup, checkInvisibleEditors) { 22117 var container = typeof(containerOrContainerId) == "string" ? document.getElementById(containerOrContainerId) : containerOrContainerId; 22118 var checkResult = ASPx.ProcessEditorsInContainer(container, ASPx.EditorsValidProcessingProc, _aspxEditorsValidChoiceCondition, validationGroup, 22119 checkInvisibleEditors, false ); 22120 checkResult.isValid = ASPxClientEdit.AreExternalControlsValidInContainer(containerOrContainerId, validationGroup, 22121 checkInvisibleEditors, false ) && checkResult.isValid; 22122 return checkResult.isValid; 22123}; 22124ASPxClientEdit.AreExternalControlsValidInContainer = function(containerId, validationGroup, validateInvisibleEditors, processDisabledEditors) { 22125 if(ASPx.Ident.scripts.ASPxClientHtmlEditor) 22126 return ASPxClientHtmlEditor.AreEditorsValidInContainer(containerId, validationGroup, validateInvisibleEditors, processDisabledEditors); 22127 return true; 22128}; 22129ASPxClientEdit.ClearExternalControlsInContainer = function(containerId, validationGroup, validateInvisibleEditors, processDisabledEditors) { 22130 if(ASPx.Ident.scripts.ASPxClientHtmlEditor) 22131 return ASPxClientHtmlEditor.ClearEditorsInContainer(containerId, validationGroup, validateInvisibleEditors, processDisabledEditors); 22132 return true; 22133};
22134ASPxClientEdit.ValidateExternalControlsInContainer = function(containerId, validationGroup, validateInvisibleEditors, processDisabledEditors) { 22135 if(ASPx.Ident.scripts.ASPxClientHtmlEditor) 22136 return ASPxClientHtmlEditor.ValidateEditorsInContainer(containerId, validationGroup, validateInvisibleEditors, processDisabledEditors); 22137 return true; 22138}; 22139ASPxClientEdit.AttachEditorModificationListener = function(handler, predicate) { 22140 var processAction = function(event) { event.AddHandler(handler); }; 22141 ASPxClientEdit.ProcessEditorModificationListener(handler, processAction, predicate); 22142}; 22143ASPxClientEdit.DetachEditorModificationListener = function(handler, predicate) { 22144 var processAction = function(event) { event.RemoveHandler(handler); }; 22145 ASPxClientEdit.ProcessEditorModificationListener(handler, processAction, predicate); 22146}; 22147ASPxClientEdit.ProcessEditorModificationListener = function(handler, action, predicate) { 22148 ASPx.GetControlCollection().ForEachControl(function(control) { 22149 if(control.GetModifyEvent && predicate(control)) { 22150 if(control.isNative) 22151 control.EnsureRequiredNativeAttributesExists(); 22152 action(control.GetModifyEvent()); 22153 } 22154 }); 22155}; 22156var ASPxClientEditKeyEventArgs = ASPx.CreateClass(ASPxClientEventArgs, { 22157 constructor: function(htmlEvent) { 22158 this.constructor.prototype.constructor.call(this); 22159 this.htmlEvent = htmlEvent; 22160 } 22161}); 22162var ASPxClientEditValidationEventArgs = ASPx.CreateClass(ASPxClientEventArgs, { 22163 constructor: function(value, errorText, isValid) { 22164 this.constructor.prototype.constructor.call(this); 22165 this.errorText = errorText; 22166 this.isValid = isValid; 22167 this.value = value; 22168 } 22169}); 22170ASPx.ProcessEditorsInContainer = function(container, processingProc, choiceCondition, validationGroup, processInvisibleEditors, processDisabledEditors) { 22171 var allProcessedSuccessfull = true; 22172 var firstInvalid = null; 22173 var firstVisibleInvalid = null; 22174 var invalidEditorToBeFocused = null; 22175 ASPx.GetControlCollection().ForEachControl(function(control) { 22176 var canValidate = ASPx.CanValidateControl(control, container, processingProc, choiceCondition, validationGroup, processInvisibleEditors, processDisabledEditors); 22177 if(!canValidate) return; 22178 var isSuccess = processingProc(control); 22179 if(!isSuccess) { 22180 allProcessedSuccessfull = false; 22181 if(firstInvalid == null) 22182 firstInvalid = control; 22183 var isVisible = control.IsVisible(); 22184 if(isVisible && firstVisibleInvalid == null) 22185 firstVisibleInvalid = control; 22186 if(control.setFocusOnError && invalidEditorToBeFocused == null && isVisible) 22187 invalidEditorToBeFocused = control; 22188 } 22189 }, this); 22190 if(invalidEditorToBeFocused != null) 22191 invalidEditorToBeFocused.SetFocus(); 22192 return new ASPxValidationResult(allProcessedSuccessfull, firstInvalid, firstVisibleInvalid); 22193}; 22194ASPx.CanValidateControl = function(control, container, processingProc, choiceCondition, validationGroup, processInvisibleEditors, processDisabledEditors) { 22195 var needToProcessRatingControl = window.ASPxClientRatingControl && (control instanceof ASPxClientRatingControl) && processingProc === ASPx.ClearProcessingProc; 22196 var mainElement = control.GetMainElement(); 22197 if(!ASPx.Ident.IsASPxClientEdit(control) && !needToProcessRatingControl) 22198 return false; 22199 if(ASPx.Ident.isDialogInvisibleControl(control) || ASPx.Ident.isBatchEditUnusedEditor(control)) 22200 return false; 22201 if(!processDisabledEditors && !control.GetEnabled()) 22202 return false; 22203 if(!mainElement || (container && !ASPx.GetIsParent(container, mainElement))) 22204 return false; 22205 if(!processInvisibleEditors && !control.IsVisible()) 22206 return false; 22207 if(choiceCondition && !choiceCondition(control, validationGroup)) 22208 return false; 22209 return true; 22210}; 22211var ASPxValidationResult = ASPx.CreateClass(null, { 22212 constructor: function(isValid, firstInvalid, firstVisibleInvalid) { 22213 this.isValid = isValid; 22214 this.firstInvalid = firstInvalid; 22215 this.firstVisibleInvalid = firstVisibleInvalid; 22216 } 22217}); 22218ASPx.ClearChoiceCondition = function(edit, validationGroup) { 22219 return !ASPx.IsExists(validationGroup) || (edit.validationGroup == validationGroup); 22220}; 22221function _aspxValidateChoiceCondition(edit, validationGroup) { 22222 return ASPx.ClearChoiceCondition(edit, validationGroup) && edit.customValidationEnabled; 22223} 22224function _aspxEditorsValidChoiceCondition(edit, validationGroup) { 22225 return _aspxValidateChoiceCondition(edit, validationGroup); 22226} 22227function wrapLostFocusHandler(handler) { 22228 if(ASPx.Browser.Edge) { 22229 return function(name) { 22230 var edit = ASPx.GetControlCollection().Get(name); 22231 if(edit && !ASPx.IsElementVisible(edit.GetMainElement())) 22232 setTimeout(handler, 0, name); 22233 else 22234 handler(name); 22235 }; 22236 } 22237 return handler; 22238} 22239ASPx.EGotFocus = function(name) { 22240 var edit = ASPx.GetControlCollection().Get(name); 22241 if(!edit) return; 22242 if(!edit.isInitialized){ 22243 var inputElement = edit.GetFocusableInputElement(); 22244 if(inputElement && inputElement === document.activeElement) { 22245 if(ASPx.Browser.Firefox) 22246 window.setTimeout(function() { document.activeElement.blur(); }, 0); 22247 else 22248 document.activeElement.blur(); 22249 } 22250 return; 22251 } 22252 if(ASPx.Browser.VirtualKeyboardSupported && !edit.ownerListBox) 22253 ASPx.VirtualKeyboardUI.onCallingVirtualKeyboard(edit, false); 22254 else
22255 edit.OnFocus(); 22256}; 22257ASPx.ELostFocusCore = function(name) { 22258 var edit = ASPx.GetControlCollection().Get(name); 22259 if(ASPx.Browser.VirtualKeyboardSupported && (!edit || !edit.ownerListBox)) { 22260 var supressLostFocus = ASPx.VirtualKeyboardUI.isInputNativeBluring(); 22261 if(supressLostFocus) 22262 return; 22263 ASPx.VirtualKeyboardUI.resetFocusedEditor(); 22264 } 22265 if(edit != null) 22266 edit.OnLostFocus(); 22267}; 22268ASPx.ELostFocus = wrapLostFocusHandler(ASPx.ELostFocusCore); 22269ASPx.ESGotFocus = function(name) { 22270 var edit = ASPx.GetControlCollection().Get(name); 22271 if(!edit) return; 22272 if(ASPx.Browser.VirtualKeyboardSupported && !edit.ownerListBox) { 22273 ASPx.VirtualKeyboardUI.onCallingVirtualKeyboard(edit, true); 22274 } else { 22275 edit.OnSpecialFocus(); 22276 } 22277}; 22278ASPx.ESLostFocusCore = function(name) { 22279 var edit = ASPx.GetControlCollection().Get(name); 22280 if(ASPx.Browser.VirtualKeyboardSupported && (!edit || !edit.ownerListBox)) { 22281 var supressLostFocus = ASPx.VirtualKeyboardUI.isInputNativeBluring(); 22282 if(supressLostFocus) 22283 return; 22284 ASPx.VirtualKeyboardUI.resetFocusedEditor(); 22285 } 22286 if(!edit) return; 22287 if(edit.UseDelayedSpecialFocus()) 22288 edit.specialFocusTimer = window.setTimeout(function() { edit.OnSpecialLostFocus(); }, 30); 22289 else
22290 edit.OnSpecialLostFocus(); 22291}; 22292ASPx.ESLostFocus = wrapLostFocusHandler(ASPx.ESLostFocusCore); 22293ASPx.EValueChanged = function(name) { 22294 var edit = ASPx.GetControlCollection().Get(name); 22295 if(edit != null) 22296 edit.OnValueChanged(); 22297}; 22298ASPx.VirtualKeyboardUI = (function() { 22299 var focusedEditor = null; 22300 var inputNativeFocusLocked = false; 22301 function elementBelongsToEditor(element) { 22302 if(!element) return false; 22303 var isBelongsToEditor = false; 22304 ASPx.GetControlCollection().ForEachControl(function(control) { 22305 if(ASPx.Ident.IsASPxClientEdit(control) && control.IsEditorElement(element)) { 22306 isBelongsToEditor = true; 22307 return true; 22308 } 22309 }, this); 22310 return isBelongsToEditor; 22311 } 22312 function elementBelongsToFocusedEditor(element) { 22313 return focusedEditor && focusedEditor.IsEditorElement(element); 22314 } 22315 return { 22316 onTouchStart: function (evt) { 22317 if (!ASPx.Browser.VirtualKeyboardSupported || this.isGooglePlaceAutocompleteElementTap(evt)) return; 22318 inputNativeFocusLocked = false; 22319 if(focusedEditor) 22320 focusedEditor.onVirtualKeyboardUITouchStart(evt); 22321 if(ASPx.TouchUIHelper.pointerEnabled) { 22322 if(evt.pointerType !== ASPx.TouchUIHelper.pointerType.Touch || 22323 ASPx.Browser.AndroidMobilePlatform) 22324 return; 22325 this.processFocusEditorControl(evt); 22326 } else 22327 ASPx.TouchUIHelper.handleFastTapIfRequired(evt, function(){ this.processFocusEditorControl(evt); }.aspxBind(this), false); 22328 }, 22329 processFocusEditorControl: function(evt) { 22330 var evtSource = ASPx.Evt.GetEventSource(evt); 22331 var timeEditHasAppliedFocus = focusedEditor && (ASPx.Ident.IsASPxClientTimeEdit && ASPx.Ident.IsASPxClientTimeEdit(focusedEditor)); 22332 var focusedTimeEditBelongsToDateEdit = timeEditHasAppliedFocus && focusedEditor.OwnerDateEdit && focusedEditor.OwnerDateEdit.GetShowTimeSection(); 22333 if(focusedTimeEditBelongsToDateEdit) { 22334 focusedEditor.OwnerDateEdit.ForceRefocusTimeSectionTimeEdit(evtSource); 22335 return; 22336 } 22337 var elementWithNativeFocus = ASPx.GetActiveElement(); 22338 var someEditorInputIsFocused = elementBelongsToEditor(elementWithNativeFocus); 22339 var touchKeyboardIsVisible = someEditorInputIsFocused; 22340 var tapOutsideEditorAndInputs = !elementBelongsToEditor(evtSource) && !ASPx.Ident.IsFocusableElementRegardlessTabIndex(evtSource); 22341 var blurToHideTouchKeyboard = touchKeyboardIsVisible && tapOutsideEditorAndInputs; 22342 if(blurToHideTouchKeyboard) { 22343 elementWithNativeFocus.blur(); 22344 return; 22345 } 22346 var tapOutsideFocusedEditor = focusedEditor && !elementBelongsToFocusedEditor(evtSource); 22347 if(tapOutsideFocusedEditor) { 22348 var focusedEditorWithBluredInput = !elementBelongsToFocusedEditor(elementWithNativeFocus); 22349 if(focusedEditorWithBluredInput) 22350 this.lostAppliedFocusOfEditor(); 22351 } 22352 }, 22353 smartFocusEditor: function(edit) { 22354 if(!edit.focused) { 22355 this.setInputNativeFocusLocked(true); 22356 this.setFocusEditorCore(edit); 22357 } else { 22358 edit.ForceRefocusEditor(); 22359 } 22360 }, 22361 setFocusEditorCore: function(edit) { 22362 if(ASPx.Browser.MacOSMobilePlatform) { 22363 var timeoutDuration = ASPx.Browser.Chrome ? 250 : 30; 22364 window.setTimeout(function(){ edit.SetFocus(); }, timeoutDuration); 22365 } else { 22366 edit.SetFocus(); 22367 } 22368 }, 22369 onCallingVirtualKeyboard: function(edit, isSpecial) { 22370 this.setAppliedFocusOfEditor(edit, isSpecial); 22371 if(edit.specialKeyboardHandlingUsed == isSpecial && inputNativeFocusLocked) 22372 edit.BlurInputElement(); 22373 }, 22374 isInputNativeBluring: function() { 22375 return focusedEditor && inputNativeFocusLocked; 22376 }, 22377 setInputNativeFocusLocked: function(locked) { 22378 inputNativeFocusLocked = locked; 22379 }, 22380 getInputNativeFocusLocked: function() { 22381 return inputNativeFocusLocked; 22382 }, 22383 setAppliedFocusOfEditor: function(edit, isSpecial) { 22384 if(focusedEditor === edit) { 22385 if(edit.specialKeyboardHandlingUsed == isSpecial) { 22386 focusedEditor.UnlockFocusEvents(); 22387 if(focusedEditor.EnsureClearButtonVisibility) 22388 focusedEditor.EnsureClearButtonVisibility(); 22389 } 22390 return; 22391 } 22392 if(edit.specialKeyboardHandlingUsed == isSpecial) { 22393 this.lostAppliedFocusOfEditor(); 22394 focusedEditor = edit; 22395 ASPx.SetFocusedEditor(edit); 22396 } 22397 if(isSpecial) 22398 edit.OnSpecialFocus(); 22399 else 22400 edit.OnFocus(); 22401 }, 22402 lostAppliedFocusOfEditor: function() { 22403 if(!focusedEditor) return; 22404 var curEditorName = focusedEditor.name; 22405 var skbdHandlingUsed = focusedEditor.specialKeyboardHandlingUsed;
22406 var focusedEditorInputElementExists = focusedEditor.GetInputElement(); 22407 focusedEditor = null; 22408 if(!focusedEditorInputElementExists) 22409 return; 22410 ASPx.ELostFocusCore(curEditorName); 22411 if(skbdHandlingUsed) 22412 ASPx.ESLostFocusCore(curEditorName); 22413 }, 22414 getFocusedEditor: function() { 22415 return focusedEditor; 22416 }, 22417 resetFocusedEditor: function() { 22418 focusedEditor = null; 22419 }, 22420 focusableInputElementIsActive: function(edit) { 22421 var inputElement = edit.GetFocusableInputElement(); 22422 return !!inputElement ? ASPx.GetActiveElement() === inputElement : false; 22423 }, 22424 isGooglePlaceAutocompleteElementTap: function(evt) { 22425 var googlePlaceAutocompleteContainer = ASPx.GetNodeByClassName(document.body, "pac-container", 0); 22426 if(!googlePlaceAutocompleteContainer) 22427 return false; 22428 return ASPx.GetParentByClassName(ASPx.Evt.GetEventSource(evt), "pac-container") != null; 22429 } 22430 }; 22431})(); 22432if(ASPx.Browser.VirtualKeyboardSupported) { 22433 var touchEventName = ASPx.TouchUIHelper.pointerEnabled ? ASPx.TouchUIHelper.pointerDownEventName : 'touchstart'; 22434 ASPx.Evt.AttachEventToDocument(touchEventName, function(evt){ ASPx.VirtualKeyboardUI.onTouchStart(evt); }); 22435} 22436ASPx.Evt.AttachEventToDocument("mousedown", function(evt) { 22437 var editor = ASPx.GetFocusedEditor(); 22438 if(!editor) 22439 return; 22440 var evtSource = ASPx.Evt.GetEventSource(evt); 22441 if(editor.IsClearButtonElement(evtSource)) 22442 return; 22443 if(editor.OwnerDateEdit && editor.OwnerDateEdit.GetShowTimeSection()) { 22444 editor.OwnerDateEdit.ForceRefocusTimeSectionTimeEdit(evtSource); 22445 return; 22446 } 22447 if(editor.ownerListBox && editor.ownerListBox.IsEditorElement(evtSource) && !editor.IsEditorElement(evtSource)) { 22448 editor.ownerListBox.ForceRefocusEditor(evt); 22449 ASPx.SetFocusedEditor(editor.ownerListBox); 22450 return; 22451 } 22452 if(editor.IsEditorElement(evtSource) && !editor.IsElementBelongToInputElement(evtSource)) 22453 editor.ForceRefocusEditor(evt); 22454}); 22455ASPx.Evt.AttachEventToDocument(ASPx.Evt.GetMouseWheelEventName(), function(evt) { 22456 var editor = ASPx.GetFocusedEditor(); 22457 if(editor != null && ASPx.IsExistsElement(editor.GetMainElement()) && editor.focused && editor.receiveGlobalMouseWheel) 22458 editor.OnMouseWheel(evt); 22459}); 22460ASPx.KBSIKeyDown = function(name, evt){ 22461 var control = ASPx.GetControlCollection().Get(name); 22462 if(control != null){ 22463 var isProcessed = control.OnSpecialKeyDown(evt); 22464 if(isProcessed) 22465 return ASPx.Evt.PreventEventAndBubble(evt); 22466 } 22467}; 22468ASPx.KBSIKeyPress = function(name, evt){ 22469 var control = ASPx.GetControlCollection().Get(name); 22470 if(control != null){ 22471 var isProcessed = control.OnSpecialKeyPress(evt); 22472 if(isProcessed) 22473 return ASPx.Evt.PreventEventAndBubble(evt); 22474 } 22475}; 22476ASPx.KBSIKeyUp = function(name, evt){ 22477 var control = ASPx.GetControlCollection().Get(name); 22478 if(control != null){ 22479 var isProcessed = control.OnSpecialKeyUp(evt); 22480 if(isProcessed) 22481 return ASPx.Evt.PreventEventAndBubble(evt); 22482 } 22483}; 22484ASPx.ClearProcessingProc = function(edit) { 22485 return edit.Clear(); 22486}; 22487ASPx.ValidateProcessingProc = function(edit) { 22488 edit.OnValidation(ValidationType.MassValidation); 22489 return edit.GetIsValid(); 22490}; 22491ASPx.EditorsValidProcessingProc = function(edit) { 22492 return edit.GetIsValid(); 22493}; 22494var CheckEditElementHelper = ASPx.CreateClass(ASPx.CheckableElementHelper, { 22495 AttachToMainElement: function(internalCheckBox) { 22496 ASPx.CheckableElementHelper.prototype.AttachToMainElement.call(this, internalCheckBox); 22497 this.AttachToLabelElement(this.GetLabelElement(internalCheckBox.container), internalCheckBox); 22498 }, 22499 AttachToLabelElement: function(labelElement, internalCheckBox) { 22500 var _this = this; 22501 if(labelElement) { 22502 ASPx.Evt.AttachEventToElement(labelElement, "click", 22503 function (evt) { 22504 _this.InvokeClick(internalCheckBox, evt); 22505 } 22506 ); 22507 ASPx.Evt.AttachEventToElement(labelElement, "mousedown", 22508 function (evt) { 22509 internalCheckBox.Refocus(); 22510 } 22511 ); 22512 } 22513 }, 22514 GetLabelElement: function(container) { 22515 var labelElement = ASPx.GetNodeByTagName(container, "LABEL", 0); 22516 if(!labelElement) { 22517 var labelCell = ASPx.GetNodeByClassName(container, "dxichTextCellSys", 0); 22518 labelElement = ASPx.GetNodeByTagName(labelCell, "SPAN", 0); 22519 } 22520 return labelElement; 22521 } 22522}); 22523CheckEditElementHelper.Instance = new CheckEditElementHelper(); 22524var CalendarSharedParameters = ASPx.CreateClass(null, { 22525 updateCalendarCallbackCommand: "UPDATE", 22526 constructor: function() { 22527 this.minDate = null; 22528 this.maxDate = null; 22529 this.disabledDates = []; 22530 this.calendarCustomDraw = false; 22531 this.hasCustomDisabledDatesViaCallback = false; 22532 this.dateRangeMode = false; 22533 this.currentDateEdit = null; 22534 this.DaysSelectingOnMouseOver = new ASPxClientEvent(); 22535 this.VisibleDaysMouseOut = new ASPxClientEvent(); 22536 this.CalendarSelectionChangedInternal = new ASPxClientEvent(); 22537 }, 22538 Assign: function(source) { 22539 this.minDate = source.minDate ? source.minDate : null; 22540 this.maxDate = source.maxDate ? source.maxDate : null; 22541 this.calendarCustomDraw = source.calendarCustomDraw ? source.calendarCustomDraw : false;
22542 this.hasCustomDisabledDatesViaCallback = source.hasCustomDisabledDatesViaCallback ? source.hasCustomDisabledDatesViaCallback : false; 22543 this.disabledDates = source.disabledDates ? source.disabledDates : []; 22544 this.currentDateEdit = source.currentDateEdit ? source.currentDateEdit : null; 22545 }, 22546 GetUpdateCallbackParameters: function() { 22547 var callbackArgs = this.GetCallbackArgs(); 22548 callbackArgs = this.FormatCallbackArg(this.updateCalendarCallbackCommand, callbackArgs); 22549 return callbackArgs; 22550 }, 22551 GetCallbackArgs: function() { 22552 var args = {}; 22553 if(this.minDate) 22554 args.clientMinDate = ASPx.DateUtils.GetInvariantDateString(this.minDate); 22555 if(this.maxDate) 22556 args.clientMaxDate = ASPx.DateUtils.GetInvariantDateString(this.maxDate); 22557 if(args.clientMinDate || args.clientMaxDate) { 22558 var jsonArgs = JSON.stringify(args); 22559 return ASPx.Str.EncodeHtml(jsonArgs); 22560 } 22561 return null; 22562 }, 22563 FormatCallbackArg: function(prefix, arg) { 22564 if(!arg) return prefix; 22565 return [prefix, '|', arg.length, ';', arg, ';'].join(''); 22566 } 22567}); 22568ASPx.CalendarSharedParameters = CalendarSharedParameters; 22569ASPx.ValidationType = ValidationType; 22570ASPx.ErrorFrameDisplay = ErrorFrameDisplay; 22571ASPx.EditElementSuffix = EditElementSuffix; 22572ASPx.ValidationPattern = ValidationPattern; 22573ASPx.RequiredFieldValidationPattern = RequiredFieldValidationPattern; 22574ASPx.RegularExpressionValidationPattern = RegularExpressionValidationPattern; 22575ASPx.CheckEditElementHelper = CheckEditElementHelper; 22576ASPx.IsEditorFocusable = _aspxIsEditorFocusable; 22577window.ASPxClientEditBase = ASPxClientEditBase; 22578window.ASPxClientEdit = ASPxClientEdit; 22579window.ASPxClientEditKeyEventArgs = ASPxClientEditKeyEventArgs; 22580window.ASPxClientEditValidationEventArgs = ASPxClientEditValidationEventArgs; 22581})(); 22582 22583(function() { 22584ASPx.TEInputSuffix = "_I"; 22585ASPx.PasteCheckInterval = 50; 22586ASPx.CheckUserInputInterval = 10; 22587ASPx.TEHelpTextElementSuffix = "_HTE"; 22588ASPx.TempHiddenInputSuffix = "_THI"; 22589var passwordInputClonedSuffix = "_CLND"; 22590var CHROME_AUTOFILL_SELECTOR = ":-webkit-autofill"; 22591var BrowserHelper = { 22592 SAFARI_SYSTEM_CLASS_NAME: "dxeSafariSys", 22593 MOBILE_SAFARI_SYSTEM_CLASS_NAME: "dxeIPadSys", 22594 GetBrowserSpecificSystemClassName: function() { 22595 if(ASPx.Browser.Safari) 22596 return ASPx.Browser.MacOSMobilePlatform ? this.MOBILE_SAFARI_SYSTEM_CLASS_NAME : this.SAFARI_SYSTEM_CLASS_NAME; 22597 return ""; 22598 } 22599}; 22600var focusedNullTextClassName = "dxeFNTextSys"; 22601var NullTextDisplayMode = { 22602 Unfocused: "Unfocused", 22603 UnfocusedAndFocused: "UnfocusedAndFocused" 22604}; 22605ASPx.NullTextDisplayMode = NullTextDisplayMode; 22606var ASPxClientTextEdit = ASPx.CreateClass(ASPxClientEdit, { 22607 constructor: function(name) { 22608 this.constructor.prototype.constructor.call(this, name); 22609 this.isASPxClientTextEdit = true; 22610 this.nullText = ""; 22611 this.nullTextDisplayMode = NullTextDisplayMode.Unfocused; 22612 this.nullTextOnFocusCssText = ""; 22613 this.focusedNullTextTimerID = -1; 22614 this.escCount = 0; 22615 this.raiseValueChangedOnEnter = true; 22616 this.autoResizeWithContainer = false; 22617 this.lastChangedValue = null; 22618 this.autoCompleteAttribute = null; 22619 this.isTextSelectionOnClickEnabled = false; 22620 this.trySelectInputTextOnClick = true; 22621 this.passwordNullTextIntervalID = -1; 22622 this.nullTextInputElement = null; 22623 this.helpText = ""; 22624 this.helpTextObj = null; 22625 this.helpTextStyle = []; 22626 this.externalTableStyle = []; 22627 this.helpTextPosition = ASPx.Position.Right; 22628 this.helpTextMargins = null; 22629 this.helpTextHAlign = ASPxClientTextEditHelpTextHAlign.Left; 22630 this.helpTextVAlign = ASPxClientTextEditHelpTextVAlign.Top; 22631 this.enableHelpTextPopupAnimation = true; 22632 this.helpTextDisplayMode = ASPxClientTextEditHelpTextDisplayMode.Inline; 22633 this.maskInfo = null; 22634 this.maskValueBeforeUserInput = ""; 22635 this.maskPasteTimerID = -1; 22636 this.maskPasteLock = false; 22637 this.maskPasteCounter = 0; 22638 this.maskTextBeforePaste = ""; 22639 this.maskHintHtml = ""; 22640 this.maskHintTimerID = -1; 22641 this.errorCellPosition = ASPx.Position.Right; 22642 this.inlineInitializeInputValue = null; 22643 this.initializeInputValue = null; 22644 this.displayFormat = null; 22645 this.TextChanged = new ASPxClientEvent(); 22646 this.UserInput = new ASPxClientEvent(); 22647 this.userInputEventTimerID = -1; 22648 }, 22649 AddDefaultReadOnlyStateControllerItem: function(cssClass, mainElementId) { 22650 ASPx.AddReadOnlyItems(mainElementId, [[[cssClass], [''], ['', 'I']]]); 22651 }, 22652 AddDefaultDisabledStateControllerItem: function(cssClass, mainElementId) { 22653 ASPx.AddDisabledItems(mainElementId, [[[cssClass], [''], ['', 'I']]]); 22654 }, 22655 SetData: function(data){ 22656 ASPxClientEdit.prototype.SetData.call(this, data);
22657 if(data.maskInfo) { 22658 var maskProperties = data.maskInfo.properties; 22659 var useInvariantCultureDecimalSymbol = maskProperties && maskProperties.useInvariantCultureDecimalSymbol || false; 22660 this.maskInfo = ASPx.MaskInfo.Create(data.maskInfo.maskText, data.maskInfo.dateTimeOnly, data.maskInfo.allowEscapingInEnums, useInvariantCultureDecimalSymbol); 22661 this.SetProperties(data.maskInfo.properties, this.maskInfo); 22662 } 22663 }, 22664 InlineInitialize: function() { 22665 this.SaveInputValue(true); 22666 ASPxClientEdit.prototype.InlineInitialize.call(this); 22667 if(this.maskInfo != null) 22668 this.InitMask(); 22669 this.ApplyBrowserSpecificClassName(); 22670 this.helpTextInitialize(); 22671 if(ASPx.Browser.IE && ASPx.Browser.Version >= 10 && this.nullText != "") 22672 this.addIEXButtonEventHandler(); 22673 }, 22674 Initialize: function(){ 22675 this.SaveInputValue(false); 22676 this.SaveChangedValue(); 22677 ASPxClientEdit.prototype.Initialize.call(this); 22678 this.CorrectInputMaxLength(); 22679 this.SubscribeToIeDropEvent(); 22680 if(ASPx.Browser.WebKitFamily) 22681 this.CorrectMainElementWhiteSpaceStyle(); 22682 this.InitializeTextDecoration(); 22683 this.InitializeAutocompleteAttribute(); 22684 if(this.IsValueRestoredByBrowser()) 22685 this.SynchronizeRestoredValue(); 22686 }, 22687 InitializeEvents: function() { 22688 ASPxClientEdit.prototype.InitializeEvents.call(this); 22689 ASPx.Evt.AttachEventToElement(this.GetInputElement(), "keydown", this.OnKeyDown.aspxBind(this)); 22690 ASPx.Evt.AttachEventToElement(this.GetInputElement(), "keyup", this.OnKeyUp.aspxBind(this)); 22691 ASPx.Evt.AttachEventToElement(this.GetInputElement(), "keypress", this.OnKeyPress.aspxBind(this)); 22692 if(this.isTextSelectionOnClickEnabled) { 22693 ASPx.Evt.AttachEventToElement(this.GetInputElement(), ASPx.TouchUIHelper.touchMouseDownEventName, this.OnMouseDown.aspxBind(this)); 22694 ASPx.Evt.AttachEventToElement(this.GetInputElement(), "click", this.OnClick.aspxBind(this)); 22695 } 22696 this.Unload.AddHandler(this.OnUnload.aspxBind(this)); 22697 }, 22698 InitializeTextDecoration: function() { 22699 var input = this.GetInputElement(); 22700 if(input.type === "password" && !this.IsInputPasswordFilledAutomaticallyByChrome()) 22701 this.ToggleTextDecoration(); 22702 }, 22703 IsInputPasswordFilledAutomaticallyByChrome: function() { 22704 if(!ASPx.Browser.Chrome) 22705 return false; 22706 var input = this.GetInputElement(); 22707 return ASPx.ElementMatchesSelector(input, CHROME_AUTOFILL_SELECTOR); 22708 }, 22709 OnMouseDown: function() { 22710 this.trySelectInputTextOnClick = ASPx.GetActiveElement() !== this.GetInputElement() && !this.IsFocusEventsLocked(); 22711 }, 22712 OnClick: function() { 22713 if(this.trySelectInputTextOnClick) { 22714 var input = this.GetInputElement(); 22715 setTimeout(function() { 22716 var inputSelection = ASPx.Selection.GetInfo(input); 22717 if (inputSelection.startPos === inputSelection.endPos) 22718 ASPx.Selection.Set(input); 22719 }, 0); 22720 } 22721 }, 22722 InitializeAutocompleteAttribute: function() { 22723 var input = this.GetInputElement(); 22724 if(this.IsVCardAttributeRequired()) 22725 ASPx.Attr.SetAttribute(input, this.autoCompleteAttribute.name, this.autoCompleteAttribute.value); 22726 else if(this.IsAutocompleteOffRequiredOnInitialize()) 22727 ASPx.Attr.SetAttribute(input, "autocomplete", "off"); 22728 }, 22729 SaveInputValue: function(isInlineInitialize) { 22730 var input = this.GetInputElement(); 22731 if(!input) 22732 return; 22733 var inputValue = input.value; 22734 if(inputValue === null) 22735 inputValue = ""; 22736 if(isInlineInitialize) 22737 this.inlineInitializeInputValue = inputValue; 22738 else 22739 this.initializeInputValue = inputValue; 22740 }, 22741 IsValueRestoredByBrowser: function() { 22742 if(this.displayFormat || this.isNative || this.inlineInitializeInputValue === null || this.initializeInputValue === null) 22743 return false; 22744 if(ASPx.Browser.Chrome) 22745 return this.IsValueRestoredByChrome(); 22746 else if(ASPx.Browser.Firefox) 22747 return this.IsValueRestoredByFirefox(); 22748 else if(ASPx.Browser.IE) 22749 return this.IsValueRestoredByIE(); 22750 else 22751 return this.IsValueRestoredByBrowserCore(); 22752 }, 22753 IsValueRestoredByBrowserCore: function() { 22754 return this.IsValueChangedBeforeInitialize() || this.IsClientValueNotExists() || this.IsValueChangedOnMaskInitialize(); 22755 }, 22756 IsValueRestoredByChrome: function() { 22757 return this.IsValueRestoredByBrowserCore(); 22758 }, 22759 IsValueRestoredByFirefox: function() { 22760 return this.IsValueRestoredByBrowserCore(); 22761 }, 22762 IsValueRestoredByIE: function() { 22763 return this.IsValueRestoredByBrowserCore(); 22764 }, 22765 IsValueChangedBeforeInitialize: function() { 22766 return this.inlineInitializeInputValue !== this.initializeInputValue; 22767 }, 22768 IsClientValueNotExists: function() { 22769 return this.inlineInitializeInputValue !== "" && 22770 this.inlineInitializeInputValue !== this.nullText && 22771 this.inlineInitializeInputValue !== this.GetValue() && 22772 this.inlineInitializeInputValue !== this.GetText(); 22773 }, 22774 IsValueChangedOnMaskInitialize: function() { 22775 return this.maskInfo && this.inlineInitializeInputValue !== this.GetInputElement().value; 22776 }, 22777 SynchronizeRestoredValue: function() { 22778 this.SetText(this.initializeInputValue); 22779 }, 22780 AdjustControl: function() { 22781 ASPxClientEdit.prototype.AdjustControl.call(this); 22782 if(ASPx.Browser.IE && ASPx.Browser.Version > 8 && !this.isNative) 22783 this.correctInputElementHeight(); 22784 this.ensureAdjustFocusedNullTextElement(); 22785 }, 22786 correctInputElementHeight: function() { 22787 var mainElement = this.GetMainElement(); 22788 if(mainElement) { 22789 var mainElementHeight = mainElement.style.height; 22790 var mainElementHeightSpecified = mainElementHeight && mainElementHeight.indexOf('px') !== -1; 22791 if(mainElementHeightSpecified) { 22792 var inputElement = this.GetInputElement(); 22793 var inputElementHeight = this.getInputElementHeight(); 22794 inputElement.style.height = inputElementHeight + "px"; 22795 if(!ASPx.Ident.IsASPxClientMemo(this)) 22796 inputElement.style.lineHeight = inputElementHeight + "px"; 22797 } 22798 } 22799 }, 22800 getInputElementHeight: function() { 22801 var mainElement = this.GetMainElement(), 22802 inputElement = this.GetInputElement(); 22803 var inputElementHeight = ASPx.PxToInt(mainElement.style.height) - ASPx.GetTopBottomBordersAndPaddingsSummaryValue(mainElement); 22804 var inputElementContainer = inputElement.parentNode, 22805 inputContainerStyle = ASPx.GetCurrentStyle(inputElementContainer); 22806 inputElementHeight -= ASPx.GetTopBottomBordersAndPaddingsSummaryValue(inputElementContainer, inputContainerStyle) 22807 + ASPx.GetTopBottomMargins(inputElementContainer, inputContainerStyle); 22808 var mainElementCellspacing = ASPx.GetCellSpacing(mainElement); 22809 if(mainElementCellspacing) 22810 inputElementHeight -= mainElementCellspacing * 2; 22811 var inputStyle = ASPx.GetCurrentStyle(inputElement); 22812 inputElementHeight -= ASPx.GetTopBottomBordersAndPaddingsSummaryValue(inputElement, inputStyle) 22813 + ASPx.GetTopBottomMargins(inputElement, inputStyle); 22814 return inputElementHeight; 22815 }, 22816 getInputCell: function() { 22817 var inputElement = this.GetInputElement(); 22818 if(inputElement) 22819 return inputElement.parentNode; 22820 }, 22821 addIEXButtonEventHandler: function() { 22822 var inputElement = this.GetInputElement();
22823 if(ASPx.IsExists(inputElement)) { 22824 this.isDeleteOrBackspaceKeyClick = false; 22825 ASPx.Evt.AttachEventToElement(inputElement, "input", function (evt) { 22826 if(this.isDeleteOrBackspaceKeyClick) { 22827 this.isDeleteOrBackspaceKeyClick = false; 22828 return; 22829 } 22830 if(inputElement.value === '') { 22831 this.SyncRawValue(); 22832 } 22833 }.aspxBind(this)); 22834 ASPx.Evt.AttachEventToElement(inputElement, "keydown", function (evt) { 22835 this.isDeleteOrBackspaceKeyClick = (evt.keyCode == ASPx.Key.Delete || evt.keyCode == ASPx.Key.Backspace); 22836 }.aspxBind(this)); 22837 } 22838 }, 22839 ensureOutOfRangeWarningManager: function (minValue, maxValue, defaultMinValue, defaultMaxValue, valueFormatter) { 22840 if (!this.outOfRangeWarningManager) 22841 this.outOfRangeWarningManager = new ASPxOutOfRangeWarningManager(this, minValue, maxValue, defaultMinValue, defaultMaxValue, 22842 this.showOutOfRangeWarningElementAtBottom() ? ASPx.Position.Bottom : ASPx.Position.Right, valueFormatter); 22843 }, 22844 showOutOfRangeWarningElementAtBottom: function() { 22845 return this.hasRightPopupHelpText(); 22846 }, 22847 GetOutOfRangeWarningElementPrevSibling: function() { 22848 return this.GetMainElement(); 22849 }, 22850 helpTextInitialize: function () { 22851 if(this.helpText) { 22852 this.helpTextObj = new ASPxClientTextEditHelpText(this, this.helpTextStyle, this.helpText, this.helpTextPosition, 22853 this.helpTextHAlign, this.helpTextVAlign, this.helpTextMargins, this.enableHelpTextPopupAnimation, this.helpTextDisplayMode); 22854 } 22855 }, 22856 hasPopupHelpText: function() { 22857 return this.helpText && this.helpTextDisplayMode === ASPxClientTextEditHelpTextDisplayMode.Popup; 22858 }, 22859 hasRightPopupHelpText: function() { 22860 return this.hasPopupHelpText() && this.helpTextPosition === ASPx.Position.Right; 22861 }, 22862 showHelpText: function () { 22863 if(this.helpTextObj) 22864 this.helpTextObj.show(); 22865 }, 22866 hideHelpText: function () { 22867 if(this.helpTextObj) 22868 this.helpTextObj.hide(); 22869 }, 22870 ApplyBrowserSpecificClassName: function() { 22871 var mainElement = this.GetMainElement(); 22872 if(ASPx.IsExistsElement(mainElement)) { 22873 var className = BrowserHelper.GetBrowserSpecificSystemClassName(); 22874 if(className) 22875 mainElement.className += " " + className; 22876 } 22877 }, 22878 CorrectMainElementWhiteSpaceStyle: function() { 22879 var inputElement = this.GetInputElement(); 22880 if(inputElement && inputElement.parentNode) { 22881 if(this.IsElementHasWhiteSpaceStyle(inputElement.parentNode)) 22882 inputElement.parentNode.style.whiteSpace = "normal"; 22883 } 22884 }, 22885 IsElementHasWhiteSpaceStyle: function(element) { 22886 var currentStyle = ASPx.GetCurrentStyle(element); 22887 return currentStyle.whiteSpace == "nowrap" || currentStyle.whiteSpace == "pre"; 22888 }, 22889 FindInputElement: function(){ 22890 return this.isNative ? this.GetMainElement() : ASPx.GetElementById(this.name + ASPx.TEInputSuffix); 22891 }, 22892 DecodeRawInputValue: function(value) { 22893 return value; 22894 }, 22895 GetRawValue: function(value){ 22896 return ASPx.IsExists(this.stateObject) ? this.stateObject.rawValue : null; 22897 }, 22898 SetRawValue: function(value){ 22899 if(ASPx.IsExists(value)) 22900 value = value.toString(); 22901 this.UpdateStateObjectWithObject({ rawValue: value }); 22902 }, 22903 SyncRawValue: function() { 22904 if(this.maskInfo != null) 22905 this.SetRawValue(this.maskInfo.GetValue(true)); 22906 else 22907 this.SetRawValue(this.GetInputElement().value); 22908 }, 22909 HasTextDecorators: function() { 22910 return this.nullText != "" || this.displayFormat != null; 22911 }, 22912 CanApplyTextDecorators: function(){ 22913 return !this.focused; 22914 }, 22915 CreateStyleDecoration: function () { 22916 return new ASPx.TextEditorStyleDecoration(this); 22917 }, 22918 CanApplyNullTextDecoration: function() { 22919 var value = this.GetValue(); 22920 return this.IsNull(value); 22921 }, 22922 GetDecoratedText: function(value) { 22923 var result = value; 22924 if(this.IsNull(value) && this.nullText != "" && this.CanApplyNullTextDecoration()) 22925 result = this.nullText; 22926 else if(this.displayFormat != null) 22927 result = this.GetDisplayFormatText(value); 22928 else if(this.maskInfo != null) 22929 result = this.maskInfo.GetText(); 22930 else if(value == null) 22931 result = ""; 22932 return result; 22933 }, 22934 GetDisplayFormatText: function(value) { 22935 return ASPx.Formatter.Format(this.displayFormat, value); 22936 }, 22937 ToggleTextDecoration: function() { 22938 if(this.HasTextDecorators()) { 22939 if(this.focused) { 22940 var input = this.GetInputElement(); 22941 var oldValue = input.value; 22942 var sel = ASPx.Selection.GetExtInfo(input); 22943 this.ToggleTextDecorationCore(); 22944 this.ensureActivateFocusedNullTextMechanism(); 22945 if(oldValue != input.value || !ASPx.Selection.AreEqual(sel, ASPx.Selection.GetExtInfo(input))) {
22946 if(sel.startPos == 0 && sel.endPos == oldValue.length) 22947 sel.endPos = input.value.length; 22948 else 22949 sel.endPos = sel.startPos; 22950 if(!this.accessibilityCompliant || ASPx.GetActiveElement() == input) 22951 this.SetSelectionOnToggleTextDecoration(input, sel); 22952 } 22953 } else { 22954 this.ToggleTextDecorationCore(); 22955 this.ensureDeactivateFocusedNullTextMechanism(); 22956 } 22957 } 22958 }, 22959 SetSelectionOnToggleTextDecoration: function(input, sel) { 22960 ASPx.Selection.Set(input, sel.startPos, sel.endPos); 22961 }, 22962 ToggleTextDecorationCore: function() { 22963 if(this.maskInfo != null) { 22964 this.ApplyMaskInfo(false); 22965 } else { 22966 var input = this.GetInputElement(); 22967 var rawValue = this.GetRawValue(); 22968 var value = this.CanApplyTextDecorators() ? this.GetDecoratedText(rawValue) : rawValue; 22969 if(input.value != value) { 22970 if(input.type == "password") 22971 this.TogglePasswordInputTextDecoration(value); 22972 else 22973 input.value = value; 22974 } 22975 } 22976 }, 22977 GetPasswordNullTextInputElement: function() { 22978 if(!this.isPasswordNullTextInputElementExists()) 22979 this.nullTextInputElement = this.createPasswordNullTextInputElement(); 22980 return this.nullTextInputElement; 22981 }, 22982 createPasswordNullTextInputElement: function() { 22983 var inputElement = this.GetInputElement(), 22984 nullTextInputElement = document.createElement("INPUT"); 22985 nullTextInputElement.className = inputElement.className; 22986 nullTextInputElement.style.cssText = inputElement.style.cssText; 22987 nullTextInputElement.id = inputElement.id + passwordInputClonedSuffix; 22988 nullTextInputElement.type = "text"; 22989 if(ASPx.IsExists(inputElement.tabIndex)) 22990 nullTextInputElement.tabIndex = inputElement.tabIndex; 22991 nullTextInputElement.disabled = inputElement.disabled; 22992 var onFocusEventHandler = function() { 22993 var inputElement = this.GetInputElement(), 22994 nullTextInputElement = this.GetPasswordNullTextInputElement(); 22995 if(inputElement) { 22996 this.LockFocusEvents(); 22997 ASPx.SetElementDisplay(inputElement, true); 22998 inputElement.focus(); 22999 ASPx.SetElementDisplay(nullTextInputElement, false); 23000 this.ensureAdjustFocusedNullTextElement(); 23001 this.ReplaceAssociatedIdInLabels(nullTextInputElement.id, inputElement.id); 23002 } 23003 }.aspxBind(this); 23004 ASPx.Evt.AttachEventToElement(nullTextInputElement, "focus", onFocusEventHandler); 23005 return nullTextInputElement; 23006 }, 23007 isPasswordNullTextInputElementExists: function() { 23008 return ASPx.IsExistsElement(this.nullTextInputElement); 23009 }, 23010 TogglePasswordNullTextTimeoutChecker: function() { 23011 if(this.passwordNullTextIntervalID < 0) { 23012 var timeoutChecker = function() { 23013 var inputElement = this.GetInputElement(); 23014 if(ASPx.GetControlCollection().GetByName(this.name) !== this || inputElement == null) { 23015 window.clearTimeout(this.passwordNullTextIntervalID); 23016 this.passwordNullTextIntervalID = -1; 23017 return; 23018 } else { 23019 if(!this.focused) { 23020 var passwordNullTextInputElement = this.GetPasswordNullTextInputElement(); 23021 if(passwordNullTextInputElement.value != this.nullText && inputElement.value == "") { 23022 passwordNullTextInputElement.value = this.nullText; 23023 this.SetValue(null); 23024 } 23025 if(inputElement.value != "") { 23026 if(inputElement.style.display == "none") { 23027 this.SetValue(inputElement.value); 23028 this.UnhidePasswordInput(); 23029 } 23030 } else { 23031 if(inputElement.style.display != "none") { 23032 this.SetValue(null); 23033 this.HidePasswordInput(); 23034 } 23035 } 23036 } 23037 } 23038 }.aspxBind(this); 23039 timeoutChecker(); 23040 this.passwordNullTextIntervalID = window.setInterval(timeoutChecker, 100); 23041 } 23042 }, 23043 TogglePasswordInputTextDecoration: function(value) { 23044 var inputElement = this.GetInputElement(); 23045 var nullTextInputElement = this.GetPasswordNullTextInputElement(); 23046 nullTextInputElement.value = value; 23047 var parentNode = inputElement.parentNode; 23048 if(ASPx.Data.ArrayIndexOf(parentNode.childNodes, nullTextInputElement) < 0) { 23049 ASPx.Attr.ChangeStyleAttribute(nullTextInputElement, "display", "none"); 23050 parentNode.appendChild(nullTextInputElement); 23051 } 23052 this.HidePasswordInput(); 23053 this.TogglePasswordNullTextTimeoutChecker(); 23054 },
23055 HidePasswordInput: function() { 23056 ASPx.Attr.ChangeStyleAttribute(this.GetInputElement(), "display", "none"); 23057 ASPx.Attr.ChangeStyleAttribute(this.GetPasswordNullTextInputElement(), "display", ""); 23058 this.ReplaceAssociatedIdInLabels(this.GetInputElement().id, this.GetPasswordNullTextInputElement().id); 23059 }, 23060 UnhidePasswordInput: function() { 23061 ASPx.Attr.ChangeStyleAttribute(this.GetInputElement(), "display", ""); 23062 ASPx.Attr.ChangeStyleAttribute(this.GetPasswordNullTextInputElement(), "display", "none"); 23063 this.ReplaceAssociatedIdInLabels(this.GetPasswordNullTextInputElement().id, this.GetInputElement().id); 23064 }, 23065 ReplaceAssociatedIdInLabels: function(oldId, newId) { 23066 var labels = document.getElementsByTagName("LABEL"); 23067 for(var i = 0; i < labels.length; i++) { 23068 if(labels[i].attributes["for"] && labels[i].attributes["for"].value == oldId) 23069 labels[i].attributes["for"].value = newId; 23070 } 23071 }, 23072 GetFormattedText: function() { 23073 var value = this.GetValue(); 23074 if(this.IsNull(value) && this.nullText != "") 23075 return this.GetText(); 23076 return this.GetDecoratedText(value); 23077 }, 23078 IsNull: function(value) { 23079 return value == null || value === ""; 23080 }, 23081 PopulateStyleDecorationPostfixes: function() { 23082 ASPxClientEdit.prototype.PopulateStyleDecorationPostfixes.call(this); 23083 this.styleDecoration.AddPostfix(ASPx.TEInputSuffix); 23084 }, 23085 GetValue: function() { 23086 var value = null; 23087 if(this.maskInfo != null) 23088 value = this.maskInfo.GetValue(); 23089 else if(this.HasTextDecorators()) 23090 value = this.GetRawValue(); 23091 else { 23092 var input = this.GetInputElement(); 23093 value = input ? input.value : null; 23094 } 23095 return (value == "" && this.convertEmptyStringToNull) ? null : value; 23096 }, 23097 SetValue: function(value) { 23098 if(value == null || value === undefined) 23099 value = ""; 23100 if(this.maskInfo != null) { 23101 this.maskInfo.SetValue(value.toString()); 23102 this.ApplyMaskInfo(false); 23103 this.SavePrevMaskValue(); 23104 } 23105 else if(this.HasTextDecorators()) { 23106 this.SetRawValue(value); 23107 this.GetInputElement().value = this.CanApplyTextDecorators() && this.GetInputElement().type != "password" ? this.GetDecoratedText(value) : value; 23108 } 23109 else 23110 this.GetInputElement().value = value; 23111 this.UpdateStyleDecorations(); 23112 this.SaveChangedValue(); 23113 }, 23114 SetVisible: function(visible) { 23115 ASPxClientEdit.prototype.SetVisible.call(this, visible); 23116 if(this.helpTextDisplayMode === ASPxClientTextEditHelpTextDisplayMode.Inline) { 23117 if(visible) 23118 this.showHelpText(); 23119 else 23120 this.hideHelpText(); 23121 } 23122 }, 23123 UnstretchInputElement: function(){ 23124 var inputElement = this.GetInputElement(); 23125 var mainElement = this.GetMainElement(); 23126 var mainElementCurStyle = ASPx.GetCurrentStyle(mainElement); 23127 if(ASPx.IsExistsElement(mainElement) && ASPx.IsExistsElement(inputElement) && ASPx.IsExists(mainElementCurStyle) && 23128 inputElement.style.width == "100%" && 23129 (mainElementCurStyle.width == "" || mainElementCurStyle.width == "auto")) 23130 inputElement.style.width = ""; 23131 }, 23132 RestoreActiveElement: function(activeElement) { 23133 if(activeElement && activeElement.setActive && activeElement.tagName != "IFRAME") 23134 activeElement.setActive(); 23135 }, 23136 RaiseValueChangedEvent: function() { 23137 var processOnServer = ASPxClientEdit.prototype.RaiseValueChangedEvent.call(this); 23138 processOnServer = this.RaiseTextChanged(processOnServer); 23139 return processOnServer; 23140 }, 23141 InitMask: function() { 23142 var rawValue = this.GetRawValue(); 23143 this.SetValue(rawValue.length ? this.DecodeRawInputValue(rawValue) : this.maskInfo.GetValue()); 23144 this.validationPatterns.unshift(new MaskValidationPattern(this.maskInfo.errorText, this.maskInfo)); 23145 }, 23146 SetMaskPasteTimer: function() { 23147 this.ClearMaskPasteTimer(); 23148 this.maskPasteTimerID = ASPx.Timer.SetControlBoundInterval(this.MaskPasteTimerProc, this, ASPx.PasteCheckInterval); 23149 }, 23150 ClearMaskPasteTimer: function() { 23151 this.maskPasteTimerID = ASPx.Timer.ClearInterval(this.maskPasteTimerID); 23152 }, 23153 SavePrevMaskValue: function() { 23154 this.maskValueBeforeUserInput = this.maskInfo.GetValue(); 23155 }, 23156 FillMaskInfo: function() { 23157 var input = this.GetInputElement(); 23158 if(!input) return; 23159 var sel = ASPx.Selection.GetInfo(input); 23160 this.maskInfo.SetCaret(sel.startPos, sel.endPos - sel.startPos); 23161 }, 23162 ApplyMaskInfo: function(applyCaret) { 23163 this.SyncRawValue(); 23164 var input = this.GetInputElement(); 23165 var text = this.GetMaskDisplayText(); 23166 this.maskTextBeforePaste = text; 23167 if(input.value != text) 23168 input.value = text; 23169 if(applyCaret) 23170 ASPx.Selection.Set(input, this.maskInfo.caretPos, this.maskInfo.caretPos + this.maskInfo.selectionLength); 23171 }, 23172 GetMaskDisplayText: function() { 23173 if(!this.focused && this.HasTextDecorators()) 23174 return this.GetDecoratedText(this.maskInfo.GetValue()); 23175 return this.maskInfo.GetText(); 23176 }, 23177 ShouldCancelMaskKeyProcessing: function(htmlEvent, keyDownInfo) { 23178 return ASPx.Evt.IsEventPrevented(htmlEvent); 23179 }, 23180 HandleMaskKeyDown: function(evt) { 23181 var keyInfo = ASPx.MaskManager.CreateKeyInfoByEvent(evt); 23182 ASPx.MaskManager.keyCancelled = this.ShouldCancelMaskKeyProcessing(evt, keyInfo); 23183 if(ASPx.MaskManager.keyCancelled) { 23184 ASPx.Evt.PreventEvent(evt); 23185 return; 23186 } 23187 this.maskPasteLock = true; 23188 this.FillMaskInfo(); 23189 var canHandle = ASPx.MaskManager.CanHandleControlKey(keyInfo); 23190 ASPx.MaskManager.savedKeyDownKeyInfo = keyInfo; 23191 if(canHandle) { 23192 ASPx.MaskManager.OnKeyDown(this.maskInfo, keyInfo);
23193 this.ApplyMaskInfo(true); 23194 ASPx.Evt.PreventEvent(evt); 23195 } 23196 ASPx.MaskManager.keyDownHandled = canHandle; 23197 this.maskPasteLock = false; 23198 this.UpdateMaskHintHtml(); 23199 }, 23200 HandleMaskKeyPress: function(evt) { 23201 var keyInfo = ASPx.MaskManager.CreateKeyInfoByEvent(evt); 23202 ASPx.MaskManager.keyCancelled = ASPx.MaskManager.keyCancelled || this.ShouldCancelMaskKeyProcessing(evt, ASPx.MaskManager.savedKeyDownKeyInfo); 23203 if(ASPx.MaskManager.keyCancelled) { 23204 ASPx.Evt.PreventEvent(evt); 23205 return; 23206 } 23207 this.maskPasteLock = true; 23208 var printable = ASPx.MaskManager.savedKeyDownKeyInfo != null && ASPx.MaskManager.IsPrintableKeyCode(ASPx.MaskManager.savedKeyDownKeyInfo); 23209 if(printable) { 23210 ASPx.MaskManager.OnKeyPress(this.maskInfo, keyInfo); 23211 this.ApplyMaskInfo(true); 23212 } 23213 if(printable || ASPx.MaskManager.keyDownHandled) 23214 ASPx.Evt.PreventEvent(evt); 23215 this.maskPasteLock = false; 23216 this.UpdateMaskHintHtml(); 23217 }, 23218 MaskPasteTimerProc: function() { 23219 if(this.maskPasteLock || !this.maskInfo) return; 23220 this.maskPasteCounter++; 23221 var inputElement = this.inputElement; 23222 if(!inputElement || this.maskPasteCounter > 40) { 23223 this.maskPasteCounter = 0; 23224 inputElement = this.GetInputElement(); 23225 if(!ASPx.IsExistsElement(inputElement)) { 23226 this.ClearMaskPasteTimer(); 23227 return; 23228 } 23229 } 23230 if(this.maskTextBeforePaste !== inputElement.value) 23231 this.ProcessInputValueChangedOnTimer(); 23232 if(!this.focused) 23233 this.ClearMaskPasteTimer(); 23234 }, 23235 ProcessInputValueChangedOnTimer: function() { 23236 var inputElement = this.inputElement; 23237 var selectionInfo = ASPx.Selection.GetInfo(inputElement); 23238 var startCaretPosition = selectionInfo.startPos; 23239 var endCaretPosition = selectionInfo.endPos; 23240 var oldText = this.maskTextBeforePaste; 23241 var newText = inputElement.value; 23242 var isAndroidBackSpacePressed = this.isAndroidBackSpacePressed(oldText, newText, startCaretPosition, endCaretPosition); 23243 var isLastTypedCharacter = newText.indexOf(oldText) == 0 && newText.length > oldText.length; 23244 if(isAndroidBackSpacePressed || isLastTypedCharacter) { 23245 this.SetText(newText); 23246 this.SetCaretPosition(endCaretPosition); 23247 } else { 23248 this.maskInfo.ProcessPaste(newText, endCaretPosition); 23249 this.ApplyMaskInfo(true); 23250 } 23251 }, 23252 isAndroidBackSpacePressed: function(oldText, newText, startCaretPosition, endCaretPosition) { 23253 if(!ASPx.Browser.AndroidMobilePlatform || startCaretPosition !== endCaretPosition || newText.length >= oldText.length) 23254 return false; 23255 var startSubstring = newText.substring(0, startCaretPosition); 23256 var endSubstring = newText.substring(startCaretPosition); 23257 var isStartSubstringMatches = oldText.indexOf(startSubstring) == 0; 23258 var isEndSubstringMatches = endSubstring == "" || oldText.lastIndexOf(endSubstring) == oldText.length - endSubstring.length; 23259 return isStartSubstringMatches && isEndSubstringMatches; 23260 }, 23261 BeginShowMaskHint: function() { 23262 if(!this.GetReadOnly() && this.maskHintTimerID == -1) 23263 this.maskHintTimerID = window.setInterval(ASPx.MaskHintTimerProc, 500); 23264 }, 23265 EndShowMaskHint: function() { 23266 window.clearInterval(this.maskHintTimerID); 23267 this.maskHintTimerID = -1; 23268 }, 23269 MaskHintTimerProc: function() { 23270 if(this.maskInfo) { 23271 this.FillMaskInfo(); 23272 this.UpdateMaskHintHtml(); 23273 } else { 23274 this.EndShowMaskHint(); 23275 } 23276 }, 23277 UpdateMaskHintHtml: function() { 23278 var hint = this.GetMaskHintElement(); 23279 if(!ASPx.IsExistsElement(hint)) 23280 return; 23281 var html = ASPx.MaskManager.GetHintHtml(this.maskInfo); 23282 if(html == this.maskHintHtml) 23283 return; 23284 if(html != "") { 23285 var mainElement = this.GetMainElement(); 23286 if(ASPx.IsExistsElement(mainElement)) { 23287 hint.innerHTML = html; 23288 hint.style.position = "absolute"; 23289 hint.style.left = ASPx.PrepareClientPosForElement(ASPx.GetAbsoluteX(mainElement), mainElement, true) + "px"; 23290 hint.style.top = (ASPx.PrepareClientPosForElement(ASPx.GetAbsoluteY(mainElement), mainElement, false) + mainElement.offsetHeight + 2) + "px"; 23291 hint.style.display = "block"; 23292 } 23293 } else { 23294 hint.style.display = "none"; 23295 } 23296 this.maskHintHtml = html; 23297 }, 23298 HideMaskHint: function() { 23299 var hint = this.GetMaskHintElement(); 23300 if(ASPx.IsExistsElement(hint)) 23301 hint.style.display = "none"; 23302 this.maskHintHtml = ""; 23303 }, 23304 GetMaskHintElement: function() { 23305 return ASPx.GetElementById(this.name + "_MaskHint"); 23306 }, 23307 OnFocus: function() { 23308 if (this.maskInfo != null && !ASPx.GetControlCollection().InCallback()) { 23309 this.TrySetCursorToStartPosition(); 23310 this.SetMaskPasteTimer(); 23311 } 23312 if(this.IsAutocompleteDropDownListRequiredOnFocus()) 23313 ASPx.Attr.RemoveAttribute(this.GetInputElement(), "autocomplete"); 23314 ASPxClientEdit.prototype.OnFocus.call(this); 23315 }, 23316 OnLostFocus: function() { 23317 if(this.IsAutocompleteOffRequiredOnLostFocus()) 23318 ASPx.Attr.SetAttribute(this.GetInputElement(), "autocomplete", "off"); 23319 ASPxClientEdit.prototype.OnLostFocus.call(this); 23320 }, 23321 OnMouseWheel: function(evt){ 23322 if(this.GetReadOnly() || this.maskInfo == null || !this.maskInfo.allowMouseWheel) 23323 return; 23324 this.FillMaskInfo(); 23325 ASPx.MaskManager.OnMouseWheel(this.maskInfo, ASPx.Evt.GetWheelDelta(evt) < 0 ? -1 : 1);
23326 this.ApplyMaskInfo(true); 23327 ASPx.Evt.PreventEvent(evt); 23328 this.UpdateMaskHintHtml(); 23329 }, 23330 OnBrowserWindowResize: function(e) { 23331 if(!this.autoResizeWithContainer) 23332 this.AdjustControl(); 23333 }, 23334 IsValueChanged: function() { 23335 return this.GetValue() != this.lastChangedValue; 23336 }, 23337 OnKeyDown: function(evt) { 23338 if(this.NeedPreventBrowserUndoBehaviour(evt)) 23339 return ASPx.Evt.PreventEvent(evt); 23340 if(this.RequireHandleMaxlenManually()) { 23341 this.onKeyDownInputValue = this.GetInputElement().value; 23342 var selectionInfo = ASPx.Selection.GetExtInfo(this.GetInputElement()); 23343 this.onKeyDownCursorPos = selectionInfo.startPos; 23344 } 23345 if(ASPx.Browser.IE && ASPx.Evt.GetKeyCode(evt) == ASPx.Key.Esc) { 23346 if(++this.escCount > 1) { 23347 ASPx.Evt.PreventEvent(evt); 23348 return; 23349 } 23350 } else 23351 this.escCount = 0; 23352 ASPxClientEdit.prototype.OnKeyDown.call(this, evt); 23353 if(!this.IsRaiseStandardOnChange(evt)) { 23354 if(!this.GetReadOnly() && this.maskInfo != null) 23355 this.HandleMaskKeyDown(evt); 23356 } 23357 }, 23358 IsCtrlZ: function(evt) { 23359 return evt.ctrlKey && !evt.altKey && !evt.shiftKey && (ASPx.Evt.GetKeyCode(evt) == 122 || ASPx.Evt.GetKeyCode(evt) == 90); 23360 }, 23361 NeedPreventBrowserUndoBehaviour: function(evt) { 23362 var inputElement = this.GetInputElement(); 23363 return this.IsCtrlZ(evt) && !!inputElement && !inputElement.value; 23364 }, 23365 OnKeyPress: function(evt) { 23366 ASPxClientEdit.prototype.OnKeyPress.call(this, evt); 23367 if(!this.GetReadOnly() && this.maskInfo != null && !this.IsRaiseStandardOnChange(evt)) 23368 this.HandleMaskKeyPress(evt); 23369 if(this.NeedOnKeyEventEnd(evt, true)) 23370 this.OnKeyEventEnd(evt); 23371 }, 23372 OnKeyUp: function(evt) { 23373 if(ASPx.Browser.Firefox && !this.focused && ASPx.Evt.GetKeyCode(evt) === ASPx.Key.Tab) 23374 return; 23375 if(this.NeedOnKeyEventEnd(evt, false)) { 23376 var proccessNextCommingPress = ASPx.Evt.GetKeyCode(evt) === ASPx.Key.Alt; 23377 this.OnKeyEventEnd(evt, proccessNextCommingPress); 23378 } 23379 if(this.RequireHandleMaxlenManually()) { 23380 var inputValueLength = this.GetInputElement().value.length; 23381 var maxLength = this.GetInputMaxLength(); 23382 if(inputValueLength > maxLength && inputValueLength > this.onKeyDownInputValue.length) { 23383 this.GetInputElement().value = this.onKeyDownInputValue; 23384 this.SetCaretPosition(this.onKeyDownCursorPos); 23385 } 23386 } 23387 ASPxClientEdit.prototype.OnKeyUp.call(this, evt); 23388 }, 23389 RequireHandleMaxlenManually: function() { 23390 return ASPx.Browser.AndroidMobilePlatform && ASPx.Browser.SamsungAndroidDevice && ASPx.Browser.PlaformMajorVersion < 6 && this.GetInputMaxLength() !== -1; 23391 }, 23392 GetInputMaxLength: function() { 23393 var input = this.GetInputElement(); 23394 if(ASPx.Attr.IsExistsAttribute(input, "maxlength")) 23395 return input.maxLength; 23396 return -1; 23397 }, 23398 NeedOnKeyEventEnd: function(evt, isKeyPress) { 23399 var handleKeyPress = this.maskInfo != null && evt.keyCode == ASPx.Key.Enter; 23400 return handleKeyPress == isKeyPress; 23401 }, 23402 OnKeyEventEnd: function(evt, withDelay){ 23403 if(!this.GetReadOnly()) { 23404 if(this.IsRaiseStandardOnChange(evt)) 23405 this.RaiseStandardOnChange(); 23406 this.SyncRawValueIfHasTextDecorators(withDelay); 23407 } 23408 }, 23409 SyncRawValueIfHasTextDecorators: function(withDelay) { 23410 if(this.HasTextDecorators()) { 23411 if(withDelay) { 23412 window.setTimeout(function() { 23413 this.SyncRawValue(); 23414 }.aspxBind(this), 0); 23415 } else 23416 this.SyncRawValue(); 23417 } 23418 }, 23419 IsRaiseStandardOnChange: function(evt){ 23420 return !this.specialKeyboardHandlingUsed && this.raiseValueChangedOnEnter && evt.keyCode == ASPx.Key.Enter; 23421 }, 23422 GetFocusSelectAction: function() { 23423 if (this.maskInfo) 23424 return this.maskInfo.IsEmpty() ? null : "start"; 23425 return "all"; 23426 }, 23427 CorrectFocusWhenDisabled: function() { 23428 if(!this.GetEnabled()) { 23429 var inputElement = this.GetInputElement(); 23430 if(inputElement) 23431 inputElement.blur(); 23432 return true; 23433 } 23434 return false; 23435 }, 23436 EnsureShowPopupHelpText: function() { 23437 if(this.helpTextDisplayMode === ASPxClientTextEditHelpTextDisplayMode.Popup) 23438 this.showHelpText(); 23439 }, 23440 EnsureHidePopupHelpText: function() { 23441 if(this.helpTextDisplayMode === ASPxClientTextEditHelpTextDisplayMode.Popup) 23442 this.hideHelpText(); 23443 }, 23444 OnFocusCore: function() { 23445 if(this.CorrectFocusWhenDisabled()) 23446 return;
23447 var wasLocked = this.IsFocusEventsLocked(); 23448 ASPxClientEdit.prototype.OnFocusCore.call(this); 23449 this.CorrectInputMaxLength(true); 23450 if(this.maskInfo != null) { 23451 this.SavePrevMaskValue(); 23452 this.BeginShowMaskHint(); 23453 } 23454 if(!wasLocked) { 23455 this.ToggleTextDecoration(); 23456 this.startUserInputEventTimerIfRequired(); 23457 } 23458 if(this.isPasswordNullTextInputElementExists()) 23459 setTimeout(function() { this.EnsureShowPopupHelpText(); }.aspxBind(this), 0); 23460 else 23461 this.EnsureShowPopupHelpText(); 23462 }, 23463 startUserInputEventTimerIfRequired: function () { 23464 if(this.shouldStartUserInputTimer() && this.userInputEventTimerID === -1) { 23465 this.prevInputValue = this.GetInputElement().value; 23466 this.userInputEventTimerID = ASPx.Timer.SetControlBoundInterval(this.processUserInputEventTimer, this, ASPx.CheckUserInputInterval); 23467 } 23468 }, 23469 shouldStartUserInputTimer: function() { 23470 return !this.UserInput.IsEmpty(); 23471 }, 23472 restartCurrentUserInputTimer: function() { 23473 if(this.userInputEventTimerID !== -1) { 23474 this.processUserInputEventTimer(true); 23475 this.clearUserInputEventTimerIfRequired(); 23476 this.startUserInputEventTimerIfRequired(); 23477 } 23478 }, 23479 clearUserInputEventTimerIfRequired: function () { 23480 if (this.userInputEventTimerID !== -1) 23481 this.userInputEventTimerID = ASPx.Timer.ClearInterval(this.userInputEventTimerID); 23482 }, 23483 processUserInputEventTimer: function(onRestart) { 23484 var currentInputValue = this.GetInputElement().value; 23485 if(currentInputValue !== this.prevInputValue) { 23486 this.onInputChangedOnUserInputTimer(onRestart); 23487 this.prevInputValue = currentInputValue; 23488 } 23489 }, 23490 onInputChangedOnUserInputTimer: function(onRestart) { 23491 if(this.raiseUserInputTimeout > -1) 23492 clearTimeout(this.raiseUserInputTimeout); 23493 this.raiseUserInputTimeout = setTimeout(function() { 23494 this.RaiseUserInput(); 23495 this.raiseUserInputTimeout = -1; 23496 }.bind(this), 0); 23497 }, 23498 ensureFocusedNullTextElement: function () { 23499 if(!this.focusedNullTextElement) 23500 this.createFocusedNullTextElement(); 23501 }, 23502 getFocusedNullTextElementClassName: function() { 23503 return focusedNullTextClassName; 23504 }, 23505 getFocusedNullTextElementTagName: function() { 23506 return "INPUT"; 23507 }, 23508 getCopyFromInputElementStyles: function() { 23509 return [ "paddingLeft", "paddingTop", "paddingRight", "paddingBottom", "borderCollapse", "borderLeftWidth", "borderTopWidth", "borderRightWidth", "borderBottomWidth" ]; 23510 }, 23511 copyStylesFromInputElementToFocusedNullTextElement: function() { 23512 var input = this.GetInputElement(); 23513 var inputStyle = ASPx.GetCurrentStyle(input); 23514 var stylesToCopy = this.getCopyFromInputElementStyles(); 23515 for(var i = 0; i < stylesToCopy.length; i++) 23516 this.focusedNullTextElement.style[stylesToCopy[i]] = inputStyle[stylesToCopy[i]]; 23517 }, 23518 createFocusedNullTextElement: function() { 23519 this.focusedNullTextElement = document.createElement(this.getFocusedNullTextElementTagName()); 23520 this.focusedNullTextElement.value = this.nullText; 23521 this.focusedNullTextElement.className = this.getFocusedNullTextElementClassName(); 23522 this.focusedNullTextElement.tabIndex = -1; 23523 ASPx.SetElementDisplay(this.focusedNullTextElement, false); 23524 if(this.accessibilityCompliant) { 23525 ASPx.Attr.SetAttribute(this.focusedNullTextElement, "aria-label", this.nullText); 23526 ASPx.Attr.SetAttribute(this.focusedNullTextElement, "aria-hidden", true); 23527 } 23528 this.copyStylesFromInputElementToFocusedNullTextElement(); 23529 if (this.nullTextOnFocusCssText) { 23530 var styleSheet = ASPx.GetCurrentStyleSheet(); 23531 this.focusedNullTextElement.className += " " + ASPx.CreateImportantStyleRule(styleSheet, this.nullTextOnFocusCssText); 23532 } 23533 var inputElement = this.GetInputElement(); 23534 inputElement.parentNode.insertBefore(this.focusedNullTextElement, inputElement.nextSibling); 23535 }, 23536 ensureActivateFocusedNullTextMechanism: function() { 23537 if (this.nullTextDisplayMode === NullTextDisplayMode.UnfocusedAndFocused) { 23538 if(this.IsNull(this.GetValue())) 23539 this.changeFocusedNullTextElementVisibility(true); 23540 this.setFocusedNullTextTimer(); 23541 } 23542 }, 23543 ensureDeactivateFocusedNullTextMechanism: function () { 23544 if (this.nullTextDisplayMode === NullTextDisplayMode.UnfocusedAndFocused) { 23545 this.clearFocusedNullTextTimer(); 23546 this.changeFocusedNullTextElementVisibility(false); 23547 } 23548 }, 23549 setFocusedNullTextTimer: function () { 23550 if(this.focusedNullTextTimerID === -1) 23551 this.focusedNullTextTimerID = ASPx.Timer.SetControlBoundInterval(this.onFocusedNullTextVisibilityCheck, this, ASPx.PasteCheckInterval); 23552 }, 23553 clearFocusedNullTextTimer: function () { 23554 this.focusedNullTextTimerID = ASPx.Timer.ClearInterval(this.focusedNullTextTimerID); 23555 }, 23556 onFocusedNullTextVisibilityCheck: function (evt) { 23557 if(!this.needShowFocusedNullText() && this.isFocusedNullTextElementDisplayed()) 23558 this.changeFocusedNullTextElementVisibility(false); 23559 else if(this.needShowFocusedNullText() && !this.isFocusedNullTextElementDisplayed()) 23560 this.changeFocusedNullTextElementVisibility(true); 23561 }, 23562 isFocusedNullTextElementDisplayed: function() { 23563 return this.focusedNullTextElement && ASPx.GetElementDisplay(this.focusedNullTextElement); 23564 }, 23565 needShowFocusedNullText: function() { 23566 if(this.focusedNullTextTimerID === -1) 23567 return this.IsNull(this.GetValue()); 23568 var result = this.GetInputElement().value === ""; 23569 if(this.CanApplyNullTextDecoration) 23570 result = result && this.CanApplyNullTextDecoration(); 23571 return result; 23572 }, 23573 changeFocusedNullTextElementVisibility: function (visible) { 23574 this.ensureFocusedNullTextElement(); 23575 ASPx.SetElementDisplay(this.focusedNullTextElement, visible); 23576 if(visible) 23577 this.adjustFocusedNullTextElement(); 23578 }, 23579 getInputElementAbsoluteX: function(input) { 23580 var result = ASPx.GetAbsoluteX(input); 23581 if(ASPx.Browser.Opera || ASPx.Browser.AndroidMobilePlatform) 23582 result++; 23583 return result; 23584 }, 23585 getInputElementAbsoluteY: function (input) { 23586 var result = ASPx.GetAbsoluteY(input); 23587 if(ASPx.Browser.Opera || ASPx.Browser.AndroidMobilePlatform) 23588 result++; 23589 return result; 23590 }, 23591 adjustFocusedNullTextElement: function() { 23592 var input = this.GetInputElement(); 23593 this.focusedNullTextElement.style.width = input.offsetWidth + "px"; 23594 this.focusedNullTextElement.style.height = input.offsetHeight + "px"; 23595 var inputXPos = this.getInputElementAbsoluteX(input);
23596 var inputYPos = this.getInputElementAbsoluteY(input); 23597 ASPx.SetAbsoluteX(this.focusedNullTextElement, inputXPos); 23598 ASPx.SetAbsoluteY(this.focusedNullTextElement, inputYPos); 23599 var shiftByX = inputXPos - ASPx.GetAbsoluteX(this.focusedNullTextElement); 23600 var shiftByY = inputYPos - ASPx.GetAbsoluteY(this.focusedNullTextElement); 23601 if (shiftByX !== 0) 23602 this.focusedNullTextElement.style.left = ASPx.PxToFloat(this.focusedNullTextElement.style.left) + shiftByX + "px"; 23603 if (shiftByY !== 0) 23604 this.focusedNullTextElement.style.top = ASPx.PxToFloat(this.focusedNullTextElement.style.top) + shiftByY + "px"; 23605 }, 23606 ensureAdjustFocusedNullTextElement: function () { 23607 if(this.isFocusedNullTextElementDisplayed()) 23608 this.adjustFocusedNullTextElement(this.focusedNullTextElement); 23609 }, 23610 TrySetCursorToStartPosition: function() { 23611 var input = this.GetInputElement(); 23612 var sel = ASPx.Selection.GetInfo(input); 23613 if (sel.startPos === sel.endPos && this.IsMaskInfoEmpty()) { 23614 var pos = this.maskInfo.GetFirstNonLiteralPosition(); 23615 var setCaret = ASPx.Selection.SetCaretPosition.bind(this, input, pos); 23616 setTimeout(function() { 23617 if (document.activeElement === input) { 23618 setCaret(); 23619 setTimeout(setCaret, 50); 23620 } 23621 }, 0); 23622 } 23623 }, 23624 IsMaskInfoEmpty: function() { 23625 return this.maskInfo.IsEmpty(); 23626 }, 23627 OnLostFocusCore: function() { 23628 var wasLocked = this.IsFocusEventsLocked(); 23629 ASPxClientEdit.prototype.OnLostFocusCore.call(this); 23630 this.CorrectInputMaxLength(); 23631 if(this.maskInfo != null) { 23632 this.EndShowMaskHint(); 23633 this.HideMaskHint(); 23634 if(this.maskInfo.ApplyFixes(null)) 23635 this.ApplyMaskInfo(false); 23636 this.RaiseStandardOnChange(); 23637 } 23638 if(!wasLocked) { 23639 this.clearUserInputEventTimerIfRequired(); 23640 this.ToggleTextDecoration(); 23641 } 23642 this.escCount = 0; 23643 this.EnsureHidePopupHelpText(); 23644 }, 23645 InputMaxLengthCorrectionRequired: function () { 23646 return ASPx.Browser.IE && ASPx.Browser.Version >= 10 && (!this.isNative || this.nullText != ""); 23647 }, 23648 CorrectInputMaxLength: function (onFocus) { 23649 if(this.InputMaxLengthCorrectionRequired()) { 23650 var input = this.GetInputElement(); 23651 if(!ASPx.IsExists(this.inputMaxLength)) 23652 this.inputMaxLength = input.maxLength; 23653 input.maxLength = onFocus ? this.inputMaxLength : -1; 23654 } 23655 }, 23656 SubscribeToIeDropEvent: function() { 23657 if(this.InputMaxLengthCorrectionRequired()) { 23658 var input = this.GetInputElement(); 23659 ASPx.Evt.AttachEventToElement(input, "drop", function(e) { this.CorrectInputMaxLength(true); }.aspxBind(this)); 23660 } 23661 }, 23662 SetFocus: function() { 23663 if(this.isPasswordNullTextInputElementExists()) { 23664 this.GetPasswordNullTextInputElement().focus(); 23665 } else { 23666 ASPxClientEdit.prototype.SetFocus.call(this); 23667 } 23668 }, 23669 OnValueChanged: function() { 23670 if(this.maskInfo != null) { 23671 if(this.maskInfo.GetValue() == this.maskValueBeforeUserInput && !this.IsValueChangeForced()) 23672 return; 23673 this.SavePrevMaskValue(); 23674 } 23675 if(this.HasTextDecorators()) 23676 this.SyncRawValue(); 23677 if(!this.IsValueChanged() && !this.IsValueChangeForced()) 23678 return; 23679 this.SaveChangedValue(); 23680 ASPxClientEdit.prototype.OnValueChanged.call(this); 23681 }, 23682 IsValueChangeForced: function() { 23683 return false; 23684 }, 23685 OnTextChanged: function() { 23686 }, 23687 ForceTextChanged: function() { 23688 this.OnTextChanged(); 23689 }, 23690 SaveChangedValue: function() { 23691 this.lastChangedValue = this.GetValue(); 23692 }, 23693 RaiseStandardOnChange: function(){ 23694 var element = this.GetInputElement(); 23695 if(element && element.onchange) { 23696 element.onchange({ target: this.GetInputElement() }); 23697 } 23698 else if(this.ValueChanged) { 23699 this.ValueChanged.FireEvent(this); 23700 } 23701 }, 23702 RaiseTextChanged: function(processOnServer){ 23703 if(!this.TextChanged.IsEmpty()){ 23704 var args = new ASPxClientProcessingModeEventArgs(processOnServer); 23705 this.TextChanged.FireEvent(this, args); 23706 processOnServer = args.processOnServer; 23707 } 23708 return processOnServer; 23709 }, 23710 RaiseUserInput: function () { 23711 if(!this.UserInput.IsEmpty()) { 23712 var args = new ASPxClientEventArgs(); 23713 this.UserInput.FireEvent(this, args); 23714 } 23715 }, 23716 GetText: function(){ 23717 if(this.maskInfo != null) { 23718 return this.maskInfo.GetText(); 23719 } else { 23720 var value = this.GetValue(); 23721 return value != null ? value : ""; 23722 } 23723 }, 23724 SetText: function (value){ 23725 if(this.maskInfo != null) { 23726 this.maskInfo.SetText(value);
23727 this.ApplyMaskInfo(false); 23728 this.SavePrevMaskValue(); 23729 } else { 23730 this.SetValue(value); 23731 } 23732 }, 23733 SelectAll: function() { 23734 this.SetSelection(0, -1, false); 23735 }, 23736 SetCaretPosition: function(pos) { 23737 var inputElement = this.GetInputElement(); 23738 ASPx.Selection.SetCaretPosition(inputElement, pos); 23739 }, 23740 GetCaretPosition: function() { 23741 var inputElement = this.GetInputElement(); 23742 return ASPx.Selection.GetCaretPosition(inputElement); 23743 }, 23744 SetSelection: function(startPos, endPos, scrollToSelection) { 23745 var inputElement = this.GetInputElement(); 23746 ASPx.Selection.Set(inputElement, startPos, endPos, scrollToSelection, true); 23747 }, 23748 ChangeEnabledAttributes: function(enabled){ 23749 var inputElement = this.GetInputElement(); 23750 if(inputElement){ 23751 this.ChangeInputEnabledAttributes(inputElement, ASPx.Attr.ChangeAttributesMethod(enabled), enabled); 23752 if(this.specialKeyboardHandlingUsed) 23753 this.ChangeSpecialInputEnabledAttributes(inputElement, ASPx.Attr.ChangeEventsMethod(enabled), true); 23754 this.ChangeInputEnabled(inputElement, enabled, this.GetReadOnly()); 23755 if(this.isPasswordNullTextInputElementExists()) 23756 this.GetPasswordNullTextInputElement().disabled = inputElement.disabled; 23757 } 23758 }, 23759 SetReadOnlyInternal: function(readOnly) { 23760 ASPxClientEdit.prototype.SetReadOnlyInternal.call(this, readOnly); 23761 this.ChangeInputReadOnly(readOnly); 23762 }, 23763 ChangeReadOnlyStateItems: function(readOnly) { 23764 ASPxClientEdit.prototype.ChangeReadOnlyStateItems.call(this, readOnly); 23765 ASPx.GetStateController().SetElementReadOnly(this.GetInputElement(), readOnly); 23766 }, 23767 ChangeInputReadOnly: function(readOnly) { 23768 var inputElement = this.GetInputElement(); 23769 if(inputElement) 23770 inputElement.readOnly = readOnly || !this.GetEnabled() && this.UseReadOnlyForDisabled(); 23771 }, 23772 ChangeEnabledStateItems: function(enabled){ 23773 if(!this.isNative) { 23774 var sc = ASPx.GetStateController(); 23775 sc.SetElementEnabled(this.GetMainElement(), enabled); 23776 sc.SetElementEnabled(this.GetInputElement(), enabled); 23777 } 23778 }, 23779 ChangeInputEnabled: function(element, enabled, readOnly) { 23780 if(this.UseReadOnlyForDisabled()) 23781 element.readOnly = !enabled || readOnly; 23782 else 23783 element.disabled = !enabled; 23784 }, 23785 ChangeInputEnabledAttributes: function(element, method, enabled) { 23786 var ieTabIndexFix = enabled && ASPx.Browser.IE && element.setAttribute && ASPx.Attr.IsExistsAttribute(element, "savedtabIndex"); 23787 method(element, "tabIndex"); 23788 if(!enabled) element.tabIndex = -1; 23789 if(ieTabIndexFix) { 23790 window.setTimeout(function() { 23791 if(element && element.parentNode) 23792 element.parentNode.replaceChild(element, element); 23793 }, 0); 23794 } 23795 method(element, "onclick"); 23796 if(!this.NeedFocusCorrectionWhenDisabled()) 23797 method(element, "onfocus"); 23798 method(element, "onblur"); 23799 method(element, "onkeydown"); 23800 method(element, "onkeypress"); 23801 method(element, "onkeyup"); 23802 }, 23803 UseReadOnlyForDisabled: function() { 23804 return (ASPx.Browser.IE && ASPx.Browser.Version < 10) && !this.isNative; 23805 }, 23806 NeedFocusCorrectionWhenDisabled: function(){ 23807 return (ASPx.Browser.IE && ASPx.Browser.Version < 10) && !this.isNative; 23808 }, 23809 OnPostFinalization: function(args) { 23810 this.TryRestoreDisabledOnPost(args); 23811 this.TryClearInputTextDecorationOnPost(args); 23812 }, 23813 TryRestoreDisabledOnPost: function(args) { 23814 if(this.GetEnabled() || !this.UseReadOnlyForDisabled() || args.isDXCallback) 23815 return; 23816 var inputElement = this.GetInputElement(); 23817 if(inputElement) { 23818 var inputDisabled = inputElement.disabled; 23819 inputElement.disabled = true; 23820 window.setTimeout(function() { 23821 inputElement.disabled = inputDisabled; 23822 }, 0); 23823 } 23824 }, 23825 GetTempHiddenInputID: function() { 23826 return this.name + ASPx.TempHiddenInputSuffix; 23827 }, 23828 TryClearInputTextDecorationOnPost: function(args) { 23829 if(ASPx.Platform === "NETCORE") 23830 return; 23831 if(this.HasTextDecorators() && !ASPx.IsExists(this.GetValue())) { 23832 var inputElement = this.GetInputElement(); 23833 if(inputElement) { 23834 var name = ASPx.Attr.GetAttribute(inputElement, "name"); 23835 if(name) 23836 this.TryClearInputTextDecorationOnPostCore(inputElement, name); 23837 } 23838 } 23839 }, 23840 TryClearInputTextDecorationOnPostCore: function(inputElement, name) { 23841 var hiddenInput = ASPx.CreateHiddenField(name, this.GetTempHiddenInputID(), inputElement.parentNode); 23842 ASPx.Attr.SetAttribute(inputElement, "data-name", name); 23843 ASPx.Attr.RemoveAttribute(inputElement, "name"); 23844 setTimeout(function() { 23845 ASPx.Attr.SetAttribute(inputElement, "name", name); 23846 ASPx.Attr.RemoveAttribute(inputElement, "data-name"); 23847 ASPx.RemoveElement(hiddenInput); 23848 }, 0); 23849 }, 23850 OnUnload: function() { 23851 var input = this.GetInputElement(); 23852 if(!input) 23853 return; 23854 if(this.IsAutocompleteOffNotRequiredOnUnload()) 23855 ASPx.Attr.RemoveAttribute(input, "autocomplete"); 23856 if(this.focusedNullTextElement) 23857 ASPx.RemoveElement(this.focusedNullTextElement); 23858 }, 23859 IsVCardAttributeRequired: function() { 23860 return this.autoCompleteAttribute && this.autoCompleteAttribute.name !== "autocomplete"; 23861 }, 23862 IsAutocompleteDropDownListRequiredOnFocus: function() { 23863 return !this.autoCompleteAttribute || this.IsVCardAttributeRequired(); 23864 }, 23865 IsAutocompleteOffRequiredOnInitialize: function() { 23866 return !this.isNative && (this.autoCompleteAttribute && this.autoCompleteAttribute.name === "autocomplete" || ASPx.Browser.WebKitFamily); 23867 }, 23868 IsAutocompleteOffRequiredOnLostFocus: function() { 23869 return !this.autoCompleteAttribute && this.IsNullTextVisible() && !this.IsVCardAttributeRequired(); 23870 }, 23871 IsAutocompleteOffNotRequiredOnUnload: function() { 23872 return !this.IsNullTextVisible() || this.IsVCardAttributeRequired() || (this.maskInfo != null && this.GetValue() == null); 23873 }, 23874 IsNullTextVisible: function() { 23875 return this.nullText && !this.GetValue() && !this.GetText(); 23876 }, 23877 GetModifyEvent: function() { 23878 return this.UserInput; 23879 }, 23880 EnsureRequiredNativeAttributesExists: function() { 23881 var input = this.GetInputElement(); 23882 if(!input.onfocus)
23883 ASPx.Evt.AttachEventToElement(input, "focus", function() { ASPx.EGotFocus(this.name); }.aspxBind(this)); 23884 if(!input.onblur) 23885 ASPx.Evt.AttachEventToElement(input, "blur", function() { ASPx.ELostFocus(this.name); }.aspxBind(this)); 23886 } 23887}); 23888MaskValidationPattern = ASPx.CreateClass(ASPx.ValidationPattern, { 23889 constructor: function(errorText, maskInfo) { 23890 this.constructor.prototype.constructor.call(this, errorText); 23891 this.maskInfo = maskInfo; 23892 }, 23893 EvaluateIsValid: function(value) { 23894 return this.maskInfo.IsValid(); 23895 } 23896}); 23897ASPx.Ident.IsASPxClientTextEdit = function(obj) { 23898 return !!obj.isASPxClientTextEdit; 23899}; 23900var ASPxClientTextBoxBase = ASPx.CreateClass(ASPxClientTextEdit, { 23901 constructor: function(name) { 23902 this.constructor.prototype.constructor.call(this, name); 23903 this.sizingConfig.allowSetHeight = false; 23904 this.sizingConfig.adjustControl = true; 23905 } 23906}); 23907var ASPxClientTextBox = ASPx.CreateClass(ASPxClientTextBoxBase, { 23908 constructor: function(name) { 23909 this.constructor.prototype.constructor.call(this, name); 23910 this.isASPxClientTextBox = true; 23911 this.isCaptchaTextBox = false; 23912 }, 23913 NeedProcessUnload: function() { 23914 return ASPxClientTextBoxBase.prototype.NeedProcessUnload.call(this) && !this.isCaptchaTextBox; 23915 }, 23916 IsValueRestoredByBrowser: function() { 23917 if(this.isCaptchaTextBox) 23918 return this.initializeInputValue !== "" && this.initializeInputValue !== this.nullText; 23919 return ASPxClientTextBoxBase.prototype.IsValueRestoredByBrowser.call(this); 23920 }, 23921 SynchronizeRestoredValue: function() { 23922 if(this.isCaptchaTextBox) 23923 this.SetText(null); 23924 else 23925 ASPxClientTextBoxBase.prototype.SynchronizeRestoredValue.call(this); 23926 }, 23927}); 23928ASPxClientTextBox.Cast = ASPxClientControl.Cast; 23929ASPx.Ident.IsASPxClientTextBox = function(obj) { 23930 return !!obj.isASPxClientTextBox; 23931}; 23932var ASPxClientMemo = ASPx.CreateClass(ASPxClientTextEdit, { 23933 constructor: function(name) { 23934 this.constructor.prototype.constructor.call(this, name); 23935 this.isASPxClientMemo = true; 23936 this.raiseValueChangedOnEnter = false; 23937 this.maxLength = 0; 23938 this.pasteTimerID = -1; 23939 this.pasteTimerActivatorCount = 0; 23940 }, 23941 Initialize: function() { 23942 ASPxClientTextEdit.prototype.Initialize.call(this); 23943 this.SaveChangedValue(); 23944 this.maxLengthRestricted = this.maxLength > 0; 23945 }, 23946 CutString: function() { 23947 var text = this.GetText(); 23948 if(text.length > this.maxLength) { 23949 text = text.substring(0, this.maxLength); 23950 this.SetText(text); 23951 } 23952 }, 23953 EventKeyCodeChangesTheInput: function(evt) { 23954 if(ASPx.IsPasteShortcut(evt)) 23955 return true; 23956 else if(evt.ctrlKey) 23957 return false; 23958 var keyCode = ASPx.Evt.GetKeyCode(evt); 23959 var isSystemKey = ASPx.Key.Windows <= keyCode && keyCode <= ASPx.Key.ContextMenu; 23960 var isFKey = ASPx.Key.F1 <= keyCode && keyCode <= 127; 23961 return ASPx.Key.Delete < keyCode && !isSystemKey && !isFKey || keyCode == ASPx.Key.Enter || keyCode == ASPx.Key.Space; 23962 }, 23963 OnTextChangingCheck: function() { 23964 if(this.maxLengthRestricted) 23965 this.CutString(); 23966 }, 23967 StartTextChangingTimer: function() { 23968 if(this.maxLengthRestricted) { 23969 if(this.pasteTimerActivatorCount == 0) 23970 this.SetTextChangingTimer(); 23971 this.pasteTimerActivatorCount ++; 23972 } 23973 }, 23974 EndTextChangingTimer: function() { 23975 if(this.maxLengthRestricted) { 23976 this.pasteTimerActivatorCount --; 23977 if(this.pasteTimerActivatorCount == 0) 23978 this.ClearTextChangingTimer(); 23979 } 23980 }, 23981 CollapseEditor: function() { 23982 if(!this.IsAdjustmentRequired()) return; 23983 var mainElement = this.GetMainElement(); 23984 var inputElement = this.GetInputElement(); 23985 if(!ASPx.IsExistsElement(mainElement) || !ASPx.IsExistsElement(inputElement)) 23986 return; 23987 ASPxClientTextEdit.prototype.CollapseEditor.call(this); 23988 var mainElementCurStyle = ASPx.GetCurrentStyle(mainElement); 23989 if(this.heightCorrectionRequired && mainElement && inputElement) { 23990 if(mainElement.style.height == "100%" || mainElementCurStyle.height == "100%") { 23991 mainElement.style.height = "0"; 23992 mainElement.wasCollapsed = true; 23993 } 23994 inputElement.style.height = "0"; 23995 } 23996 }, 23997 SetWidth: function(width) { 23998 ASPxClientTextEdit.prototype.SetWidth.call(this, width); 23999 if(ASPx.Browser.IE) 24000 this.AdjustControl(); 24001 }, 24002 SetHeight: function(height) { 24003 var textarea = this.GetInputElement(); 24004 textarea.style.height = "1px"; 24005 ASPxClientTextEdit.prototype.SetHeight.call(this, height); 24006 textarea.style.height = ASPx.GetClearClientHeight(this.GetMainElement()) - ASPx.GetTopBottomBordersAndPaddingsSummaryValue(textarea) + "px"; 24007 }, 24008 ClearErrorFrameElementsStyles: function() { 24009 var textarea = this.GetInputElement(); 24010 if(!textarea) 24011 return; 24012 var scrollBarPosition = textarea.scrollTop; 24013 ASPxClientTextEdit.prototype.ClearErrorFrameElementsStyles.call(this); 24014 if(ASPx.Browser.Firefox) 24015 textarea.scrollTop = scrollBarPosition; 24016 }, 24017 OnMouseOver: function() { 24018 this.StartTextChangingTimer(); 24019 }, 24020 OnMouseOut: function() { 24021 this.EndTextChangingTimer(); 24022 }, 24023 OnFocus: function() { 24024 this.StartTextChangingTimer(); 24025 ASPxClientTextEdit.prototype.OnFocus.call(this); 24026 }, 24027 OnLostFocus: function() { 24028 this.EndTextChangingTimer(); 24029 ASPxClientTextEdit.prototype.OnLostFocus.call(this); 24030 }, 24031 OnKeyDown: function(evt) { 24032 if(this.NeedPreventBrowserUndoBehaviour(evt)) 24033 return ASPx.Evt.PreventEvent(evt); 24034 if(this.maxLengthRestricted){ 24035 var selection = ASPx.Selection.GetInfo(this.GetInputElement()); 24036 var noCharToReplace = selection.startPos == selection.endPos; 24037 if(this.GetText().length >= this.maxLength && noCharToReplace && this.EventKeyCodeChangesTheInput(evt)) { 24038 return ASPx.Evt.PreventEvent(evt); 24039 } 24040 } 24041 ASPxClientEdit.prototype.OnKeyDown.call(this, evt); 24042 }, 24043 SetTextChangingTimer: function() { 24044 this.pasteTimerID = ASPx.Timer.SetControlBoundInterval(this.OnTextChangingCheck, this, ASPx.PasteCheckInterval); 24045 }, 24046 ClearTextChangingTimer: function() { 24047 this.pasteTimerID = ASPx.Timer.ClearInterval(this.pasteTimerID); 24048 }, 24049 getFocusedNullTextElementTagName: function() { 24050 return "TEXTAREA"; 24051 }, 24052 getCopyFromInputElementStyles: function() { 24053 var result = ASPxClientTextEdit.prototype.getCopyFromInputElementStyles.call(this); 24054 result.push("resize"); 24055 return result; 24056 } 24057}); 24058ASPxClientMemo.Cast = ASPxClientControl.Cast; 24059ASPx.Ident.IsASPxClientMemo = function(obj) { return obj && !!obj.isASPxClientMemo; }; 24060var CLEAR_BUTTON_INDEX = -100; 24061var HIDE_CONTENT_CSS_CLASS_NAME = "dxHideContent"; 24062var setContentVisibility = function(clearButtonElement, value) { 24063 var action = value ? ASPx.RemoveClassNameFromElement : ASPx.AddClassNameToElement; 24064 action(clearButtonElement, HIDE_CONTENT_CSS_CLASS_NAME); 24065}; 24066var CLEAR_BUTTON_DISPLAY_MODE = { 24067 AUTO: 'Auto', 24068 ALWAYS: 'Always', 24069 NEVER: 'Never', 24070 ON_HOVER: 'OnHover' 24071}; 24072var AccessibilityFocusedButtonClassName = "dxAFB"; 24073var ASPxClientButtonEditBase = ASPx.CreateClass(ASPxClientTextBoxBase, { 24074 constructor: function(name) { 24075 this.constructor.prototype.constructor.call(this, name); 24076 this.allowUserInput = true; 24077 this.isValueChanging = false; 24078 this.allowMouseWheel = true; 24079 this.isMouseOver = false; 24080 this.buttonCount = 0; 24081 this.emptyValueMaskDisplayText = ""; 24082 this.clearButtonDisplayMode = CLEAR_BUTTON_DISPLAY_MODE.AUTO; 24083 this.forceShowClearButtonAlways = false; 24084 this.recoverClearButtonVisibility = false; 24085 this.ButtonClick = new ASPxClientEvent(); 24086 }, 24087 Initialize: function() { 24088 ASPxClientTextBoxBase.prototype.Initialize.call(this); 24089 this.EnsureEmptyValueMaskDisplayText(); 24090 if(this.HasClearButton()) 24091 this.InitializeClearButton(); 24092 this.InitAccessibilityCompliant(); 24093 }, 24094 InlineInitialize: function() { 24095 ASPxClientTextBoxBase.prototype.InlineInitialize.call(this); 24096 if(this.clearButtonDisplayMode === CLEAR_BUTTON_DISPLAY_MODE.AUTO) { 24097 this.clearButtonDisplayMode = this.IsClearButtonVisibleAuto() || this.forceShowClearButtonAlways ? 24098 CLEAR_BUTTON_DISPLAY_MODE.ALWAYS : CLEAR_BUTTON_DISPLAY_MODE.NEVER; 24099 } 24100 this.EnsureClearButtonVisibility(); 24101 }, 24102 InitializeClearButton: function() { 24103 if(this.clearButtonDisplayMode === CLEAR_BUTTON_DISPLAY_MODE.ON_HOVER) { 24104 ASPx.Evt.AttachMouseEnterToElement(this.GetHoverElementToShowClearButton(), this.OnMouseOver.aspxBind(this), this.OnMouseOut.aspxBind(this)); 24105 } 24106 }, 24107 GetHoverElementToShowClearButton: function() { 24108 return this.GetMainElement(); 24109 }, 24110 IsClearButtonVisibleAuto: function() { 24111 return ASPx.Browser.MobileUI; 24112 }, 24113 SetEnabled: function(enabled) { 24114 ASPxClientTextBoxBase.prototype.SetEnabled.call(this, enabled); 24115 this.EnsureClearButtonVisibility(); 24116 }, 24117 EnsureEmptyValueMaskDisplayText: function() { 24118 if(this.maskInfo && this.HasClearButton()) { 24119 var savedText = this.maskInfo.GetText(); 24120 this.maskInfo.SetText(""); 24121 this.emptyValueMaskDisplayText = this.maskInfo.GetText(); 24122 this.maskInfo.SetText(savedText); 24123 } 24124 }, 24125 GetButton: function(number) { 24126 return this.GetChildElement("B" + number); 24127 }, 24128 GetCustomButtonCollection: function() { 24129 var buttonElements = []; 24130 for(var i = 0; i < this.buttonCount; i++) { 24131 var button = this.GetButton(i); 24132 if(!!button) 24133 buttonElements.push(button); 24134 } 24135 return buttonElements; 24136 }, 24137 GetButtonCollection: function() { 24138 var buttonElements = []; 24139 var clearButton = this.GetClearButton(); 24140 if(!!clearButton) 24141 buttonElements.push(clearButton); 24142 return buttonElements.concat(this.GetCustomButtonCollection()); 24143 }, 24144 GetAccessibilityAnchor: function(buttonElement) { 24145 var firstChild = buttonElement.firstElementChild; 24146 var isExistsAnchorElement = ASPx.Attr.GetAttribute(firstChild, "role") === "button"; 24147 return isExistsAnchorElement ? firstChild : null; 24148 }, 24149 GetButtonByAccessibilityAnchor: function(anchorElement) { 24150 return anchorElement.parentNode; 24151 }, 24152 SetAccessibilityAnchorEnabled: function(buttonElement, enabled) { 24153 var anchorElement = this.GetAccessibilityAnchor(buttonElement); 24154 if(ASPx.IsExists(anchorElement)) 24155 ASPx.Attr.SetOrRemoveAttribute(anchorElement, "tabindex", enabled ? "0" : ""); 24156 }, 24157 InitAccessibilityCompliant: function() { 24158 if(!this.accessibilityCompliant) return; 24159 var buttonElements = this.GetButtonCollection(); 24160 var labelElements = ASPx.FindAssociatedLabelElements(this); 24161 for(var i = 0; i < buttonElements.length; i++) 24162 this.InitAccessibilityAnchor(this.GetAccessibilityAnchor(buttonElements[i]), labelElements); 24163 }, 24164 InitAccessibilityAnchor: function(anchorElement, labelElements) { 24165 if(!ASPx.IsExists(anchorElement)) 24166 return; 24167 for(var i = 0; i < labelElements.length; i++) 24168 this.ariaExplanatoryTextManager.SetOrRemoveText([anchorElement], labelElements[i], true, false, false); 24169 this.InitAccessibilityAnchorEvents(anchorElement); 24170 }, 24171 InitAccessibilityAnchorEvents: function(anchorElement) { 24172 ASPx.Evt.AttachEventToElement(anchorElement, "keydown", function(evt) { this.OnButtonKeysHandling(evt); }.aspxBind(this)); 24173 ASPx.Evt.AttachEventToElement(anchorElement, "keyup", function(evt) { this.OnButtonKeysHandling(evt); }.aspxBind(this)); 24174 ASPx.Evt.AttachEventToElement(anchorElement, "focus", function(evt) { this.OnButtonGotFocus(evt); }.aspxBind(this)); 24175 ASPx.Evt.AttachEventToElement(anchorElement, "blur", function(evt) { this.OnButtonLostFocus(evt); }.aspxBind(this)); 24176 }, 24177 EmulateButtonMouseEvent: function(sourceElement) { 24178 var buttonElement = this.GetButtonByAccessibilityAnchor(sourceElement); 24179 var mouseEvent = buttonElement.onclick || buttonElement.onmousedown || buttonElement.ontouchstart || buttonElement.onpointerdown; 24180 var emulateMouseEvtArgs = { button: 0, which: 1, srcElement: buttonElement, target: buttonElement }; 24181 if(!!mouseEvent) { 24182 ASPx.Attr.SetAttribute(sourceElement, "aria-pressed", true); 24183 setTimeout(function() { 24184 mouseEvent(emulateMouseEvtArgs); 24185 ASPx.Attr.RemoveAttribute(sourceElement, "aria-pressed"); 24186 }, 300); 24187 } 24188 }, 24189 OnButtonKeysHandling: function(evt) { 24190 var isKeyUp = evt.type == "keyup"; 24191 var keyCode = ASPx.Evt.GetKeyCode(evt); 24192 var sourceElement = ASPx.Evt.GetEventSource(evt); 24193 if((keyCode == ASPx.Key.Space && isKeyUp) || (keyCode == ASPx.Key.Enter && !isKeyUp)) 24194 this.EmulateButtonMouseEvent(sourceElement); 24195 if(keyCode != ASPx.Key.Tab) 24196 ASPx.Evt.PreventEventAndBubble(evt); 24197 return false; 24198 }, 24199 OnButtonGotFocus: function(evt) { 24200 var editor = ASPx.GetControlCollection().Get(this.name); 24201 var sourceElement = ASPx.Evt.GetEventSource(evt);
24202 if(!!editor && !editor.CorrectAccessibilityButtonFocus(sourceElement)) { 24203 var buttonElement = editor.GetButtonByAccessibilityAnchor(sourceElement); 24204 ASPx.AddClassNameToElement(buttonElement, this.GetAccessibilityFocusedButtonClassName()); 24205 ASPx.EGotFocus(editor.name); 24206 if(editor.specialKeyboardHandlingUsed) 24207 ASPx.ESGotFocus(editor.name); 24208 } 24209 }, 24210 OnButtonLostFocus: function(evt) { 24211 var editor = ASPx.GetControlCollection().Get(this.name); 24212 var sourceElement = ASPx.Evt.GetEventSource(evt); 24213 if(!!editor) { 24214 var buttonElement = editor.GetButtonByAccessibilityAnchor(sourceElement); 24215 ASPx.RemoveClassNameFromElement(buttonElement, this.GetAccessibilityFocusedButtonClassName()); 24216 } 24217 setTimeout(function() { 24218 if(!!editor && !editor.IsEditorElement(ASPx.GetActiveElement())) { 24219 ASPx.ELostFocus(editor.name); 24220 if(editor.specialKeyboardHandlingUsed) 24221 ASPx.ESLostFocus(editor.name); 24222 } 24223 }.aspxBind(this), 0); 24224 }, 24225 ForceRefocusEditor: function(evt, isNativeFocus) { 24226 if(this.accessibilityCompliant) { 24227 var srcElement = ASPx.Evt.GetEventSource(evt); 24228 var customButtons = this.GetCustomButtonCollection(); 24229 for(var i = 0; i < customButtons.length; i++) 24230 if(customButtons[i] == srcElement || ASPx.GetIsParent(customButtons[i], srcElement)) 24231 return; 24232 } 24233 ASPxClientEdit.prototype.ForceRefocusEditor.call(this, evt, isNativeFocus); 24234 if(this.GetInputElement().type == "password") { 24235 window.setTimeout(function() { this.GetInputElement().focus(); }.bind(this), 0); 24236 } 24237 },
24238 CorrectAccessibilityButtonFocus: function(sourceElement) { 24239 if(ASPx.Attr.IsExistsAttribute(sourceElement, "tabindex")) 24240 return false; 24241 setTimeout(function() { 24242 var buttonElements = this.GetButtonCollection(); 24243 for(var i = 0; i < buttonElements.length; i++) 24244 if(ASPx.GetIsParent(buttonElements[i], sourceElement)) 24245 this.GetAccessibilityAnchor(buttonElements[i]).focus(); 24246 }.aspxBind(this), 0); 24247 return true; 24248 }, 24249 OnKeyDown: function(evt) { 24250 if(this.NeedEnsureClearButtonVisibilityOnKeyDown()) { 24251 var hasClearButtonOnHover = this.HasClearButton() && this.clearButtonDisplayMode === CLEAR_BUTTON_DISPLAY_MODE.ON_HOVER; 24252 this.recoverClearButtonVisibility = hasClearButtonOnHover && ASPx.Evt.GetKeyCode(evt) == ASPx.Key.Tab && !evt.shiftKey; 24253 } 24254 ASPxClientTextBoxBase.prototype.OnKeyDown.call(this, evt); 24255 }, 24256 NeedEnsureClearButtonVisibilityOnKeyDown: function() { 24257 return this.accessibilityCompliant; 24258 }, 24259 GetAccessibilityFocusedButtonClassName: function() { 24260 return AccessibilityFocusedButtonClassName; 24261 }, 24262 SetButtonVisible: function(number, value) { 24263 var button = this.GetButton(number); 24264 if(!button) 24265 return; 24266 var isAlwaysShownClearButton = number === CLEAR_BUTTON_INDEX && this.clearButtonDisplayMode === CLEAR_BUTTON_DISPLAY_MODE.ALWAYS; 24267 var visibilityModifier = isAlwaysShownClearButton ? setContentVisibility : ASPx.SetElementDisplay; 24268 if(isAlwaysShownClearButton && this.accessibilityCompliant && this.enabled)
24269 this.SetAccessibilityAnchorEnabled(button, value); 24270 visibilityModifier(button, value); 24271 }, 24272 GetButtonVisible: function(number) { 24273 var button = this.GetButton(number); 24274 if(number === CLEAR_BUTTON_INDEX && this.clearButtonDisplayMode === CLEAR_BUTTON_DISPLAY_MODE.ALWAYS) 24275 return button && !ASPx.ElementHasCssClass(button, this.GetHideContentCssClassName()); 24276 return button && ASPx.IsElementVisible(button); 24277 }, 24278 GetHideContentCssClassName: function() { 24279 return HIDE_CONTENT_CSS_CLASS_NAME; 24280 }, 24281 ProcessInternalButtonClick: function(buttonIndex) { 24282 return false; 24283 }, 24284 OnButtonClick: function(number) { 24285 var processOnServer = this.RaiseButtonClick(number); 24286 if(!this.ProcessInternalButtonClick(number) && processOnServer) 24287 this.SendPostBack('BC:' + number); 24288 }, 24289 GetLastSuccesfullValue: function() { 24290 return this.lastChangedValue; 24291 }, 24292 OnClear: function() { 24293 this.startUserInputEventTimerIfRequired(); 24294 this.ClearEditorValueAndForceOnChange(); 24295 this.ForceRefocusEditor(null, true); 24296 window.setTimeout(this.EnsureClearButtonVisibility.aspxBind(this), 0); 24297 }, 24298 ClearEditorValueAndForceOnChange: function() { 24299 if(this.GetReadOnly() || !this.GetButtonVisible(CLEAR_BUTTON_INDEX)) 24300 return; 24301 var raiseOnChange = this.ClearEditorValueByClearButton(); 24302 if(raiseOnChange) 24303 this.ForceStandardOnChange(); 24304 }, 24305 ClearEditorValueByClearButton: function() { 24306 var prevValue = this.GetLastSuccesfullValue(); 24307 this.ClearEditorValueByClearButtonCore(); 24308 return prevValue !== this.GetValue(); 24309 }, 24310 ClearEditorValueByClearButtonCore: function() { 24311 this.Clear(); 24312 this.GetInputElement().value = ''; 24313 }, 24314 ForceStandardOnChange: function() { 24315 this.forceValueChanged = true; 24316 this.RaiseStandardOnChange(); 24317 this.forceValueChanged = false; 24318 }, 24319 IsValueChangeForced: function() { 24320 return this.forceValueChanged || ASPxClientTextBoxBase.prototype.IsValueChangeForced.call(this); 24321 }, 24322 IsValueChanging: function() { return this.isValueChanging; }, 24323 StartValueChanging: function() { this.isValueChanging = true; }, 24324 EndValueChanging: function() { this.isValueChanging = false; }, 24325 IsClearButtonElement: function(element) { 24326 return ASPx.GetIsParent(this.GetClearButton(), element); 24327 }, 24328 OnFocusCore: function() { 24329 ASPxClientTextBoxBase.prototype.OnFocusCore.call(this); 24330 this.EnsureClearButtonVisibility(); 24331 }, 24332 OnLostFocusCore: function() { 24333 ASPxClientTextBoxBase.prototype.OnLostFocusCore.call(this); 24334 this.EnsureClearButtonVisibility(); 24335 this.recoverClearButtonVisibility = false; 24336 }, 24337 GetClearButton: function() { 24338 return this.GetButton(CLEAR_BUTTON_INDEX); 24339 }, 24340 HasClearButton: function() { 24341 return !!this.GetClearButton(); 24342 }, 24343 RequireShowClearButton: function() { 24344 return !this.IsClearButtonDisabled() && !this.IsClearButtonNotRequired() && this.RequireShowClearButtonInternal(); 24345 }, 24346 IsClearButtonDisabled: function() { 24347 return !this.clientEnabled || !this.HasClearButton() || this.clearButtonDisplayMode === CLEAR_BUTTON_DISPLAY_MODE.NEVER; 24348 }, 24349 IsClearButtonNotRequired: function() { 24350 return !this.IsFocused() && !this.isMouseOver && this.clearButtonDisplayMode !== CLEAR_BUTTON_DISPLAY_MODE.ALWAYS && !this.recoverClearButtonVisibility; 24351 }, 24352 RequireShowClearButtonInternal: function () { 24353 return this.IsFocused() && this.RequireShowClearButtonCore() || !this.IsNullState(); 24354 }, 24355 RequireShowClearButtonCore: function() { 24356 var inputText = this.GetInputElement().value; 24357 return inputText !== this.GetEmptyValueDisplayText(); 24358 }, 24359 IsFocused: function() { 24360 return this === ASPx.GetFocusedEditor(); 24361 }, 24362 IsNullState: function() { 24363 var value = this.GetValue(); 24364 return this.IsNull(value) || value === this.GetEmptyValueDisplayText(); 24365 }, 24366 GetEmptyValueDisplayText: function() { 24367 return this.maskInfo ? this.emptyValueMaskDisplayText : ""; 24368 }, 24369 EnsureClearButtonVisibility: function() { 24370 this.SetButtonVisible(CLEAR_BUTTON_INDEX, this.RequireShowClearButton()); 24371 }, 24372 OnMouseOver: function() { 24373 this.isMouseOver = true; 24374 this.EnsureClearButtonVisibility(); 24375 }, 24376 OnMouseOut: function() { 24377 this.isMouseOver = false; 24378 this.EnsureClearButtonVisibility(); 24379 }, 24380 OnKeyPress: function(evt) { 24381 if(this.allowUserInput) 24382 ASPxClientTextBoxBase.prototype.OnKeyPress.call(this, evt); 24383 }, 24384 OnKeyEventEnd: function(evt, withDelay) { 24385 ASPxClientTextBoxBase.prototype.OnKeyEventEnd.call(this, evt, withDelay); 24386 this.EnsureClearButtonVisibility(); 24387 }, 24388 RaiseButtonClick: function(number){
24389 var processOnServer = this.autoPostBack || this.IsServerEventAssigned("ButtonClick"); 24390 if(!this.ButtonClick.IsEmpty()){ 24391 var args = new ASPxClientButtonEditClickEventArgs(processOnServer, number); 24392 this.ButtonClick.FireEvent(this, args); 24393 processOnServer = args.processOnServer; 24394 } 24395 return processOnServer; 24396 }, 24397 ChangeEnabledAttributes: function(enabled){ 24398 ASPxClientTextEdit.prototype.ChangeEnabledAttributes.call(this, enabled); 24399 for(var i = 0; i < this.buttonCount; i++){ 24400 var element = this.GetButton(i); 24401 if(element) 24402 this.ChangeButtonEnabledAttributes(element, this.GetChangeButtonEnabledAttributesMethod(enabled)); 24403 } 24404 if(this.accessibilityCompliant) 24405 this.ChangeAccessibilityButtonEnabledAttributes(enabled); 24406 }, 24407 ChangeEnabledStateItems: function(enabled){ 24408 ASPxClientTextEdit.prototype.ChangeEnabledStateItems.call(this, enabled); 24409 for(var i = 0; i < this.buttonCount; i++){ 24410 var element = this.GetButton(i); 24411 if(element) 24412 ASPx.GetStateController().SetElementEnabled(element, enabled); 24413 } 24414 }, 24415 GetChangeButtonEnabledAttributesMethod: function(enabled) { 24416 return ASPx.Attr.ChangeAttributesMethod(enabled); 24417 }, 24418 ChangeButtonEnabledAttributes: function(element, method){ 24419 method(element, "onclick"); 24420 method(element, "ondblclick"); 24421 if(ASPx.Browser.Edge) 24422 method(element, "onmousedown"); 24423 method(element, "on" + ASPx.TouchUIHelper.touchMouseDownEventName); 24424 method(element, "on" + ASPx.TouchUIHelper.touchMouseUpEventName); 24425 }, 24426 ChangeInputEnabled: function(element, enabled, readOnly) { 24427 ASPxClientTextEdit.prototype.ChangeInputEnabled.call(this, element, enabled, readOnly || !this.allowUserInput); 24428 }, 24429 ChangeAccessibilityButtonEnabledAttributes: function(enabled) { 24430 var buttonElements = this.GetButtonCollection(); 24431 for(var i = 0; i < buttonElements.length; i++)
24432 this.SetAccessibilityAnchorEnabled(buttonElements[i], enabled); 24433 }, 24434 SetValue: function(value) { 24435 ASPxClientTextEdit.prototype.SetValue.call(this, value); 24436 if(!this.IsFocused()) 24437 this.EnsureClearButtonVisibility(); 24438 }, 24439 OnAssociatedLabelClick: function(focusableElement) { 24440 var isValidElement = focusableElement && ASPx.IsActionElement(focusableElement) && ASPx.GetIsParent(this.GetMainElement(), focusableElement) && ASPx.IsElementVisible(focusableElement); 24441 if(isValidElement) 24442 focusableElement.focus(); 24443 else 24444 this.SetFocus(); 24445 }, 24446 onClearButtonClick: function() { 24447 var requireFocus = !ASPx.Browser.VirtualKeyboardSupported || ASPx.Browser.MSTouchUI; 24448 if(this.ownerListBox) 24449 this.ownerListBox.ForceLockFocusEvents(); 24450 if(requireFocus && !this.IsFocused()) 24451 this.GetInputElement().focus(); 24452 if(this.IsFocused() || !requireFocus) { 24453 if(this.ownerListBox) 24454 this.ownerListBox.UnlockFocusEvents(); 24455 this.OnClear(); 24456 } 24457 else 24458 window.setTimeout(this.onClearButtonClick.bind(this), 100); 24459 } 24460}); 24461var ASPxClientButtonEdit = ASPx.CreateClass(ASPxClientButtonEditBase, { 24462}); 24463ASPxClientButtonEdit.Cast = ASPxClientControl.Cast; 24464var ASPxClientButtonEditClickEventArgs = ASPx.CreateClass(ASPxClientProcessingModeEventArgs, { 24465 constructor: function(processOnServer, buttonIndex){ 24466 this.constructor.prototype.constructor.call(this, processOnServer); 24467 this.buttonIndex = buttonIndex; 24468 } 24469}); 24470var ASPxClientTextEditHelpTextHAlign = { 24471 Left: "Left", 24472 Right: "Right", 24473 Center: "Center" 24474}; 24475var ASPxClientTextEditHelpTextVAlign = { 24476 Top: "Top", 24477 Bottom: "Bottom", 24478 Middle: "Middle" 24479}; 24480var ASPxClientTextEditHelpTextDisplayMode = { 24481 Inline: "Inline", 24482 Popup: "Popup" 24483}; 24484var ASPxClientTextEditHelpTextConsts = { 24485 VERTICAL_ORIENTATION_CLASS_NAME: "dxeVHelpTextSys", 24486 HORIZONTAL_ORIENTATION_CLASS_NAME: "dxeHHelpTextSys" 24487}; 24488var ASPxClientTextEditHelpText = ASPx.CreateClass(null, { 24489 constructor: function (editor, helpTextStyle, helpText, position, hAlign, vAlign, margins, animationEnabled, helpTextDisplayMode) { 24490 this.hAlign = hAlign; 24491 this.vAlign = vAlign; 24492 this.animationEnabled = animationEnabled; 24493 this.displayMode = helpTextDisplayMode; 24494 this.editor = editor; 24495 this.editorMainElement = editor.GetMainElement(); 24496 this.margins = margins ? { Top: margins[0], Right: margins[1], Bottom: margins[2], Left: margins[3] } : null; 24497 this.defaultMargins = { Top: 10, Right: 10, Bottom: 10, Left: 10 }; 24498 this.position = position; 24499 this.helpTextElement = this.createHelpTextElement(); 24500 this.setHelpTextZIndex(true); 24501 this.prepareHelpTextElement(helpTextStyle, helpText); 24502 }, 24503 getRows: function (table) { 24504 return ASPx.GetChildNodesByTagName(table, "TR"); 24505 }, 24506 getCells: function (row) { 24507 return ASPx.GetChildNodesByTagName(row, "TD"); 24508 }, 24509 getCellByIndex: function(row, cellIndex) { 24510 return this.getCells(row)[cellIndex]; 24511 }, 24512 getCellIndex: function(row, cell) { 24513 var cells = this.getCells(row); 24514 for(var i = 0; i < cells.length; i++) { 24515 if(cells[i] === cell) 24516 return i; 24517 } 24518 }, 24519 isHorizontal: function(position) { 24520 return position === ASPx.Position.Left || position === ASPx.Position.Right; 24521 }, 24522 isVertical: function (position) { 24523 return position === ASPx.Position.Top || position === ASPx.Position.Bottom; 24524 }, 24525 createEmptyCell: function(assignClassName) { 24526 var cell = document.createElement("TD"); 24527 if(assignClassName) 24528 cell.className = "dxeFakeEmptyCell"; 24529 return cell; 24530 }, 24531 addHelpTextCellToExternalTableWithTwoCells: function (captionCell, errorCell, helpTextCell, errorTableBody, tableRows) { 24532 var captionPosition = this.editor.captionPosition; 24533 var errorCellPosition = this.editor.errorCellPosition; 24534 var helpTextRow = this.isVertical(this.position) ? document.createElement("TR") : null; 24535 if(captionPosition === ASPx.Position.Left && this.position === ASPx.Position.Left && this.isHorizontal(errorCellPosition)) 24536 captionCell.parentNode.insertBefore(helpTextCell, captionCell.nextSibling); 24537 if(captionPosition === ASPx.Position.Right && this.position === ASPx.Position.Right && this.isHorizontal(errorCellPosition)) 24538 captionCell.parentNode.insertBefore(helpTextCell, captionCell); 24539 if(captionPosition === ASPx.Position.Left && this.position === ASPx.Position.Right && this.isHorizontal(errorCellPosition)) 24540 tableRows[0].appendChild(helpTextCell); 24541 if(captionPosition === ASPx.Position.Right && this.position === ASPx.Position.Left && this.isHorizontal(errorCellPosition)) 24542 tableRows[0].insertBefore(helpTextCell, tableRows[0].childNodes[0]); 24543 if(captionPosition === ASPx.Position.Top && this.position === ASPx.Position.Bottom && this.isVertical(errorCellPosition)) { 24544 helpTextRow.appendChild(helpTextCell); 24545 errorTableBody.appendChild(helpTextRow); 24546 } 24547 if(captionPosition === ASPx.Position.Bottom && this.position === ASPx.Position.Top && this.isVertical(errorCellPosition)) { 24548 helpTextRow.appendChild(helpTextCell); 24549 errorTableBody.insertBefore(helpTextRow, errorTableBody.childNodes[0]); 24550 } 24551 if(captionPosition === ASPx.Position.Top && this.position === ASPx.Position.Top && this.isVertical(errorCellPosition)) { 24552 helpTextRow.appendChild(helpTextCell); 24553 errorTableBody.insertBefore(helpTextRow, captionCell.parentNode.nextSibling); 24554 } 24555 if(captionPosition === ASPx.Position.Bottom && this.position === ASPx.Position.Bottom && this.isVertical(errorCellPosition)) { 24556 helpTextRow.appendChild(helpTextCell); 24557 errorTableBody.insertBefore(helpTextRow, captionCell.parentNode); 24558 } 24559 if(captionPosition === ASPx.Position.Right && this.position === ASPx.Position.Top && this.isVertical(errorCellPosition)) { 24560 helpTextRow.appendChild(helpTextCell); 24561 helpTextRow.appendChild(this.createEmptyCell()); 24562 errorTableBody.insertBefore(helpTextRow, errorTableBody.childNodes[0]); 24563 } 24564 if(this.position === ASPx.Position.Bottom) { 24565 if(captionPosition === ASPx.Position.Right && errorCellPosition === ASPx.Position.Top || captionPosition === ASPx.Position.Top && errorCellPosition === ASPx.Position.Right) { 24566 helpTextRow.appendChild(helpTextCell); 24567 helpTextRow.appendChild(this.createEmptyCell()); 24568 errorTableBody.appendChild(helpTextRow); 24569 } 24570 } 24571 if(captionPosition === ASPx.Position.Left && this.position === ASPx.Position.Top && this.isVertical(errorCellPosition)) { 24572 helpTextRow.appendChild(this.createEmptyCell()); 24573 helpTextRow.appendChild(helpTextCell); 24574 errorTableBody.insertBefore(helpTextRow, errorTableBody.childNodes[0]); 24575 } 24576 if(captionPosition === ASPx.Position.Left && this.position === ASPx.Position.Bottom && this.isVertical(errorCellPosition)) { 24577 helpTextRow.appendChild(this.createEmptyCell()); 24578 helpTextRow.appendChild(helpTextCell); 24579 errorTableBody.appendChild(helpTextRow); 24580 } 24581 if(this.position === ASPx.Position.Right) { 24582 if(captionPosition === ASPx.Position.Top && errorCellPosition === ASPx.Position.Left || captionPosition === ASPx.Position.Left && errorCellPosition === ASPx.Position.Top 24583 || captionPosition === ASPx.Position.Top && errorCellPosition === ASPx.Position.Right) { 24584 tableRows[1].appendChild(helpTextCell); 24585 tableRows[0].appendChild(this.createEmptyCell()); 24586 } 24587 if(captionPosition === ASPx.Position.Left && errorCellPosition === ASPx.Position.Bottom || captionPosition === ASPx.Position.Bottom && errorCellPosition === ASPx.Position.Left) { 24588 tableRows[0].appendChild(helpTextCell); 24589 tableRows[1].appendChild(this.createEmptyCell()); 24590 } 24591 } 24592 if(this.position === ASPx.Position.Left) { 24593 if(captionPosition === ASPx.Position.Right && errorCellPosition === ASPx.Position.Top || captionPosition === ASPx.Position.Top && errorCellPosition === ASPx.Position.Right 24594 || captionPosition === ASPx.Position.Top && errorCellPosition === ASPx.Position.Left) { 24595 tableRows[1].insertBefore(helpTextCell, tableRows[1].childNodes[0]); 24596 tableRows[0].insertBefore(this.createEmptyCell(), tableRows[0].childNodes[0]); 24597 } 24598 if(captionPosition === ASPx.Position.Bottom && errorCellPosition === ASPx.Position.Top || captionPosition === ASPx.Position.Top && errorCellPosition === ASPx.Position.Bottom) { 24599 tableRows[1].insertBefore(helpTextCell, tableRows[1].childNodes[0]); 24600 tableRows[0].insertBefore(this.createEmptyCell(errorCellPosition === ASPx.Position.Top), tableRows[0].childNodes[0]); 24601 tableRows[2].insertBefore(this.createEmptyCell(errorCellPosition !== ASPx.Position.Top), tableRows[2].childNodes[0]); 24602 } 24603 if(captionPosition === ASPx.Position.Top && errorCellPosition === ASPx.Position.Top) { 24604 tableRows[2].insertBefore(helpTextCell, tableRows[2].childNodes[0]); 24605 tableRows[0].insertBefore(this.createEmptyCell(false), tableRows[0].childNodes[0]); 24606 tableRows[1].insertBefore(this.createEmptyCell(true), tableRows[1].childNodes[0]); 24607 } 24608 if(captionPosition === ASPx.Position.Bottom && errorCellPosition === ASPx.Position.Bottom) { 24609 tableRows[0].insertBefore(helpTextCell, tableRows[0].childNodes[0]); 24610 tableRows[1].insertBefore(this.createEmptyCell(true), tableRows[1].childNodes[0]); 24611 tableRows[2].insertBefore(this.createEmptyCell(false), tableRows[2].childNodes[0]); 24612 } 24613 if(captionPosition === ASPx.Position.Bottom && errorCellPosition === ASPx.Position.Left || captionPosition === ASPx.Position.Right && errorCellPosition === ASPx.Position.Bottom 24614 || captionPosition === ASPx.Position.Bottom && errorCellPosition === ASPx.Position.Right) { 24615 tableRows[0].insertBefore(helpTextCell, tableRows[0].childNodes[0]); 24616 tableRows[1].insertBefore(this.createEmptyCell(), tableRows[1].childNodes[0]); 24617 } 24618 if(captionPosition === ASPx.Position.Left && this.isVertical(errorCellPosition)) { 24619 captionCell.parentNode.insertBefore(helpTextCell, captionCell.nextSibling); 24620 var emptyCellParentRow = errorCellPosition === ASPx.Position.Top ? tableRows[0] : tableRows[1]; 24621 var helpTextCellIndex = this.getCellIndex(helpTextCell.parentNode, helpTextCell); 24622 emptyCellParentRow.insertBefore(this.createEmptyCell(), this.getCellByIndex(emptyCellParentRow, helpTextCellIndex)); 24623 } 24624 } 24625 if(this.position === ASPx.Position.Right) { 24626 if(captionPosition === ASPx.Position.Bottom && errorCellPosition === ASPx.Position.Top || captionPosition === ASPx.Position.Top && errorCellPosition === ASPx.Position.Bottom) { 24627 tableRows[1].appendChild(helpTextCell); 24628 tableRows[0].appendChild(this.createEmptyCell(errorCellPosition === ASPx.Position.Top)); 24629 tableRows[2].appendChild(this.createEmptyCell(errorCellPosition !== ASPx.Position.Top)); 24630 } 24631 if(captionPosition === ASPx.Position.Top && errorCellPosition === ASPx.Position.Top) { 24632 tableRows[2].appendChild(helpTextCell); 24633 tableRows[0].appendChild(this.createEmptyCell(false)); 24634 tableRows[1].appendChild(this.createEmptyCell(true)); 24635 } 24636 if(captionPosition === ASPx.Position.Bottom && errorCellPosition === ASPx.Position.Bottom) { 24637 tableRows[0].appendChild(helpTextCell); 24638 tableRows[1].appendChild(this.createEmptyCell(true)); 24639 tableRows[2].appendChild(this.createEmptyCell(false)); 24640 } 24641 if(captionPosition === ASPx.Position.Bottom && errorCellPosition === ASPx.Position.Right) { 24642 tableRows[0].appendChild(helpTextCell); 24643 tableRows[1].appendChild(this.createEmptyCell()); 24644 } 24645 if(captionPosition === ASPx.Position.Right && this.isVertical(errorCellPosition)) { 24646 captionCell.parentNode.insertBefore(helpTextCell, captionCell); 24647 var emptyCellParentRow = errorCellPosition === ASPx.Position.Top ? tableRows[0] : tableRows[1]; 24648 var helpTextCellIndex = this.getCellIndex(helpTextCell.parentNode, helpTextCell); 24649 emptyCellParentRow.insertBefore(this.createEmptyCell(), this.getCellByIndex(emptyCellParentRow, helpTextCellIndex)); 24650 } 24651 } 24652 if(captionPosition === ASPx.Position.Top && this.position === ASPx.Position.Top && this.isHorizontal(errorCellPosition)) { 24653 if(errorCellPosition === ASPx.Position.Left) { 24654 helpTextRow.appendChild(this.createEmptyCell(true)); 24655 helpTextRow.appendChild(helpTextCell); 24656 } 24657 else { 24658 helpTextRow.appendChild(helpTextCell); 24659 helpTextRow.appendChild(this.createEmptyCell()); 24660 } 24661 errorTableBody.insertBefore(helpTextRow, captionCell.parentNode.nextSibling); 24662 } 24663 if(captionPosition === ASPx.Position.Bottom && this.position === ASPx.Position.Top && this.isHorizontal(errorCellPosition)) { 24664 if(errorCellPosition === ASPx.Position.Left) { 24665 helpTextRow.appendChild(this.createEmptyCell(true)); 24666 helpTextRow.appendChild(helpTextCell); 24667 } 24668 else { 24669 helpTextRow.appendChild(helpTextCell); 24670 helpTextRow.appendChild(this.createEmptyCell()); 24671 } 24672 errorTableBody.insertBefore(helpTextRow, errorTableBody.childNodes[0]); 24673 } 24674 if(captionPosition === ASPx.Position.Bottom && this.position === ASPx.Position.Bottom && this.isHorizontal(errorCellPosition)) { 24675 if(errorCellPosition === ASPx.Position.Left) { 24676 helpTextRow.appendChild(this.createEmptyCell(true)); 24677 helpTextRow.appendChild(helpTextCell); 24678 } 24679 else { 24680 helpTextRow.appendChild(helpTextCell); 24681 helpTextRow.appendChild(this.createEmptyCell()); 24682 } 24683 errorTableBody.insertBefore(helpTextRow, captionCell.parentNode); 24684 } 24685 if(captionPosition === ASPx.Position.Top && this.position === ASPx.Position.Bottom && errorCellPosition === ASPx.Position.Left) { 24686 helpTextRow.appendChild(this.createEmptyCell(true)); 24687 helpTextRow.appendChild(helpTextCell); 24688 errorTableBody.appendChild(helpTextRow); 24689 } 24690 if(captionPosition === ASPx.Position.Right && this.position === ASPx.Position.Bottom && errorCellPosition === ASPx.Position.Bottom) { 24691 helpTextRow.appendChild(helpTextCell); 24692 helpTextRow.appendChild(this.createEmptyCell()); 24693 errorTableBody.appendChild(helpTextRow); 24694 } 24695 if(this.position === ASPx.Position.Bottom) { 24696 if(captionPosition === ASPx.Position.Left && errorCellPosition === ASPx.Position.Right || captionPosition === ASPx.Position.Right && errorCellPosition === ASPx.Position.Left) { 24697 helpTextRow.appendChild(this.createEmptyCell(errorCellPosition !== ASPx.Position.Right)); 24698 helpTextRow.appendChild(helpTextCell); 24699 helpTextRow.appendChild(this.createEmptyCell(errorCellPosition === ASPx.Position.Right)); 24700 errorTableBody.appendChild(helpTextRow); 24701 } 24702 if(captionPosition === ASPx.Position.Left && errorCellPosition === ASPx.Position.Left) { 24703 helpTextRow.appendChild(this.createEmptyCell(false)); 24704 helpTextRow.appendChild(this.createEmptyCell(true)); 24705 helpTextRow.appendChild(helpTextCell); 24706 errorTableBody.appendChild(helpTextRow); 24707 } 24708 if(captionPosition === ASPx.Position.Right && errorCellPosition === ASPx.Position.Right) { 24709 helpTextRow.appendChild(helpTextCell); 24710 helpTextRow.appendChild(this.createEmptyCell(true)); 24711 helpTextRow.appendChild(this.createEmptyCell(false)); 24712 errorTableBody.appendChild(helpTextRow); 24713 } 24714 } 24715 if(this.position === ASPx.Position.Top) { 24716 if(captionPosition === ASPx.Position.Left && errorCellPosition === ASPx.Position.Right || captionPosition === ASPx.Position.Right && errorCellPosition === ASPx.Position.Left) { 24717 helpTextRow.appendChild(this.createEmptyCell(errorCellPosition !== ASPx.Position.Right)); 24718 helpTextRow.appendChild(helpTextCell); 24719 helpTextRow.appendChild(this.createEmptyCell(errorCellPosition === ASPx.Position.Right)); 24720 errorTableBody.insertBefore(helpTextRow, errorTableBody.childNodes[0]); 24721 } 24722 if(captionPosition === ASPx.Position.Left && errorCellPosition === ASPx.Position.Left) { 24723 helpTextRow.appendChild(this.createEmptyCell(false)); 24724 helpTextRow.appendChild(this.createEmptyCell(true)); 24725 helpTextRow.appendChild(helpTextCell); 24726 errorTableBody.insertBefore(helpTextRow, errorTableBody.childNodes[0]); 24727 } 24728 if(captionPosition === ASPx.Position.Right && errorCellPosition === ASPx.Position.Right) { 24729 helpTextRow.appendChild(helpTextCell); 24730 helpTextRow.appendChild(this.createEmptyCell(true)); 24731 helpTextRow.appendChild(this.createEmptyCell(false)); 24732 errorTableBody.insertBefore(helpTextRow, errorTableBody.childNodes[0]); 24733 } 24734 } 24735 }, 24736 addHelpTextCellToExternalTableWithErrorCell: function (errorCell, helpTextCell, errorTableBody, tableRows) { 24737 var errorCellPosition = this.editor.
24737errorCellPosition; 24738 var helpTextRow = document.createElement("TR"); 24739 if(this.position === ASPx.Position.Left && this.isHorizontal(errorCellPosition)) 24740 tableRows[0].insertBefore(helpTextCell, tableRows[0].childNodes[0]); 24741 if(this.position === ASPx.Position.Right && this.isHorizontal(errorCellPosition)) 24742 tableRows[0].appendChild(helpTextCell); 24743 if(this.position === ASPx.Position.Top && this.isVertical(errorCellPosition)) { 24744 helpTextRow.appendChild(helpTextCell); 24745 errorTableBody.insertBefore(helpTextRow, errorTableBody.childNodes[0]); 24746 } 24747 if(this.position === ASPx.Position.Bottom && this.isVertical(errorCellPosition)) { 24748 helpTextRow.appendChild(helpTextCell); 24749 errorTableBody.appendChild(helpTextRow); 24750 } 24751 if(errorCellPosition === ASPx.Position.Left && this.isVertical(this.position)) { 24752 helpTextRow.appendChild(this.createEmptyCell(true)); 24753 helpTextRow.appendChild(helpTextCell); 24754 if(this.position === ASPx.Position.Top) 24755 errorTableBody.insertBefore(helpTextRow, errorTableBody.childNodes[0]); 24756 else 24757 errorTableBody.appendChild(helpTextRow); 24758 } 24759 if(errorCellPosition === ASPx.Position.Right && this.isVertical(this.position)) { 24760 helpTextRow.appendChild(helpTextCell); 24761 helpTextRow.appendChild(this.createEmptyCell(true)); 24762 if(this.position === ASPx.Position.Top) 24763 errorTableBody.insertBefore(helpTextRow, errorTableBody.childNodes[0]); 24764 else 24765 errorTableBody.appendChild(helpTextRow); 24766 } 24767 if(this.position === ASPx.Position.Left && this.isVertical(errorCellPosition)) { 24768 var helpTextParentRowIndex = errorCellPosition === ASPx.Position.Top ? 1 : 0; 24769 var emptyCellRowIndex = helpTextParentRowIndex === 0 ? 1 : 0; 24770 tableRows[helpTextParentRowIndex].insertBefore(helpTextCell, tableRows[helpTextParentRowIndex].childNodes[0]); 24771 tableRows[emptyCellRowIndex].insertBefore(this.createEmptyCell(true), tableRows[emptyCellRowIndex].childNodes[0]); 24772 } 24773 if(this.position === ASPx.Position.Right && this.isVertical(errorCellPosition)) { 24774 var helpTextParentRowIndex = errorCellPosition === ASPx.Position.Top ? 1 : 0; 24775 var emptyCellRowIndex = helpTextParentRowIndex === 0 ? 1 : 0; 24776 tableRows[helpTextParentRowIndex].appendChild(helpTextCell); 24777 tableRows[emptyCellRowIndex].appendChild(this.createEmptyCell(true)); 24778 } 24779 }, 24780 addHelpTextCellToExternalTableWithCaption: function (captionCell, helpTextCell, errorTableBody, tableRows) { 24781 var captionPosition = this.editor.captionPosition; 24782 var helpTextRow = document.createElement("TR"); 24783 if(captionPosition === ASPx.Position.Left && this.isVertical(this.position)) { 24784 helpTextRow.appendChild(this.createEmptyCell()); 24785 helpTextRow.appendChild(helpTextCell); 24786 if(this.position === ASPx.Position.Top) 24787 errorTableBody.insertBefore(helpTextRow, errorTableBody.childNodes[0]); 24788 else 24789 errorTableBody.appendChild(helpTextRow); 24790 } 24791 if(this.position === ASPx.Position.Left && this.isVertical(captionPosition)) { 24792 var helpTextParentRowIndex = captionPosition === ASPx.Position.Top ? 1 : 0; 24793 var emptyCellParentRowIndex = helpTextParentRowIndex === 0 ? 1 : 0; 24794 tableRows[helpTextParentRowIndex].insertBefore(helpTextCell, tableRows[helpTextParentRowIndex].childNodes[0]); 24795 tableRows[emptyCellParentRowIndex].insertBefore(this.createEmptyCell(), tableRows[emptyCellParentRowIndex].childNodes[0]); 24796 } 24797 if(this.position === ASPx.Position.Right && this.isVertical(captionPosition)) { 24798 var helpTextParentRowIndex = captionPosition === ASPx.Position.Top ? 1 : 0; 24799 var emptyCellParentRowIndex = helpTextParentRowIndex === 0 ? 1 : 0; 24800 tableRows[helpTextParentRowIndex].appendChild(helpTextCell); 24801 tableRows[emptyCellParentRowIndex].appendChild(this.createEmptyCell()); 24802 } 24803 if(captionPosition === ASPx.Position.Right && this.isVertical(this.position)) { 24804 helpTextRow.appendChild(helpTextCell); 24805 helpTextRow.appendChild(this.createEmptyCell()); 24806 if(this.position === ASPx.Position.Top) 24807 errorTableBody.insertBefore(helpTextRow, errorTableBody.childNodes[0]); 24808 else 24809 errorTableBody.appendChild(helpTextRow); 24810 } 24811 if(this.isVertical(captionPosition) && this.isVertical(this.position)) { 24812 helpTextRow.appendChild(helpTextCell); 24813 if(captionPosition === ASPx.Position.Top && this.position === ASPx.Position.Top) 24814 errorTableBody.insertBefore(helpTextRow, captionCell.parentNode.nextSibling); 24815 if(captionPosition === ASPx.Position.Top && this.position === ASPx.Position.Bottom) 24816 errorTableBody.appendChild(helpTextRow); 24817 if(captionPosition === ASPx.Position.Bottom && this.position === ASPx.Position.Top) 24818 errorTableBody.insertBefore(helpTextRow, errorTableBody.childNodes[0]); 24819 if(captionPosition === ASPx.Position.Bottom && this.position === ASPx.Position.Bottom) 24820 errorTableBody.insertBefore(helpTextRow, captionCell.parentNode); 24821 } 24822 if(captionPosition === ASPx.Position.Left && this.position === ASPx.Position.Left) 24823 captionCell.parentNode.insertBefore(helpTextCell, captionCell.nextSibling); 24824 if(captionPosition === ASPx.Position.Right && this.position === ASPx.Position.Right) 24825 captionCell.parentNode.insertBefore(helpTextCell, captionCell); 24826 if(captionPosition === ASPx.Position.Left && this.position === ASPx.Position.Right) 24827 tableRows[0].appendChild(helpTextCell); 24828 if(captionPosition === ASPx.Position.Right && this.position === ASPx.Position.Left) 24829 tableRows[0].insertBefore(helpTextCell, tableRows[0].childNodes[0]); 24830 }, 24831 addHelpTextCellToExternalTableWithEditorOnly: function (helpTextCell, errorTableBody, tableRows) { 24832 if(this.isHorizontal(this.position)) { 24833 if(this.position === ASPx.Position.Left) 24834 tableRows[0].insertBefore(helpTextCell, tableRows[0].childNodes[0]); 24835 else 24836 tableRows[0].appendChild(helpTextCell); 24837 } 24838 else { 24839 var helpTextRow = document.createElement("TR"); 24840 helpTextRow.appendChild(helpTextCell); 24841 if(this.position === ASPx.Position.Top) 24842 errorTableBody.insertBefore(helpTextRow, errorTableBody.childNodes[0]); 24843 else 24844 errorTableBody.appendChild(helpTextRow); 24845 } 24846 }, 24847 addHelpTextCellToExternalTable: function (errorTable, helpTextCell) { 24848 var errorTableBody = ASPx.GetNodeByTagName(errorTable, "TBODY", 0); 24849 var tableRows = this.getRows(errorTableBody); 24850 var captionCell = this.editor.GetCaptionCell();
24851 var errorCell = this.editor.GetErrorCell(); 24852 if(captionCell) { 24853 if(errorCell) 24854 this.addHelpTextCellToExternalTableWithTwoCells(captionCell, errorCell, helpTextCell, errorTableBody, tableRows); 24855 else 24856 this.addHelpTextCellToExternalTableWithCaption(captionCell, helpTextCell, errorTableBody, tableRows); 24857 } 24858 else if(errorCell) 24859 this.addHelpTextCellToExternalTableWithErrorCell(errorCell, helpTextCell, errorTableBody, tableRows); 24860 else 24861 this.addHelpTextCellToExternalTableWithEditorOnly(helpTextCell, errorTableBody, tableRows); 24862 }, 24863 createExternalTable: function () { 24864 var externalTable = document.createElement("TABLE"); 24865 externalTable.id = this.editor.name + ASPx.EditElementSuffix.ExternalTable; 24866 externalTable.cellPadding = 0; 24867 externalTable.cellSpacing = 0; 24868 this.applyExternalTableStyle(externalTable); 24869 var editorWidth = this.editorMainElement.style.width; 24870 if(ASPx.IsPercentageSize(editorWidth)) { 24871 externalTable.style.width = editorWidth; 24872 this.editorMainElement.style.width = "100%"; 24873 this.editor.width = "100%"; 24874 } 24875 var externalTableBody = document.createElement("TBODY"); 24876 var externalTableRow = document.createElement("TR"); 24877 var externalTableCell = document.createElement("TD"); 24878 externalTable.appendChild(externalTableBody); 24879 externalTableBody.appendChild(externalTableRow); 24880 externalTableRow.appendChild(externalTableCell); 24881 this.editorMainElement.parentNode.appendChild(externalTable); 24882 ASPx.ChangeElementContainer(this.editorMainElement, externalTableCell, true); 24883 if(this.editor.accessibilityCompliant) 24884 ASPx.Attr.SetAttribute(externalTable, "role", "presentation"); 24885 return externalTable; 24886 }, 24887 applyExternalTableStyle: function (externalTable) { 24888 var externalTableStyle = this.editor.externalTableStyle; 24889 if(externalTableStyle.length > 0) { 24890 this.applyStyleToElement(externalTable, externalTableStyle); 24891 } 24892 }, 24893 applyStyleToElement: function(element, style) { 24894 element.className = style[0]; 24895 if(style[1]) { 24896 var styleSheet = ASPx.GetCurrentStyleSheet(); 24897 element.className += " " + ASPx.CreateImportantStyleRule(styleSheet, style[1]); 24898 } 24899 }, 24900 createInlineHelpTextElement: function () { 24901 var helpTextElement = document.createElement("TD"); 24902 var externalTable = this.editor.GetExternalTable(); 24903 if(!externalTable) 24904 externalTable = this.createExternalTable(); 24905 this.addHelpTextCellToExternalTable(externalTable, helpTextElement); 24906 return helpTextElement; 24907 }, 24908 createPopupHelpTextElement: function () { 24909 var helpTextElement = document.createElement("DIV"); 24910 ASPx.InsertElementAfter(helpTextElement, this.editor.GetMainElement()); 24911 ASPx.AnimationHelper.setOpacity(helpTextElement, 0); 24912 ASPx.SetElementDisplay(helpTextElement, false); 24913 return helpTextElement; 24914 }, 24915 createHelpTextElement: function () { 24916 return this.displayMode === ASPxClientTextEditHelpTextDisplayMode.Popup ? 24917 this.createPopupHelpTextElement() : this.createInlineHelpTextElement(); 24918 }, 24919 prepareHelpTextElement: function (helpTextStyle, helpText) { 24920 this.helpTextElement.id = this.getHelpTextElementId(); 24921 this.applyStyleToElement(this.helpTextElement, helpTextStyle); 24922 ASPx.SetInnerHtml(this.helpTextElement, "<SPAN>" + helpText + "</SPAN>"); 24923 if(this.displayMode === ASPxClientTextEditHelpTextDisplayMode.Popup) 24924 this.updatePopupHelpTextPosition(); 24925 else { 24926 var isVerticalOrientation = this.position === ASPx.Position.Top || this.position === ASPx.Position.Bottom; 24927 var orientationClassName = isVerticalOrientation ? ASPxClientTextEditHelpTextConsts.VERTICAL_ORIENTATION_CLASS_NAME : 24928 ASPxClientTextEditHelpTextConsts.HORIZONTAL_ORIENTATION_CLASS_NAME; 24929 this.helpTextElement.className += " " + orientationClassName; 24930 this.setInlineHelpTextElementAlign(); 24931 ASPx.SetElementDisplay(this.helpTextElement, this.editor.clientVisible); 24932 } 24933 }, 24934 getHelpTextElementId: function() { 24935 return this.editor.name + ASPx.TEHelpTextElementSuffix; 24936 }, 24937 setInlineHelpTextElementAlign: function() { 24938 var hAlignValue = "", vAlignValue = ""; 24939 switch(this.hAlign) { 24940 case ASPxClientTextEditHelpTextHAlign.Left: hAlignValue = "left"; break; 24941 case ASPxClientTextEditHelpTextHAlign.Right: hAlignValue = "right"; break; 24942 case ASPxClientTextEditHelpTextHAlign.Center: hAlignValue = "center"; break; 24943 } 24944 switch(this.vAlign) { 24945 case ASPxClientTextEditHelpTextVAlign.Top: vAlignValue = "top"; break; 24946 case ASPxClientTextEditHelpTextVAlign.Bottom: vAlignValue = "bottom"; break; 24947 case ASPxClientTextEditHelpTextVAlign.Middle: vAlignValue = "middle"; break; 24948 } 24949 this.helpTextElement.style.textAlign = hAlignValue; 24950 this.helpTextElement.style.verticalAlign = vAlignValue; 24951 }, 24952 getHelpTextMargins: function() { 24953 if(this.margins) 24954 return this.margins; 24955 var result = this.defaultMargins; 24956 if(this.position === ASPx.Position.Top || this.position === ASPx.Position.Bottom) 24957 result.Left = result.Right = 0; 24958 else 24959 result.Top = result.Bottom = 0; 24960 return result; 24961 }, 24962 updatePopupHelpTextPosition: function (editorMainElement) { 24963 var editorWidth = this.editorMainElement.offsetWidth; 24964 var editorHeight = this.editorMainElement.offsetHeight; 24965 var helpTextWidth = this.helpTextElement.offsetWidth; 24966 var helpTextHeight = this.helpTextElement.offsetHeight; 24967 var editorX = ASPx.GetAbsoluteX(this.editorMainElement); 24968 var editorY = ASPx.GetAbsoluteY(this.editorMainElement); 24969 var helpTextX = 0, helpTextY = 0; 24970 var margins = this.getHelpTextMargins(); 24971 if(this.position === ASPx.Position.Top || this.position === ASPx.Position.Bottom) { 24972 if(this.position === ASPx.Position.Top) 24973 helpTextY = editorY - margins.Bottom - helpTextHeight; 24974 else if(this.position === ASPx.Position.Bottom) 24975 helpTextY = editorY + editorHeight + margins.Top; 24976 if(this.hAlign === ASPxClientTextEditHelpTextHAlign.Left) 24977 helpTextX = editorX + margins.Left; 24978 else if(this.hAlign === ASPxClientTextEditHelpTextHAlign.Right) 24979 helpTextX = editorX + editorWidth - helpTextWidth - margins.Right; 24980 else if(this.hAlign === ASPxClientTextEditHelpTextHAlign.Center) { 24981 var editorCenterX = editorX + editorWidth / 2; 24982 var helpTextWidthWithMargins = helpTextWidth + margins.Left + margins.Right; 24983 helpTextX = editorCenterX - helpTextWidthWithMargins / 2 + margins.Left; 24984 } 24985 } else { 24986 if(this.position === ASPx.Position.Left) 24987 helpTextX = editorX - margins.Right - helpTextWidth; 24988 else if(this.position === ASPx.Position.Right) 24989 helpTextX = editorX + editorWidth + margins.Left; 24990 if(this.vAlign === ASPxClientTextEditHelpTextVAlign.Top) 24991 helpTextY = editorY + margins.Top; 24992 else if(this.vAlign === ASPxClientTextEditHelpTextVAlign.Bottom) 24993 helpTextY = editorY + editorHeight - helpTextHeight - margins.Bottom; 24994 else if(this.vAlign === ASPxClientTextEditHelpTextVAlign.Middle) { 24995 var editorCenterY = editorY + editorHeight / 2; 24996 var helpTextHeightWithMargins = helpTextHeight + margins.Top + margins.Bottom; 24997 helpTextY = editorCenterY - helpTextHeightWithMargins / 2 + margins.Top; 24998 } 24999 } 25000 helpTextX = helpTextX < 0 ? 0 : helpTextX; 25001 helpTextY = helpTextY < 0 ? 0 : helpTextY; 25002 ASPx.SetAbsoluteX(this.helpTextElement, helpTextX); 25003 ASPx.SetAbsoluteY(this.helpTextElement, helpTextY); 25004 }, 25005 setHelpTextZIndex: function (hide) { 25006 var newZIndex = 41998 * (hide ? -1 : 1); 25007 if(this.helpTextElement.style.zIndex != newZIndex) 25008 this.helpTextElement.style.zIndex = newZIndex; 25009 }, 25010 hide: function () { 25011 if(this.displayMode === ASPxClientTextEditHelpTextDisplayMode.Inline) { 25012 ASPx.SetElementDisplay(this.helpTextElement, false); 25013 } 25014 else 25015 this.hidePopupHelpText(); 25016 }, 25017 hidePopupHelpText: function() { 25018 var onHidePopupHelpTextComplete = function () { 25019 this.setHelpTextZIndex(true); 25020 ASPx.SetElementDisplay(this.helpTextElement, false); 25021 }.aspxBind(this); 25022 if(this.animationEnabled) 25023 ASPx.AnimationHelper.fadeOut(this.helpTextElement, onHidePopupHelpTextComplete); 25024 else { 25025 ASPx.AnimationHelper.setOpacity(this.helpTextElement, 0); 25026 onHidePopupHelpTextComplete(); 25027 } 25028 }, 25029 show: function () { 25030 if(this.displayMode === ASPxClientTextEditHelpTextDisplayMode.Inline) { 25031 ASPx.SetElementDisplay(this.helpTextElement, true); 25032 } 25033 else 25034 this.showPopupHelpText(); 25035 }, 25036 showPopupHelpText: function () { 25037 ASPx.SetElementDisplay(this.helpTextElement, true); 25038 this.updatePopupHelpTextPosition(); 25039 if(this.animationEnabled) 25040 ASPx.AnimationHelper.fadeIn(this.helpTextElement); 25041 else 25042 ASPx.AnimationHelper.setOpacity(this.helpTextElement, 1); 25043 this.setHelpTextZIndex(false); 25044 } 25045}); 25046var ASPxOutOfRangeWarningManager = ASPx.CreateClass(null, { 25047 constructor: function (editor, minValue, maxValue, defaultMinValue, defaultMaxValue, outOfRangeWarningElementPosition, valueFormatter) { 25048 this.editor = editor; 25049 this.outOfRangeWarningElementPosition = outOfRangeWarningElementPosition; 25050 this.minValue = minValue; 25051 this.maxValue = maxValue; 25052 this.defaultMinValue = defaultMinValue; 25053 this.defaultMaxValue = defaultMaxValue; 25054 this.minMaxValueFormatter = valueFormatter; 25055 this.animationDuration = 150; 25056 this.CreateOutOfRangeWarningElement(); 25057 }, 25058 SetMinValue: function (minValue) { 25059 this.minValue = minValue; 25060 this.UpdateOutOfRangeWarningElementText(); 25061 }, 25062 SetMaxValue: function (maxValue) { 25063 this.maxValue = maxValue; 25064 this.UpdateOutOfRangeWarningElementText(); 25065 }, 25066 CreateOutOfRangeWarningElement: function () { 25067 this.outOfRangeWarningElement = document.createElement("DIV"); 25068 this.outOfRangeWarningElement.id = this.editor.name + "OutOfRWarn"; 25069 ASPx.InsertElementAfter(this.outOfRangeWarningElement, this.editor.GetOutOfRangeWarningElementPrevSibling()); 25070 ASPx.AnimationHelper.setOpacity(this.outOfRangeWarningElement, 0); 25071 this.outOfRangeWarningElement.className = this.editor.outOfRangeWarningClassName; 25072 this.UpdateOutOfRangeWarningElementText(); 25073 }, 25074 IsValueInRange: function (value) { 25075 return (!this.IsMinValueExists() || value >= this.minValue)
25076 && (!this.IsMaxValueExists() || value <= this.maxValue); 25077 }, 25078 IsMinValueExists: function() { 25079 return ASPx.IsExists(this.minValue) && !isNaN(this.minValue) && this.minValue !== this.defaultMinValue; 25080 }, 25081 IsMaxValueExists: function () { 25082 return ASPx.IsExists(this.maxValue) && !isNaN(this.maxValue) && this.maxValue !== this.defaultMaxValue; 25083 }, 25084 GetFormattedTextByValue: function(value) { 25085 if (this.minMaxValueFormatter) 25086 return this.minMaxValueFormatter.Format(value); 25087 return value; 25088 }, 25089 GetWarningText: function() { 25090 var textTemplate = arguments[0]; 25091 var valueTexts = []; 25092 for (var i = 1; i < arguments.length; i++) { 25093 var valueText = this.GetFormattedTextByValue(arguments[i]); 25094 valueTexts.push(valueText); 25095 } 25096 return ASPx.Formatter.Format(textTemplate, valueTexts); 25097 }, 25098 UpdateOutOfRangeWarningElementText: function () { 25099 var text = ""; 25100 if (this.IsMinValueExists() && this.IsMaxValueExists()) 25101 text = this.GetWarningText(this.editor.outOfRangeWarningMessages[0], this.minValue, this.maxValue); 25102 if (this.IsMinValueExists() && !this.IsMaxValueExists()) 25103 text = this.GetWarningText(this.editor.outOfRangeWarningMessages[1], this.minValue); 25104 if (!this.IsMinValueExists() && this.IsMaxValueExists()) 25105 text = this.GetWarningText(this.editor.outOfRangeWarningMessages[2], this.maxValue); 25106 ASPx.SetInnerHtml(this.outOfRangeWarningElement, "<LABEL>" + text + "</LABEL>"); 25107 }, 25108 UpdateOutOfRangeWarningElementVisibility: function (currentValue) { 25109 var isValidValue = currentValue == null || this.IsValueInRange(currentValue); 25110 if (!isValidValue && !this.outOfRangeWarningElementShown) 25111 this.ShowOutOfRangeWarningElement(); 25112 if (isValidValue && this.outOfRangeWarningElementShown) 25113 this.HideOutOfRangeWarningElement(); 25114 }, 25115 GetOutOfRangeWarningElementCoordinates: function() { 25116 var editorMainElement = this.editor.GetMainElement(); 25117 var editorWidth = editorMainElement.offsetWidth; 25118 var editorHeight = editorMainElement.offsetHeight; 25119 var editorX = ASPx.GetAbsoluteX(editorMainElement); 25120 var editorY = ASPx.GetAbsoluteY(editorMainElement); 25121 var outOfRangeWarningElementX = this.outOfRangeWarningElementPosition === ASPx.Position.Right ? editorX + editorWidth : editorX; 25122 var outOfRangeWarningElementY = this.outOfRangeWarningElementPosition === ASPx.Position.Right ? editorY : editorY + editorHeight; 25123 outOfRangeWarningElementX = outOfRangeWarningElementX < 0 ? 0 : outOfRangeWarningElementX; 25124 outOfRangeWarningElementY = outOfRangeWarningElementY < 0 ? 0 : outOfRangeWarningElementY; 25125 return { 25126 x: outOfRangeWarningElementX, 25127 y: outOfRangeWarningElementY 25128 }; 25129 }, 25130 ShowOutOfRangeWarningElement: function () { 25131 this.outOfRangeWarningElement.style.display = "inline"; 25132 var outOfRangeWarningElementCoordinates = this.GetOutOfRangeWarningElementCoordinates(); 25133 ASPx.SetAbsoluteX(this.outOfRangeWarningElement, outOfRangeWarningElementCoordinates.x); 25134 ASPx.SetAbsoluteY(this.outOfRangeWarningElement, outOfRangeWarningElementCoordinates.y); 25135 ASPx.AnimationHelper.fadeIn(this.outOfRangeWarningElement, null, this.animationDuration); 25136 this.ScrollToWarningElementIfRequired(outOfRangeWarningElementCoordinates); 25137 this.outOfRangeWarningElementShown = true; 25138 }, 25139 HideOutOfRangeWarningElement: function () { 25140 ASPx.AnimationHelper.fadeOut(this.outOfRangeWarningElement, function () { 25141 ASPx.SetElementDisplay(this.outOfRangeWarningElement, false); 25142 }.aspxBind(this), this.animationDuration); 25143 this.outOfRangeWarningElementShown = false; 25144 }, 25145 ScrollToWarningElementIfRequired: function (outOfRangeWarningElementCoordinates) { 25146 if(this.outOfRangeWarningElementPosition === ASPx.Position.Right) { 25147 var warnElementRightPos = outOfRangeWarningElementCoordinates.x 25148 + ASPx.PxToInt(ASPx.GetCurrentStyle(this.outOfRangeWarningElement).marginLeft) 25149 + this.outOfRangeWarningElement.offsetWidth; 25150 if(warnElementRightPos > ASPx.GetDocumentClientWidth() + ASPx.GetDocumentScrollLeft()) 25151 ASPx.SetDocumentScrollLeft(warnElementRightPos - ASPx.GetDocumentClientWidth()); 25152 } 25153 if(this.outOfRangeWarningElementPosition === ASPx.Position.Bottom) { 25154 var warnElementBottomPos = outOfRangeWarningElementCoordinates.y 25155 + ASPx.PxToInt(ASPx.GetCurrentStyle(this.outOfRangeWarningElement).marginTop) 25156 + this.outOfRangeWarningElement.offsetHeight; 25157 if(warnElementBottomPos > ASPx.GetDocumentClientHeight() + ASPx.GetDocumentScrollTop()) 25158 ASPx.SetDocumentScrollTop(warnElementBottomPos - ASPx.GetDocumentClientHeight()); 25159 } 25160 } 25161}); 25162ASPx.MMMouseOut = function(name, evt) { 25163 var edit = ASPx.GetControlCollection().Get(name);
25164 if(edit != null) edit.OnMouseOut(evt); 25165}; 25166ASPx.MMMouseOver = function(name, evt) { 25167 var edit = ASPx.GetControlCollection().Get(name); 25168 if(edit != null) edit.OnMouseOver(evt); 25169}; 25170ASPx.MaskHintTimerProc = function() { 25171 var focusedEditor = ASPx.GetFocusedEditor(); 25172 if(focusedEditor != null && ASPx.IsFunction(focusedEditor.MaskHintTimerProc)) 25173 focusedEditor.MaskHintTimerProc(); 25174}; 25175ASPx.ETextChanged = function(name) { 25176 var edit = ASPx.GetControlCollection().Get(name); 25177 if(edit != null) edit.OnTextChanged(); 25178}; 25179ASPx.BEClick = function(name,number){ 25180 var edit = ASPx.GetControlCollection().Get(name); 25181 if(edit != null) edit.OnButtonClick(number); 25182}; 25183ASPx.BEClear = function(name, evt) { 25184 var edit = ASPx.GetControlCollection().Get(name); 25185 if(edit && (evt.button === 0 || ASPx.Browser.TouchUI)) 25186 edit.onClearButtonClick(); 25187}; 25188ASPx.SetFocusToTextEditWithDelay = function(name) { 25189 window.setTimeout(function() { 25190 var edit = ASPx.GetControlCollection().Get(name); 25191 if(!edit) 25192 return; 25193 if(ASPx.Browser.IE) 25194 edit.SetCaretPosition(0); 25195 else 25196 edit.SetFocus(); 25197 }, 500); 25198}; 25199window.ASPxClientTextEdit = ASPxClientTextEdit; 25200window.ASPxClientTextBoxBase = ASPxClientTextBoxBase; 25201window.ASPxClientTextBox = ASPxClientTextBox; 25202window.ASPxClientMemo = ASPxClientMemo; 25203window.ASPxClientButtonEditBase = ASPxClientButtonEditBase; 25204window.ASPxClientButtonEdit = ASPxClientButtonEdit; 25205window.ASPxClientButtonEditClickEventArgs = ASPxClientButtonEditClickEventArgs; 25206})(); 25207 25208(function() { 25209var ASPxClientButton = ASPx.CreateClass(ASPxClientControl, { 25210 constructor: function(name) { 25211 this.constructor.prototype.constructor.call(this, name); 25212 this.isASPxClientButton = true; 25213 this.allowFocus = true; 25214 this.autoPostBackFunction = null; 25215 this.causesValidation = true; 25216 this.checked = false; 25217 this.clickLocked = false; 25218 this.groupName = ""; 25219 this.focusElementSelected = false; 25220 this.pressed = false; 25221 this.useSubmitBehavior = true; 25222 this.validationGroup = ""; 25223 this.validationContainerID = null; 25224 this.validateInvisibleEditors = false; 25225 this.originalWidth = null; 25226 this.originalHeight = null; 25227 this.needUpdateBounds = true; 25228 this.isTextEmpty = false; 25229 this.CheckedChanged = new ASPxClientEvent(); 25230 this.GotFocus = new ASPxClientEvent(); 25231 this.LostFocus = new ASPxClientEvent(); 25232 this.Click = new ASPxClientEvent(); 25233 }, 25234 InlineInitialize: function() { 25235 var mainElement = this.GetMainElement(); 25236 this.originalWidth = mainElement.style.width; 25237 this.originalHeight = mainElement.style.height; 25238 ASPxClientControl.prototype.InlineInitialize.call(this); 25239 this.InitializeElementIDs(); 25240 this.InitializeEvents(); 25241 this.InitializeEnabled(); 25242 this.InitializeChecked(); 25243 if(this.IsLink()) 25244 this.InitializeLink(); 25245 this.PreventButtonImageDragging(); 25246 this.EnsureBoundsAdjusted(); 25247 }, 25248 InitializeElementIDs: function(){ 25249 var mainElement = this.GetMainElement(); 25250 var contentElement = ASPx.GetNodeByTagName(mainElement, "DIV", 0); 25251 if(contentElement) contentElement.id = this.name + "_CD"; 25252 var imageElement = ASPx.GetNodeByTagName(mainElement, "IMG", 0); 25253 if(imageElement) imageElement.id = this.name + "Img"; 25254 }, 25255 InitializeEnabled: function(){ 25256 this.SetEnabledInternal(this.clientEnabled, true); 25257 }, 25258 InitializeChecked: function(){ 25259 this.SetCheckedInternal(this.checked, true); 25260 }, 25261 InitializeLink: function(){ 25262 var mainElement = this.GetMainElement(); 25263 if(this.enabled) 25264 mainElement.href = "javascript:;"; 25265 if(!this.allowFocus) 25266 mainElement.style.outline = 0; 25267 if(!this.GetTextContainer()) 25268 mainElement.style.fontSize = "0pt"; 25269 }, 25270 InitializeEvents: function(){ 25271 if(!this.isNative && !this.IsLink()) { 25272 var element = this.GetInternalButton(); 25273 if(element) 25274 element.onfocus = null; 25275 var textControl = this.GetTextControl(); 25276 if(textControl) { 25277 if(ASPx.Browser.IE) 25278 ASPx.Evt.AttachEventToElement(textControl, "mouseup", ASPx.Selection.Clear); 25279 ASPx.Evt.PreventElementDragAndSelect(textControl, false); 25280 } 25281 } 25282 this.onClick = function(evt) { 25283 var processOnServer = ASPx.BClick(this.name, evt); 25284 if(!processOnServer) 25285 ASPx.Evt.PreventEvent(evt); 25286 return processOnServer; 25287 }.aspxBind(this); 25288 this.onImageMoseDown = function() { var el = ASPx.GetFocusedElement(); if(el) el.blur(); }; 25289 this.onGotFocus = function() { this.OnFocus(); }.aspxBind(this); 25290 this.onLostFocus = function() { this.OnLostFocus(); }.aspxBind(this); 25291 this.onKeyUp = function(evt) { this.OnKeyUp(evt); }.aspxBind(this); 25292 this.onKeyDown = function(evt) { this.OnKeyDown(evt); }.aspxBind(this); 25293 if(!this.isNative && !this.IsLink()) 25294 this.InitializeNativeHandlers(); 25295 }, 25296 InitializeNativeHandlers: function() { 25297 this.AttachNativeHandlerToMainElement("focus", "SetFocus"); 25298 this.AttachNativeHandlerToMainElement("click", "DoClick"); 25299 }, 25300 EnsureBoundsAdjusted: function() { 25301 var mainElement = this.GetMainElement(); 25302 this.needUpdateBounds = ASPx.GetCurrentStyle(mainElement).display === "block"; 25303 if(this.needUpdateBounds) 25304 mainElement.className = mainElement.className.replace("dxbTSys", ""); 25305 }, 25306 AdjustControlCore: function () { 25307 if(this.isNative || this.IsLink()) return; 25308 var buttonImage = this.GetButtonImage(); 25309 if(buttonImage && buttonImage.offsetHeight === 0 && buttonImage.offsetWidth === 0) 25310 buttonImage.onload = function() { this.UpdateSize(); }.aspxBind(this); 25311 else 25312 this.UpdateSize(); 25313 this.UpdateVerticalAlign(); 25314 }, 25315 UpdateSize: function() { 25316 if(this.needUpdateBounds) { 25317 this.UpdateWidth(); 25318 this.UpdateHeight(); 25319 } else 25320 this.CorrectWrappedText(this.GetContentDiv, "Text", true); 25321 }, 25322 UpdateVerticalAlign: function() { 25323 var contentElement = this.GetContentDiv(); 25324 var verticalAlign = this.GetMainElement().style.verticalAlign; 25325 if(ASPx.IsExistsElement(contentElement) && verticalAlign) 25326 contentElement.style.verticalAlign = verticalAlign; 25327 }, 25328 UpdateHeight: function(){ 25329 if(this.isNative || this.IsLink() || this.originalHeight === null || ASPx.IsPercentageSize(this.originalHeight)) return; 25330 var height; 25331 var mainElement = this.GetMainElement(); 25332 var contentDiv = this.GetContentDiv(); 25333 var borderAndPadding = ASPx.GetTopBottomBordersAndPaddingsSummaryValue(mainElement); 25334 var contentHasExcessiveHeight = contentDiv.offsetHeight > mainElement.offsetHeight - borderAndPadding;
25335 var needSetAutoHeight = !this.originalHeight || (ASPx.Browser.Safari && contentHasExcessiveHeight); 25336 if(needSetAutoHeight) { 25337 mainElement.style.height = ""; 25338 height = mainElement.offsetHeight - borderAndPadding; 25339 } 25340 else 25341 height = (ASPx.PxToInt(this.originalHeight) - borderAndPadding); 25342 if(height){ 25343 mainElement.style.height = height + "px"; 25344 if(contentDiv && contentDiv.offsetHeight > 0){ 25345 var contentDivCurrentStyle = ASPx.GetCurrentStyle(contentDiv); 25346 var paddingTop = parseInt(contentDivCurrentStyle.paddingTop) || 0; 25347 var paddingBottom = parseInt(contentDivCurrentStyle.paddingBottom) || 0; 25348 var clientHeightDiff = height - contentDiv.offsetHeight; 25349 var verticalAlign = ASPx.GetCurrentStyle(mainElement).verticalAlign; 25350 if(verticalAlign == "top") 25351 paddingBottom = paddingBottom + clientHeightDiff; 25352 else if(verticalAlign == "bottom") 25353 paddingTop = paddingTop + clientHeightDiff; 25354 else { 25355 var halfClientHeightDiff = Math.floor(clientHeightDiff / 2); 25356 paddingTop = paddingTop + halfClientHeightDiff; 25357 paddingBottom = paddingBottom + (clientHeightDiff - halfClientHeightDiff); 25358 } 25359 contentDiv.style.paddingTop = (paddingTop > 0 ? paddingTop : 0) + "px"; 25360 contentDiv.style.paddingBottom = (paddingBottom > 0 ? paddingBottom : 0) + "px"; 25361 } 25362 } 25363 }, 25364 UpdateWidth: function(){ 25365 if(this.isNative || this.IsLink() || this.originalWidth === null) return; 25366 if(!ASPx.IsPercentageSize(this.originalWidth)) { 25367 var mainElement = this.GetMainElement(); 25368 var borderAndPadding = ASPx.GetLeftRightBordersAndPaddingsSummaryValue(mainElement); 25369 if(this.originalWidth && ASPx.IsTextWrapped(this.GetTextContainer())) 25370 mainElement.style.width = (ASPx.PxToInt(this.originalWidth) - borderAndPadding) + "px"; 25371 else 25372 mainElement.style.width = "auto"; 25373 var width = mainElement.offsetWidth - borderAndPadding; 25374 if(this.originalWidth && width < ASPx.PxToInt(this.originalWidth) - borderAndPadding) 25375 width = ASPx.PxToInt(this.originalWidth) - borderAndPadding; 25376 if(width) 25377 mainElement.style.width = (width > 0 ? width : 0) + "px"; 25378 } 25379 this.CorrectWrappedText(this.GetContentDiv, "Text", true); 25380 }, 25381 GetAdjustedSizes: function() { 25382 var sizes = ASPxClientControl.prototype.GetAdjustedSizes.call(this); 25383 var image = this.GetButtonImage(); 25384 if(image) { 25385 sizes.imageWidth = image.offsetWidth; 25386 sizes.imageHeight = image.offsetHeight; 25387 } 25388 return sizes; 25389 }, 25390 PreventButtonImageDragging: function() { 25391 ASPx.Evt.PreventImageDragging(this.GetButtonImage()); 25392 }, 25393 AttachNativeHandlerToMainElement: function(handlerName, correspondingMethodName) { 25394 var mainElement = this.GetMainElement(); 25395 if(!ASPx.IsExistsElement(mainElement)) 25396 return; 25397 mainElement[handlerName] = function() { _aspxBCallButtonMethod(this.name, correspondingMethodName); }.aspxBind(this); 25398 }, 25399 GetContentDiv: function(){ 25400 return this.GetChildElement("CD"); 25401 }, 25402 GetButtonImage: function(){ 25403 return ASPx.CacheHelper.GetCachedElement(this, "buttonImage", 25404 function() { 25405 return ASPx.GetNodeByTagName(this.GetMainElement(), "IMG", 0); 25406 }); 25407 }, 25408 GetInternalButton: function() { 25409 return ASPx.CacheHelper.GetCachedElement(this, "internalButton", 25410 function() { 25411 return this.isNative || this.IsLink() ? this.GetMainElement() : ASPx.GetNodeByTagName(this.GetMainElement(), "INPUT", 0); 25412 }); 25413 }, 25414 GetTextContainer: function() { 25415 return ASPx.CacheHelper.GetCachedElement(this, "textContainer", 25416 function() { 25417 if(this.isNative) 25418 return this.GetMainElement(); 25419 else{ 25420 var textElement = this.IsLink() ? this.GetMainElement() : this.GetContentDiv(); 25421 return this.accessibilityCompliant ? ASPx.GetElementById(this.name + "_BTC") : ASPx.GetNodeByTagName(textElement, "SPAN", 0); 25422 } 25423 }); 25424 }, 25425 GetTextControl: function(){ 25426 return ASPx.CacheHelper.GetCachedElement(this, "textControl", 25427 function() { 25428 var element = ASPx.GetParentByTagName(this.GetContentDiv(), "DIV");
25429 if(!ASPx.IsExistsElement(element) || (element.id == this.name)) 25430 element = this.GetContentDiv(); 25431 return element; 25432 }); 25433 }, 25434 IsLink: function(){ 25435 if (this.GetMainElement()) 25436 return this.GetMainElement().tagName === "A"; 25437 return false; 25438 }, 25439 IsHovered: function(){ 25440 var hoverElement = this.GetMainElement(); 25441 return ASPx.GetStateController().currentHoverItemName == hoverElement.id; 25442 }, 25443 SetEnabledInternal: function(enabled, initialization) { 25444 if(!this.enabled) 25445 return; 25446 if(!initialization || !enabled) 25447 this.ChangeEnabledStateItems(enabled); 25448 this.ChangeEnabledAttributes(enabled); 25449 }, 25450 ChangeEnabledAttributes: function(enabled) { 25451 var element = this.GetInternalButton(); 25452 if(element) { 25453 if(this.IsLink()){ 25454 var method = ASPx.Attr.ChangeAttributesMethod(enabled); 25455 var link = this.GetMainElement(); 25456 method(link, "href"); 25457 if(this.accessibilityCompliant) 25458 ASPx.Attr.SetOrRemoveAttribute(link, ASPx.Attr.GetTabIndexAttributeName(), enabled ? null : "0"); 25459 } else { 25460 if(this.accessibilityCompliant) 25461 ASPx.Attr.Aria.SetOrRemoveDisabled(element, !enabled); 25462 else 25463 element.disabled = !enabled; 25464 } 25465 } 25466 this.ChangeEnabledEventsAttributes(ASPx.Attr.ChangeEventsMethod(enabled)); 25467 var isFocusable = enabled || this.accessibilityCompliant; 25468 this.ChangeEnabledFocusEvents(ASPx.Attr.ChangeEventsMethod(isFocusable)); 25469 }, 25470 ChangeEnabledEventsAttributes: function(method) { 25471 var element = this.GetMainElement(); 25472 method(element, "click", this.onClick); 25473 if(this.allowFocus){ 25474 if(!this.isNative && !this.IsLink()) { 25475 element = this.GetInternalButton(); 25476 if(element) { 25477 method(element, "keyup", this.onKeyUp); 25478 method(element, "blur", this.onKeyUp); 25479 method(element, "keydown", this.onKeyDown); 25480 } 25481 } 25482 if(ASPx.Browser.Firefox){ 25483 var image = this.GetButtonImage(); 25484 if(image) 25485 method(image, "mousedown", this.onImageMoseDown); 25486 } 25487 } 25488 }, 25489 ChangeEnabledFocusEvents: function(method) { 25490 if(!this.allowFocus) 25491 return; 25492 var element = !this.isNative && !this.IsLink() ? this.GetInternalButton() : this.GetMainElement(); 25493 if(element) { 25494 method(element, "focus", this.onGotFocus); 25495 method(element, "blur", this.onLostFocus); 25496 } 25497 }, 25498 ChangeEnabledStateItems: function(enabled){ 25499 if(this.isNative) return; 25500 ASPx.GetStateController().SetElementEnabled(this.GetMainElement(), enabled); 25501 this.UpdateFocusedStyle(); 25502 }, 25503 RequiredPreventDoublePostback: function(){ 25504 return ASPx.Browser.Firefox && !this.isNative; 25505 }, 25506 OnFocus: function() { 25507 if(!this.allowFocus) 25508 return false; 25509 this.focused = true; 25510 if(this.isInitialized) 25511 this.RaiseFocus(); 25512 this.UpdateFocusedStyle(); 25513 }, 25514 OnLostFocus: function() { 25515 if(!this.allowFocus) 25516 return false; 25517 this.focused = false; 25518 if(this.isInitialized) 25519 this.RaiseLostFocus(); 25520 this.UpdateFocusedStyle(); 25521 }, 25522 CauseValidation: function() { 25523 if(this.causesValidation && ASPx.Ident.scripts.ASPxClientEdit) 25524 return this.validationContainerID != null ? 25525 ASPxClientEdit.ValidateEditorsInContainerById(this.validationContainerID, this.validationGroup, this.validateInvisibleEditors) : 25526 ASPxClientEdit.ValidateGroup(this.validationGroup, this.validateInvisibleEditors); 25527 else 25528 return true; 25529 }, 25530 OnClick: function(evt) { 25531 if(this.clickLocked) return true; 25532 if(this.checked && this.groupName != "" && this.GetCheckedGroupList().length > 1) return; 25533 this.SetFocus(); 25534 var isValid = this.CauseValidation(); 25535 var processOnServer = this.autoPostBack; 25536 if(this.groupName != "") { 25537 if(this.GetCheckedGroupList().length == 1) 25538 this.SetCheckedInternal(!this.checked, false); 25539 else { 25540 this.SetCheckedInternal(true, false); 25541 this.ClearButtonGroupChecked(true); 25542 } 25543 processOnServer = this.RaiseCheckedChanged(); 25544 if(processOnServer && isValid) 25545 this.SendPostBack("CheckedChanged"); 25546 } 25547 var params = this.RaiseClick(); 25548 if(evt && params.cancelEventAndBubble) 25549 ASPx.Evt.PreventEventAndBubble(evt); 25550 if(params.processOnServer && isValid) 25551 return this.ProcessClick(); 25552 return false; 25553 }, 25554 ProcessClick: function() { 25555 var requiredPreventDoublePostback = this.RequiredPreventDoublePostback(); 25556 var postponePostback = ASPx.Browser.AndroidMobilePlatform; 25557 if(requiredPreventDoublePostback || postponePostback) 25558 window.setTimeout(function() { _aspxBCallButtonMethod(this.name, "SendPostBack", "Click"); }.aspxBind(this), 0); 25559 else 25560 this.SendPostBack("Click"); 25561 return !requiredPreventDoublePostback; 25562 }, 25563 OnKeyUp: function(evt) { 25564 if(!this.pressed) 25565 return; 25566 this.pressed = false; 25567 ASPx.GetStateController().OnKeyUpOnElement(evt); 25568 }, 25569 OnKeyDown: function(evt) { 25570 if(evt.keyCode == ASPx.Key.Enter || evt.keyCode == ASPx.Key.Space) 25571 this.SetPressed(); 25572 }, 25573 GetCheckedGroupList: function(){ 25574 var result = [ ]; 25575 ASPx.GetControlCollection().ForEachControl(function(control) { 25576 if(ASPx.Ident.IsASPxClientButton(control) && (control.groupName == this.groupName) && !control.IsDOMDisposed()) 25577 result.push(control); 25578 }, this); 25579 return result; 25580 }, 25581 ClearButtonGroupChecked: function(raiseCheckedChanged){ 25582 var list = this.GetCheckedGroupList(); 25583 for(var i = 0; i < list.length; i ++){ 25584 if(list[i] != this && list[i].checked) { 25585 list[i].SetCheckedInternal(false, false); 25586 if(raiseCheckedChanged) 25587 list[i].RaiseCheckedChanged(); 25588 } 25589 } 25590 }, 25591 ApplyCheckedStyle: function(){ 25592 var stateController = ASPx.GetStateController(); 25593 if(this.IsHovered()) 25594 stateController.SetCurrentHoverElement(null); 25595 stateController.SelectElementBySrcElement(this.GetMainElement()); 25596 }, 25597 ApplyUncheckedStyle: function(){ 25598 var stateController = ASPx.GetStateController(); 25599 if(this.IsHovered()) 25600 stateController.SetCurrentHoverElement(null); 25601 stateController.DeselectElementBySrcElement(this.GetMainElement()); 25602 }, 25603 SetCheckedInternal: function(checked, initialization){ 25604 if(initialization && checked || (this.checked != checked)){ 25605 this.checked = checked; 25606 if(checked)
25607 this.ApplyCheckedStyle(); 25608 else 25609 this.ApplyUncheckedStyle(); 25610 } 25611 }, 25612 UpdateStateObject: function(){ 25613 if(this.groupName != "") 25614 this.UpdateStateObjectWithObject({ checked: this.checked }); 25615 }, 25616 GetStateHiddenFieldName: function() { 25617 return this.uniqueID + "$State"; 25618 }, 25619 ApplyPressedStyle: function(){ 25620 ASPx.GetStateController().OnMouseDownOnElement(this.GetMainElement()); 25621 }, 25622 ApplyUnpressedStyle: function(){ 25623 ASPx.GetStateController().OnMouseUpOnElement(this.GetMainElement()); 25624 }, 25625 SetPressed: function(){ 25626 this.pressed = true; 25627 this.ApplyPressedStyle(); 25628 }, 25629 SetUnpressed: function(){ 25630 this.pressed = false; 25631 this.ApplyUnpressedStyle(); 25632 }, 25633 SetFocus: function(){ 25634 if(!this.allowFocus || this.focused) 25635 return; 25636 var element = this.GetInternalButton(); 25637 if(element) { 25638 var hiddenInternalButtonRequiresVisibilityToGetFocused = ASPx.Browser.WebKitFamily && !this.isNative && !this.IsLink(); 25639 if(hiddenInternalButtonRequiresVisibilityToGetFocused) 25640 ASPxClientButton.MakeHiddenElementFocusable(element); 25641 if(ASPx.IsFocusable(element) && ASPx.GetActiveElement() != element) 25642 element.focus(); 25643 if(hiddenInternalButtonRequiresVisibilityToGetFocused) 25644 ASPxClientButton.RestoreHiddenElementAppearance(element); 25645 } 25646 }, 25647 ApplyFocusedStyle: function(){ 25648 if(this.focusElementSelected) return; 25649 if(typeof(ASPx.GetStateController) != "undefined") 25650 ASPx.GetStateController().SelectElementBySrcElement(this.GetContentDiv()); 25651 this.focusElementSelected = true; 25652 }, 25653 ApplyUnfocusedStyle: function(){ 25654 if(!this.focusElementSelected) return; 25655 if(typeof(ASPx.GetStateController) != "undefined") 25656 ASPx.GetStateController().DeselectElementBySrcElement(this.GetContentDiv()); 25657 this.focusElementSelected = false; 25658 }, 25659 UpdateFocusedStyle: function(){ 25660 if(this.isNative || this.IsLink()) return; 25661 var isFocusable = this.enabled && this.allowFocus && this.focused && (this.clientEnabled || this.accessibilityCompliant); 25662 if(isFocusable) 25663 this.ApplyFocusedStyle(); 25664 else 25665 this.ApplyUnfocusedStyle(); 25666 }, 25667 SendPostBack: function(postBackArg){ 25668 if(!this.enabled || !this.clientEnabled) 25669 return; 25670 var arg = postBackArg || ""; 25671 if(this.autoPostBackFunction) 25672 this.autoPostBackFunction(arg); 25673 else if(!this.useSubmitBehavior || this.IsLink()) 25674 ASPxClientControl.prototype.SendPostBack.call(this, arg); 25675 if(this.useSubmitBehavior && !this.isNative) 25676 this.ClickInternalButton(); 25677 }, 25678 ClickInternalButton: function(){ 25679 var element = this.GetInternalButton(); 25680 if(element) { 25681 this.clickLocked = true; 25682 if(ASPx.Browser.NetscapeFamily) 25683 this.CreateUniqueIDCarrier(); 25684 var postHandler = ASPx.GetPostHandler(); 25685 postHandler.SetLastSubmitElementName(element.name); 25686 ASPx.Evt.DoElementClick(element); 25687 postHandler.SetLastSubmitElementName(null); 25688 if(ASPx.Browser.NetscapeFamily) 25689 this.RemoveUniqueIDCarrier(); 25690 this.clickLocked = false; 25691 } 25692 }, 25693 CreateUniqueIDCarrier: function() { 25694 var name = this.uniqueID; 25695 var id = this.GetUniqueIDCarrierID(); 25696 var field = ASPx.CreateHiddenField(name, id);
25697 var form = this.GetParentForm(); 25698 if(form) form.appendChild(field); 25699 }, 25700 RemoveUniqueIDCarrier: function() { 25701 var field = document.getElementById(this.GetUniqueIDCarrierID()); 25702 if(field) 25703 field.parentNode.removeChild(field); 25704 }, 25705 GetUniqueIDCarrierID: function() { 25706 return this.uniqueID + "_UIDC"; 25707 }, 25708 DoClick: function(){ 25709 if(!this.enabled || !this.clientEnabled) 25710 return; 25711 var button = (this.isNative || this.IsLink()) ? this.GetMainElement() : this.GetInternalButton(); 25712 if(button) 25713 ASPx.Evt.DoElementClick(button); 25714 else 25715 this.OnClick(); 25716 }, 25717 GetChecked: function(){ 25718 return this.checked; 25719 }, 25720 SetChecked: function(checked){ 25721 this.SetCheckedInternal(checked, false); 25722 this.ClearButtonGroupChecked(false); 25723 }, 25724 GetText: function(){ 25725 if(!this.isTextEmpty) 25726 return this.isNative ? this.GetTextContainer().value : this.GetTextContainer().innerHTML; 25727 return ""; 25728 }, 25729 SetText: function(text){ 25730 this.isTextEmpty = (text == null || text == ""); 25731 var textContainer = this.GetTextContainer(); 25732 if(textContainer){ 25733 if(this.isNative) 25734 textContainer.value = (text != null) ? text : ""; 25735 else { 25736 var value = this.isTextEmpty ? " " : text; 25737 textContainer.innerHTML = value; 25738 var element = this.GetInternalButton(); 25739 if(element) 25740 element.value = value; 25741 if(this.clientVisible && ASPx.Browser.IE && ASPx.Browser.Version >= 9) 25742 ASPx.SetElementDisplay(this.GetMainElement(), true); 25743 } 25744 this.UpdateSize(); 25745 } 25746 }, 25747 GetImageUrl: function(){ 25748 var img = this.GetButtonImage(); 25749 return img ? img.src : ""; 25750 }, 25751 SetImageUrl: function(url){ 25752 var img = this.GetButtonImage(); 25753 if(img) { 25754 img.src = url; 25755 this.UpdateSize(); 25756 } 25757 }, 25758 SetEnabled: function(enabled){ 25759 if(this.clientEnabled != enabled) { 25760 if(!enabled && this.focused) 25761 this.OnLostFocus(); 25762 this.clientEnabled = enabled; 25763 this.SetEnabledInternal(enabled, false); 25764 } 25765 }, 25766 GetEnabled: function(){ 25767 return this.enabled && this.clientEnabled; 25768 }, 25769 Focus: function(){ 25770 this.SetFocus(); 25771 }, 25772 RaiseCheckedChanged: function(){ 25773 var processOnServer = this.autoPostBack || this.IsServerEventAssigned("CheckedChanged"); 25774 if(!this.CheckedChanged.IsEmpty()){ 25775 var args = new ASPxClientProcessingModeEventArgs(processOnServer); 25776 this.CheckedChanged.FireEvent(this, args); 25777 processOnServer = args.processOnServer; 25778 } 25779 return processOnServer; 25780 }, 25781 RaiseFocus: function(){ 25782 if(!this.GotFocus.IsEmpty()){ 25783 var args = new ASPxClientEventArgs(); 25784 this.GotFocus.FireEvent(this, args); 25785 } 25786 }, 25787 RaiseLostFocus: function(){ 25788 if(!this.LostFocus.IsEmpty()){ 25789 var args = new ASPxClientEventArgs(); 25790 this.LostFocus.FireEvent(this, args); 25791 } 25792 }, 25793 RaiseClick: function() { 25794 var processOnServer = this.autoPostBack || this.IsServerEventAssigned("Click"); 25795 var cancelEventAndBubble = false; 25796 if(!this.Click.IsEmpty()) { 25797 var args = new ASPxClientButtonClickEventArgs(processOnServer, cancelEventAndBubble); 25798 this.Click.FireEvent(this, args); 25799 cancelEventAndBubble = args.cancelEventAndBubble; 25800 processOnServer = args.processOnServer; 25801 } 25802 return { 25803 processOnServer: processOnServer, 25804 cancelEventAndBubble: cancelEventAndBubble 25805 }; 25806 } 25807}); 25808ASPxClientButton.Cast = ASPxClientControl.Cast; 25809var ASPxClientButtonClickEventArgs = ASPx.CreateClass(ASPxClientProcessingModeEventArgs, { 25810 constructor: function(processOnServer, cancelEventAndBubble) { 25811 this.constructor.prototype.constructor.call(this, processOnServer); 25812 this.cancelEventAndBubble = cancelEventAndBubble; 25813 } 25814}); 25815ASPxClientButton.MakeHiddenElementFocusable = function(element) { 25816 element.__dxHiddenElementState = { 25817 parentDisplay: element.parentNode.style.display, 25818 height: element.style.height, 25819 width: element.style.width 25820 }; 25821 element.parentNode.style.display = "block"; 25822 element.style.height = "1px"; 25823 element.style.width = "1px"; 25824}; 25825ASPxClientButton.RestoreHiddenElementAppearance = function(element) { 25826 var state = element.__dxHiddenElementState; 25827 element.parentNode.style.display = state.parentDisplay; 25828 element.style.height = state.height; 25829 element.style.width = state.width; 25830 delete element.__dxHiddenElementState; 25831}; 25832ASPx.Ident.IsASPxClientButton = function(obj) { 25833 return !!obj.isASPxClientButton; 25834};
25835function _aspxBCallButtonMethod(name, methodName, arg) { 25836 var button = ASPx.GetControlCollection().Get(name); 25837 if(button != null) 25838 button[methodName](arg); 25839} 25840ASPx.BClick = function(name, evt) { 25841 var button = ASPx.GetControlCollection().Get(name); 25842 if(button != null) 25843 return button.OnClick(evt); 25844}; 25845window.ASPxClientButton = ASPxClientButton; 25846})(); 25847 25848(function () { 25849var Constants = { 25850 Name: "ASPxGlobalEvents" 25851}; 25852var ASPxClientGlobalEvents = ASPx.CreateClass(ASPxClientComponent, { 25853 constructor: function () { 25854 this.constructor.prototype.constructor.call(this, Constants.Name); 25855 this.ControlsInitialized = new ASPxClientEvent(); 25856 this.BrowserWindowResized = new ASPxClientEvent(); 25857 this.BeginCallback = new ASPxClientEvent(); 25858 this.EndCallback = new ASPxClientEvent(); 25859 this.CallbackError = new ASPxClientEvent(); 25860 this.ValidationCompleted = new ASPxClientEvent(); 25861 }, 25862 OnGlobalControlsInitialized: function(args) { 25863 this.ControlsInitialized.FireEvent(this, args); 25864 }, 25865 OnGlobalBrowserWindowResized: function(args) { 25866 this.BrowserWindowResized.FireEvent(this, args); 25867 }, 25868 OnGlobalBeginCallback: function(args) { 25869 this.BeginCallback.FireEvent(this, args); 25870 }, 25871 OnGlobalEndCallback: function(args) { 25872 this.EndCallback.FireEvent(this, args); 25873 }, 25874 OnGlobalCallbackError: function(args) { 25875 this.CallbackError.FireEvent(this, args); 25876 }, 25877 OnGlobalValidationCompleted: function(args) { 25878 this.ValidationCompleted.FireEvent(this, args); 25879 } 25880}); 25881var globalEvents = null; 25882function aspxGetGlobalEvents() { 25883 if(globalEvents == null) 25884 globalEvents = new ASPxClientGlobalEvents(); 25885 return globalEvents; 25886} 25887ASPx.GetGlobalEvents = aspxGetGlobalEvents; 25888window.ASPxClientGlobalEvents = ASPxClientGlobalEvents; 25889})();
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.