1(function (define) { 2 define(['jquery'], function ($) { 3 return (function () { 4 var abp = window.abp || {}; 5 6 /* Application paths *****************************************/ 7 8 //Current application root path (including virtual directory if exists). 9 abp.appPath = abp.appPath || '/'; 10 abp.pageLoadTime = new Date(); 11 12 //Converts given path to absolute path using abp.appPath variable. 13 abp.toAbsAppPath = function (path) { 14 if (path.indexOf('/') == 0) { 15 path = path.substring(1); 16 } 17 18 return abp.appPath + path; 19 }; 20 21 /* MULTITENANCY */ 22 23 abp.multiTenancy = abp.multiTenancy || {}; 24 25 abp.multiTenancy.isEnabled = false; 26 abp.multiTenancy.ignoreFeatureCheckForHostUsers = false; 27 28 abp.multiTenancy.sides = { 29 TENANT: 1, 30 HOST: 2 31 }; 32 33 abp.multiTenancy.tenantIdCookieName = 'Abp.TenantId'; 34 35 abp.multiTenancy.setTenantIdCookie = function (tenantId) { 36 if (tenantId) { 37 abp.utils.setCookieValue( 38 abp.multiTenancy.tenantIdCookieName, 39 tenantId.toString(), 40 new Date(new Date().getTime() + 5 * 365 * 86400000), //5 years 41 abp.appPath, 42 abp.domain 43 ); 44 } else { 45 abp.utils.deleteCookie(abp.multiTenancy.tenantIdCookieName, abp.appPath); 46 } 47 }; 48 49 abp.multiTenancy.getTenantIdCookie = function () { 50 var value = abp.utils.getCookieValue(abp.multiTenancy.tenantIdCookieName); 51 if (!value) { 52 return null; 53 } 54 55 return parseInt(value); 56 } 57 58 /* SESSION */ 59 60 abp.session = abp.session || 61 { 62 multiTenancySide: abp.multiTenancy.sides.HOST 63 }; 64 65 /* LOCALIZATION ***********************************************/ 66 //Implements Localization API that simplifies usage of localization scripts generated by Abp. 67 68 abp.localization = abp.localization || {}; 69 70 abp.localization.languages = []; 71 72 abp.localization.currentLanguage = {}; 73 74 abp.localization.sources = []; 75 76 abp.localization.values = {}; 77 78 abp.localization.localize = function (key, sourceName) { 79 sourceName = sourceName || abp.localization.defaultSourceName; 80 81 var source = abp.localization.values[sourceName]; 82 83 if (!source) { 84 abp.log.warn('Could not find localization source: ' + sourceName); 85 return key; 86 } 87 88 var value = source[key]; 89 if (value == undefined) { 90 return key; 91 } 92 93 var copiedArguments = Array.prototype.slice.call(arguments, 0); 94 copiedArguments.splice(1, 1); 95 copiedArguments[0] = value; 96 97 return abp.utils.formatString.apply(this, copiedArguments); 98 }; 99 100 abp.localization.getSource = function (sourceName) { 101 return function (key) { 102 var copiedArguments = Array.prototype.slice.call(arguments, 0); 103 copiedArguments.splice(1, 0, sourceName); 104 return abp.localization.localize.apply(this, copiedArguments); 105 }; 106 }; 107 108 abp.localization.isCurrentCulture = function (name) { 109 return abp.localization.currentCulture 110 && abp.localization.currentCulture.name 111 && abp.localization.currentCulture.name.indexOf(name) == 0; 112 }; 113 114 abp.localization.defaultSourceName = undefined; 115 abp.localization.abpWeb = abp.localization.getSource('AbpWeb'); 116 117 /* AUTHORIZATION **********************************************/ 118 //Implements Authorization API that simplifies usage of authorization scripts generated by Abp. 119 120 abp.auth = abp.auth || {}; 121 122 abp.auth.allPermissions = abp.auth.allPermissions || {}; 123 124 abp.auth.grantedPermissions = abp.auth.grantedPermissions || {}; 125 126 //Deprecated. Use abp.auth.isGranted instead. 127 abp.auth.hasPermission = function (permissionName) { 128 return abp.auth.isGranted.apply(this, arguments); 129 }; 130 131 //Deprecated. Use abp.auth.isAnyGranted instead. 132 abp.auth.hasAnyOfPermissions = function () { 133 return abp.auth.isAnyGranted.apply(this, arguments); 134 }; 135 136 //Deprecated. Use abp.auth.areAllGranted instead. 137 abp.auth.hasAllOfPermissions = function () { 138 return abp.auth.areAllGranted.apply(this, arguments); 139 }; 140 141 abp.auth.isGranted = function (permissionName) { 142 return abp.auth.grantedPermissions[permissionName] != undefined; 143 }; 144 145 abp.auth.isAnyGranted = function () { 146 if (!arguments || arguments.length <= 0) { 147 return true; 148 } 149 150 for (var i = 0; i < arguments.length; i++) { 151 if (abp.auth.isGranted(arguments[i])) { 152 return true; 153 } 154 } 155 156 return false;
157 }; 158 159 abp.auth.areAllGranted = function () { 160 if (!arguments || arguments.length <= 0) { 161 return true; 162 } 163 164 for (var i = 0; i < arguments.length; i++) { 165 if (!abp.auth.isGranted(arguments[i])) { 166 return false; 167 } 168 } 169 170 return true; 171 }; 172 173 abp.auth.tokenCookieName = 'Abp.AuthToken'; 174 175 abp.auth.setToken = function (authToken, expireDate) { 176 abp.utils.setCookieValue(abp.auth.tokenCookieName, authToken, expireDate, abp.appPath, abp.domain); 177 }; 178 179 abp.auth.getToken = function() { 180 return abp.utils.getCookieValue(abp.auth.tokenCookieName); 181 }; 182 183 abp.auth.clearToken = function() { 184 abp.auth.setToken(); 185 }; 186 187 abp.auth.refreshTokenCookieName = 'Abp.AuthRefreshToken'; 188 189 abp.auth.setRefreshToken = function (refreshToken, expireDate) { 190 abp.utils.setCookieValue(abp.auth.refreshTokenCookieName, refreshToken, expireDate, abp.appPath, abp.domain); 191 }; 192 193 abp.auth.getRefreshToken = function() { 194 return abp.utils.getCookieValue(abp.auth.refreshTokenCookieName); 195 }; 196 197 abp.auth.clearRefreshToken = function() { 198 abp.auth.setRefreshToken(); 199 }; 200 201 /* FEATURE SYSTEM *********************************************/ 202 //Implements Features API that simplifies usage of feature scripts generated by Abp. 203 204 abp.features = abp.features || {}; 205 206 abp.features.allFeatures = abp.features.allFeatures || {}; 207 208 abp.features.get = function (name) { 209 return abp.features.allFeatures[name]; 210 } 211 212 abp.features.getValue = function (name) { 213 var feature = abp.features.get(name); 214 if (feature == undefined) { 215 return undefined; 216 } 217 218 return feature.value; 219 } 220 221 abp.features.isEnabled = function (name) { 222 var value = abp.features.getValue(name); 223 return value == 'true' || value == 'True'; 224 } 225 226 /* SETTINGS **************************************************/ 227 //Implements Settings API that simplifies usage of setting scripts generated by Abp. 228 229 abp.setting = abp.setting || {}; 230 231 abp.setting.values = abp.setting.values || {}; 232 233 abp.setting.get = function (name) { 234 return abp.setting.values[name]; 235 }; 236 237 abp.setting.getBoolean = function (name) { 238 var value = abp.setting.get(name); 239 return value == 'true' || value == 'True'; 240 }; 241 242 abp.setting.getInt = function (name) { 243 return parseInt(abp.setting.values[name]); 244 }; 245 246 /* REALTIME NOTIFICATIONS ************************************/ 247 248 abp.notifications = abp.notifications || {}; 249 250 abp.notifications.severity = { 251 INFO: 0, 252 SUCCESS: 1, 253 WARN: 2, 254 ERROR: 3, 255 FATAL: 4 256 }; 257 258 abp.notifications.userNotificationState = { 259 UNREAD: 0, 260 READ: 1 261 }; 262 263 abp.notifications.getUserNotificationStateAsString = function (userNotificationState) { 264 switch (userNotificationState) { 265 case abp.notifications.userNotificationState.READ: 266 return 'READ'; 267 case abp.notifications.userNotificationState.UNREAD: 268 return 'UNREAD'; 269 default: 270 abp.log.warn('Unknown user notification state value: ' + userNotificationState) 271 return '?'; 272 } 273 }; 274 275 abp.notifications.getUiNotifyFuncBySeverity = function (severity) { 276 switch (severity) { 277 case abp.notifications.severity.SUCCESS: 278 return abp.notify.success; 279 case abp.notifications.severity.WARN: 280 return abp.notify.warn; 281 case abp.notifications.severity.ERROR: 282 return abp.notify.error; 283 case abp.notifications.severity.FATAL: 284 return abp.notify.error; 285 case abp.notifications.severity.INFO: 286 default: 287 return abp.notify.info; 288 } 289 }; 290 291 abp.notifications.messageFormatters = {}; 292 293 abp.notifications.messageFormatters['Abp.Notifications.MessageNotificationData'] = function (userNotification) { 294 return userNotification.notification.data.message || userNotification.notification.data.properties.Message; 295 }; 296 297 abp.notifications.messageFormatters['Abp.Notifications.LocalizableMessageNotificationData'] = 298 function (userNotification) { 299 var message = userNotification.notification.data.message || 300 userNotification.notification.data.properties.Message; 301 var localizedMessage = abp.localization.localize( 302 message.name, 303 message.sourceName 304 ); 305 306 if (userNotification.notification.data.properties) { 307 if ($) { 308 //Prefer to use jQuery if possible 309 $.each(userNotification.notification.data.properties, function (key, value) { 310 localizedMessage = localizedMessage.replace('{' + key + '}', value); 311 }); 312 } else { 313 //alternative for $.each 314 var properties = Object.keys(userNotification.notification.data.properties); 315 for (var i = 0; i < properties.length; i++) { 316 localizedMessage = localizedMessage.replace('{' + properties[i] + '}', 317 userNotification.notification.data.properties[properties[i]]); 318 } 319 } 320 } 321 322 return localizedMessage; 323 }; 324 325 abp.notifications.getFormattedMessageFromUserNotification = function (userNotification) { 326 var formatter = abp.notifications.messageFormatters[userNotification.notification.data.type]; 327 if (!formatter) { 328 abp.log.warn('No message formatter defined for given data type: ' + userNotification.notification.data.type) 329 return '?'; 330 } 331 332 if (!abp.utils.isFunction(formatter)) { 333 abp.log.warn('Message formatter should be a function! It is invali
333d for data type: ' + 334 userNotification.notification.data.type) 335 return '?'; 336 } 337 338 return formatter(userNotification); 339 } 340 341 abp.notifications.showUiNotifyForUserNotification = function (userNotification, options) { 342 var message = abp.notifications.getFormattedMessageFromUserNotification(userNotification); 343 var uiNotifyFunc = abp.notifications.getUiNotifyFuncBySeverity(userNotification.notification.severity); 344 uiNotifyFunc(message, undefined, options); 345 } 346 347 /* LOGGING ***************************************************/ 348 //Implements Logging API that provides secure & controlled usage of console.log 349 350 abp.log = abp.log || {}; 351 352 abp.log.levels = { 353 DEBUG: 1, 354 INFO: 2, 355 WARN: 3, 356 ERROR: 4, 357 FATAL: 5 358 }; 359 360 abp.log.level = abp.log.levels.DEBUG; 361 362 abp.log.log = function (logObject, logLevel) { 363 if (!window.console || !window.console.log) { 364 return; 365 } 366 367 if (logLevel != undefined && logLevel < abp.log.level) { 368 return; 369 } 370 371 console.log(logObject); 372 }; 373 374 abp.log.debug = function (logObject) { 375 abp.log.log("DEBUG: ", abp.log.levels.DEBUG); 376 abp.log.log(logObject, abp.log.levels.DEBUG); 377 }; 378 379 abp.log.info = function (logObject) { 380 abp.log.log("INFO: ", abp.log.levels.INFO); 381 abp.log.log(logObject, abp.log.levels.INFO); 382 }; 383 384 abp.log.warn = function (logObject) { 385 abp.log.log("WARN: ", abp.log.levels.WARN); 386 abp.log.log(logObject, abp.log.levels.WARN); 387 }; 388 389 abp.log.error = function (logObject) { 390 abp.log.log("ERROR: ", abp.log.levels.ERROR); 391 abp.log.log(logObject, abp.log.levels.ERROR); 392 }; 393 394 abp.log.fatal = function (logObject) { 395 abp.log.log("FATAL: ", abp.log.levels.FATAL); 396 abp.log.log(logObject, abp.log.levels.FATAL); 397 }; 398 399 /* NOTIFICATION *********************************************/ 400 //Defines Notification API, not implements it 401 402 abp.notify = abp.notify || {}; 403 404 abp.notify.success = function (message, title, options) { 405 abp.log.warn('abp.notify.success is not implemented!'); 406 }; 407 408 abp.notify.info = function (message, title, options) { 409 abp.log.warn('abp.notify.info is not implemented!'); 410 }; 411 412 abp.notify.warn = function (message, title, options) { 413 abp.log.warn('abp.notify.warn is not implemented!'); 414 }; 415 416 abp.notify.error = function (message, title, options) { 417 abp.log.warn('abp.notify.error is not implemented!'); 418 }; 419 420 /* MESSAGE **************************************************/ 421 //Defines Message API, not implements it 422 423 abp.message = abp.message || {}; 424 425 var showMessage = function (message, title, options) { 426 alert((title || '') + ' ' + message); 427 428 if (!$) { 429 abp.log.warn('abp.message can not return promise since jQuery is not defined!'); 430 return null; 431 } 432 433 return $.Deferred(function ($dfd) { 434 $dfd.resolve(); 435 }); 436 }; 437 438 abp.message.info = function (message, title, options) { 439 abp.log.warn('abp.message.info is not implemented!'); 440 return showMessage(message, title, options); 441 }; 442 443 abp.message.success = function (message, title, options) { 444 abp.log.warn('abp.message.success is not implemented!'); 445 return showMessage(message, title, options); 446 }; 447 448 abp.message.warn = function (message, title, options) { 449 abp.log.warn('abp.message.warn is not implemented!'); 450 return showMessage(message, title, options); 451 }; 452 453 abp.message.error = function (message, title, options) { 454 abp.log.warn('abp.message.error is not implemented!'); 455 return showMessage(message, title, options); 456 }; 457 458 abp.message.confirm = function (message, title, callback, options) { 459 abp.log.warn('abp.message.confirm is not implemented!'); 460 461 var result = confirm(message); 462 callback && callback(result); 463 464 if (!$) { 465 abp.log.warn('abp.message can not return promise since jQuery is not defined!'); 466 return null; 467 } 468 469 return $.Deferred(function ($dfd) { 470 $dfd.resolve(); 471 }); 472 }; 473 474 /* UI *******************************************************/ 475 476 abp.ui = abp.ui || {}; 477 478 /* UI BLOCK */ 479 //Defines UI Block API, not implements it 480 481 abp.ui.block = function (elm) { 482 abp.log.warn('abp.ui.block is not implemented!'); 483 }; 484 485 abp.ui.unblock = function (elm) { 486 abp.log.warn('abp.ui.unblock is not implemented!'); 487 }; 488 489 /* UI BUSY */ 490 //Defines UI Busy API, not implements it 491 492 abp.ui.setBusy = function (elm, optionsOrPromise) { 493 abp.log.warn('abp.ui.setBusy is not implemented!'); 494 }; 495 496 abp.ui.clearBusy = function (elm) { 497 abp.log.warn('abp.ui.clearBusy is not implemented!'); 498 }; 499 500 /* SIMPLE EVENT BUS *****************************************/ 501 502 abp.event = (function () { 503 504 var _callbacks = {}; 505 506 var on = function (eventName, callback) { 507 if (!_callbacks[eventName]) { 508 _callbacks[eventName] = []; 509 } 510 511 _callbacks[eventName].push(callback); 512 }; 513 514 var off = function (eventName, callback) { 515 var callbacks = _callbacks[eventName]; 516 if (!callbacks) { 517 return; 518 } 519 520 var index = -1; 521 for (var i = 0; i < callbacks.length; i++) { 522 if (callbacks[i] === callback) { 523 index = i; 524 break; 525 } 526 } 527 528 if (index < 0) { 529 return; 530 } 531 532 _callbacks[eventName].splice(index, 1); 533 }; 534 535 var trigger = function (eventName) { 536 var callbacks = _callbacks[eventName]; 537 if (!callbacks || !callbacks.length) { 538 return; 539 } 540 541 var args = Array.prototype.slice.call(arguments, 1); 542 for (var i = 0; i < callbacks.length; i++) { 543 callbacks[i].apply(this, args); 544 } 545 }; 546 547 // Public interface /////////////////////////////////////////////////// 548 549 return { 550 on: on, 551 off: off, 552 trigger: trigger 553 }; 554 })(); 555 556 /* UTILS ***************************************************/ 557 558 abp.utils = abp.utils || {}; 559 560 /* Creates a name namespace. 561 * Example: 562 * var taskService = abp.utils.createNamespace(abp, 'services.task'); 563 * taskService will be equal to abp.services.task 564 * first argument (root) must be defined first 565 ************************************************************/ 566 abp.utils.createNamespace = function (root, ns) { 567 var parts = ns.split('.'); 568 for (var i = 0; i < parts.length; i++) { 569 if (typeof root[parts[i]] == 'undefined') { 570 root[parts[i]] = {}; 571 } 572 573 root = root[parts[i]]; 574 } 575 576 return root; 577 }; 578 579 /* Find and replaces a string (search) to another string (replacement) in 580 * given string (str). 581 * Example: 582 * abp.utils.replaceAll('This is a test string', 'is', 'X') = 'ThX X a test string' 583 ************************************************************/ 584 abp.utils.replaceAll = function (str, search, replacement) { 585 var fix = search.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); 586 return str.replace(new RegExp(fix, 'g'), replacement); 587 }; 588 589 /* Formats a string just like string.format in C#. 590 * Example: 591 * abp.utils.formatString('Hello {0}','Tuana') = 'Hello Tuana' 592 ************************************************************/ 593 abp.utils.formatString = function () { 594 if (arguments.length < 1) { 595 return null; 596 } 597 598 var str = arguments[0]; 599 600 for (var i = 1; i < arguments.length; i++) { 601 var placeHolder = '{' + (i - 1) + '}'; 602 str = abp.utils.replaceAll(str, placeHolder, arguments[i]); 603 } 604 605 return str; 606 }; 607 608 abp.utils.toPascalCase = function (str) { 609 if (!str || !str.length) { 610 return str; 611 } 612 613 if (str.length === 1) { 614 return str.charAt(0).toUpperCase(); 615 } 616 617 return str.charAt(0).toUpperCase() + str.substr(1); 618 } 619 620 abp.utils.toCamelCase = function (str) { 621 if (!str || !str.length) { 622 return str; 623 } 624 625 if (str.length === 1) { 626 return str.charAt(0).toLowerCase(); 627 } 628 629 return str.charAt(0).toLowerCase() + str.substr(1); 630 } 631 632 abp.utils.truncateString = function (str, maxLength) { 633 if (!str || !str.length || str.length <= maxLength) { 634 return str; 635 } 636 637 return str.substr(0, maxLength); 638 }; 639 640 abp.utils.truncateStringWithPostfix = function (str, maxLength, postfix) { 641 postfix = postfix || '...'; 642 643 if (!str || !str.length || str.length <= maxLength) { 644 return str; 645 } 646 647 if (maxLength <= postfix.length) { 648 return postfix.substr(0, maxLength); 649 } 650 651 return str.substr(0, maxLength - postfix.length) + postfix; 652 }; 653 654 abp.utils.isFunction = function (obj) { 655 if ($) { 656 //Prefer to use jQuery if possible 657 return $.isFunction(obj); 658 } 659 660 //alternative for $.isFunction 661 return !!(obj && obj.constructor && obj.call && obj.apply); 662 }; 663 664 /** 665 * parameterInfos should be an array of { name, value } objects 666 * where name is query string parameter name and value is it's value. 667 * includeQuestionMark is true by default. 668 */ 669 abp.utils.buildQueryString = function (parameterInfos, includeQuestionMark) { 670 if (includeQuestionMark === undefined) { 671 includeQuestionMark = true; 672 } 673 674 var qs = ''; 675 676 function addSeperator() { 677 if (!qs.length) { 678 if (includeQuestionMark) { 679 qs = qs + '?'; 680 } 681 } else { 682 qs = qs + '&'; 683 } 684 } 685 686 for (var i = 0; i < parameterInfos.length; ++i) { 687 var parameterInfo = parameterInfos[i]; 688 if (parameterInfo.value === undefined) { 689 continue; 690 } 691 692 if (parameterInfo.value === null) { 693 parameterInfo.value = ''; 694 } 695 696 addSeperator(); 697 698 if (parameterInfo.value.toJSON && typeof parameterInfo.value.toJSON === "function") { 699 qs = qs + parameterInfo.name + '=' + encodeURIComponent(parameterInfo.value.toJSON()); 700 } else if (Array.isArray(parameterInfo.value) && parameterInfo.value.length) { 701 for (var j = 0; j < parameterInfo.value.length; j++) { 702 if (j > 0) { 703 addSeperator(); 704 } 705 706 qs = qs + parameterInfo.name + '[' + j + ']=' + encodeURIComponent(parameterInfo.value[j]); 707 } 708 } else { 709 qs = qs + parameterInfo.name + '=' + encodeURIComponent(parameterInfo.value); 710 } 711 } 712 713 return qs; 714 } 715 716 /** 717 * Sets a cookie value for given key. 718 * This is a simple implementation created to be used by ABP. 719 * Please use a complete cookie library if you need. 720 * @param {string} key 721 * @param {string} value 722 * @param {Date} expireDate (optional). If not specified the cookie will expire at the end of session. 723 * @param {string} path (optional) 724 * @param {string} domain (optional) 725 * @param {any} attributes (optional) 726 */
727 abp.utils.setCookieValue = function (key, value, expireDate, path, domain, attributes) { 728 var cookieValue = encodeURIComponent(key) + '='; 729 730 if (value) { 731 cookieValue = cookieValue + encodeURIComponent(value); 732 } 733 734 if (expireDate) { 735 cookieValue = cookieValue + "; expires=" + expireDate.toUTCString(); 736 } 737 738 if (path) { 739 cookieValue = cookieValue + "; path=" + path; 740 } 741 742 if (domain) { 743 cookieValue = cookieValue + "; domain=" + domain; 744 } 745 746 for (var name in attributes) { 747 if (!attributes[name]) { 748 continue; 749 } 750 751 cookieValue += '; ' + name; 752 if (attributes[name] === true) { 753 continue; 754 } 755 756 cookieValue += '=' + attributes[name].split(';')[0]; 757 } 758 759 document.cookie = cookieValue; 760 }; 761 762 /** 763 * Gets a cookie with given key. 764 * This is a simple implementation created to be used by ABP. 765 * Please use a complete cookie library if you need. 766 * @param {string} key 767 * @returns {string} Cookie value or null 768 */ 769 abp.utils.getCookieValue = function (key) { 770 var equalities = document.cookie.split('; '); 771 for (var i = 0; i < equalities.length; i++) { 772 if (!equalities[i]) { 773 continue; 774 } 775 776 var splitted = equalities[i].split('='); 777 if (splitted.length != 2) { 778 continue; 779 } 780 781 if (decodeURIComponent(splitted[0]) === key) { 782 return decodeURIComponent(splitted[1] || ''); 783 } 784 } 785 786 return null; 787 }; 788 789 /** 790 * Deletes cookie for given key. 791 * This is a simple implementation created to be used by ABP. 792 * Please use a complete cookie library if you need. 793 * @param {string} key 794 * @param {string} path (optional) 795 */ 796 abp.utils.deleteCookie = function (key, path) { 797 var cookieValue = encodeURIComponent(key) + '='; 798 799 cookieValue = cookieValue + "; expires=" + (new Date(new Date().getTime() - 86400000)).toUTCString(); 800 801 if (path) { 802 cookieValue = cookieValue + "; path=" + path; 803 } 804 805 document.cookie = cookieValue; 806 } 807 808 /** 809 * Gets the domain of given url 810 * @param {string} url 811 * @returns {string} 812 */ 813 abp.utils.getDomain = function (url) { 814 var domainRegex = /(https?:){0,1}\/\/((?:[\w\d-]+\.)+[\w\d]{2,})/i; 815 var matches = domainRegex.exec(url); 816 return (matches && matches[2]) ? matches[2] : ''; 817 } 818 819 /* TIMING *****************************************/ 820 abp.timing = abp.timing || {}; 821 822 abp.timing.utcClockProvider = (function () { 823 824 var toUtc = function (date) { 825 return Date.UTC( 826 date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), date.getUTCHours(), date.getUTCMinutes(), 827 date.getUTCSeconds(), date.getUTCMilliseconds() 828 ); 829 } 830 831 var now = function () { 832 return toUtc(new Date()); 833 }; 834 835 var normalize = function (date) { 836 if (!date) { 837 return date; 838 } 839 840 return new Date(toUtc(date)); 841 }; 842 843 // Public interface /////////////////////////////////////////////////// 844 845 return { 846 now: now, 847 normalize: normalize, 848 supportsMultipleTimezone: true 849 }; 850 })(); 851 852 abp.timing.localClockProvider = (function () { 853 854 var toLocal = function (date) { 855 return new Date( 856 date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 857 date.getMilliseconds() 858 ); 859 } 860 861 var now = function () { 862 return toLocal(new Date()); 863 } 864 865 var normalize = function (date) { 866 if (!date) { 867 return date; 868 } 869 870 return toLocal(date); 871 } 872 873 // Public interface /////////////////////////////////////////////////// 874 875 return { 876 now: now, 877 normalize: normalize, 878 supportsMultipleTimezone: false 879 }; 880 })(); 881 882 abp.timing.unspecifiedClockProvider = (function () { 883 884 var now = function () { 885 return new Date(); 886 } 887 888 var normalize = function (date) { 889 return date; 890 } 891 892 // Public interface /////////////////////////////////////////////////// 893 894 return { 895 now: now, 896 normalize: normalize, 897 supportsMultipleTimezone: false 898 }; 899 })(); 900 901 abp.timing.convertToUserTimezone = function (date) { 902 var localTime = date.getTime(); 903 var utcTime = localTime + (date.getTimezoneOffset() * 60000); 904 var targetTime = parseInt(utcTime) + parseInt(abp.timing.timeZoneInfo.windows.currentUtcOffsetInMilliseconds); 905 return new Date(targetTime); 906 }; 907 908 /* CLOCK *****************************************/ 909 abp.clock = abp.clock || {}; 910 911 abp.clock.now = function () { 912 if (abp.clock.provider) { 913 return abp.clock.provider.now(); 914 } 915 916 return new Date(); 917 } 918 919 abp.clock.normalize = function (date) { 920 if (abp.clock.provider) { 921 return abp.clock.provider.normalize(date); 922 } 923 924 return date; 925 } 926 927 abp.clock.provider = abp.timing.unspecifiedClockProvider; 928 929 /* SECURITY ***************************************/ 930 abp.security = abp.security || {}; 931 abp.security.antiForgery = abp.security.antiForgery || {}; 932 933 abp.security.antiForgery.tokenCookieName = 'XSRF-TOKEN'; 934 abp.security.antiForgery.tokenHeaderName = 'X-XSRF-TOKEN'; 935 936 abp.security.antiForgery.getToken = function () { 937 return abp.utils.getCookieValue(abp.security.antiForgery.tokenCookieName); 938 }; 939
940 abp.security.antiForgery.shouldSendToken = function (settings) { 941 if (settings.crossDomain === undefined || settings.crossDomain === null) { 942 return abp.utils.getDomain(location.href) === abp.utils.getDomain(settings.url); 943 } 944 945 return !settings.crossDomain; 946 }; 947 948 return abp; 949 })(); 950 }); 951}(typeof define === 'function' && define.amd 952 ? define 953 : function (deps, factory) { 954 if (typeof module !== 'undefined' && module.exports) { 955 module.exports = factory(require('jquery')); 956 } else { 957 window.abp = factory(window.jQuery); 958 } 959 }));
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.