and | have strange behavior with offsetLeft/offsetTop and clientLeft/clientTop.
// Say you have the following html:
// The offsetLeft and offsetTop for the | will be 25, but the client/borderLeft and
// client/borderTop for the will also be 25. So if you count the client/borderLeft and
// client/borderTop for the , you will be double-counting the table border.
if ((tagName !== "TABLE") && (tagName !== "TD") && (tagName !== "HTML")) {
offsetX += parseInt(currentStyle.borderLeftWidth) || 0;
offsetY += parseInt(currentStyle.borderTopWidth) || 0;
}
if (tagName === "TABLE" &&
(currentStyle.position === "relative" || currentStyle.position === "absolute")) {
offsetX += parseInt(currentStyle.marginLeft) || 0;
offsetY += parseInt(currentStyle.marginTop) || 0;
}
}
}
currentStyle = Sys.UI.DomElement._getCurrentStyle(element);
var elementPosition = currentStyle ? currentStyle.position : null;
// If an element is absolutely positioned, its parent's scroll should not be subtracted, except on Opera.
if (!elementPosition || (elementPosition !== "absolute")) {
// In Firefox and Safari, all parent's scroll values must be taken into account.
// In IE, only the offset parent's because positioned elements are offset-parented to BODY and
// don't need scroll substraction. Non-positioned elements are offset-parented to their parent,
// which may be scrolled.
for (var parent = element.parentNode; parent; parent = parent.parentNode) {
// In IE quirks mode, the element has bogus values for scrollLeft and scrollTop.
// So we do not use the scrollLeft and scrollTop for the element. This does not
// break the standards mode behavior. (VSWhidbey 426176)
tagName = parent.tagName;
if ((tagName !== "BODY") && (tagName !== "HTML") && (parent.scrollLeft || parent.scrollTop)) {
offsetX -= (parent.scrollLeft || 0);
offsetY -= (parent.scrollTop || 0);
currentStyle = Sys.UI.DomElement._getCurrentStyle(parent);
if (currentStyle) {
offsetX += parseInt(currentStyle.borderLeftWidth) || 0;
offsetY += parseInt(currentStyle.borderTopWidth) || 0;
}
}
}
}
return new Sys.UI.Point(offsetX, offsetY);
}
break;
}
Sys.UI.DomElement.removeCssClass = function Sys$UI$DomElement$removeCssClass(element, className) {
///
///
///
var e = Function._validateParams(arguments, [
{name: "element", domElement: true},
{name: "className", type: String}
]);
if (e) throw e;
var currentClassName = ' ' + element.className + ' ';
var index = currentClassName.indexOf(' ' + className + ' ');
if (index >= 0) {
element.className = (currentClassName.substr(0, index) + ' ' +
currentClassName.substring(index + className.length + 1, currentClassName.length)).trim();
}
}
Sys.UI.DomElement.setLocation = function Sys$UI$DomElement$setLocation(element, x, y) {
///
///
///
///
var e = Function._validateParams(arguments, [
{name: "element", domElement: true},
{name: "x", type: Number, integer: true},
{name: "y", type: Number, integer: true}
]);
if (e) throw e;
var style = element.style;
style.position = 'absolute';
style.left = x + "px";
style.top = y + "px";
}
Sys.UI.DomElement.toggleCssClass = function Sys$UI$DomElement$toggleCssClass(element, className) {
///
///
///
var e = Function._validateParams(arguments, [
{name: "element", domElement: true},
{name: "className", type: String}
]);
if (e) throw e;
if (Sys.UI.DomElement.containsCssClass(element, className)) {
Sys.UI.DomElement.removeCssClass(element, className);
}
else {
Sys.UI.DomElement.addCssClass(element, className);
}
}
Sys.UI.DomElement.getVisibilityMode = function Sys$UI$DomElement$getVisibilityMode(element) {
///
///
///
var e = Function._validateParams(arguments, [
{name: "element", domElement: true}
]);
if (e) throw e;
return (element._visibilityMode === Sys.UI.VisibilityMode.hide) ?
Sys.UI.VisibilityMode.hide :
Sys.UI.VisibilityMode.collapse;
}
Sys.UI.DomElement.setVisibilityMode = function Sys$UI$DomElement$setVisibilityMode(element, value) {
///
///
///
var e = Function._validateParams(arguments, [
{name: "element", domElement: true},
{name: "value", type: Sys.UI.VisibilityMode}
]);
if (e) throw e;
Sys.UI.DomElement._ensureOldDisplayMode(element);
if (element._visibilityMode !== value) {
element._visibilityMode = value;
if (Sys.UI.DomElement.getVisible(element) === false) {
if (element._visibilityMode === Sys.UI.VisibilityMode.hide) {
element.style.display = element._oldDisplayMode;
}
else {
element.style.display = 'none';
}
}
element._visibilityMode = value;
}
}
Sys.UI.DomElement.getVisible = function Sys$UI$DomElement$getVisible(element) {
///
///
///
var e = Function._validateParams(arguments, [
{name: "element", domElement: true}
]);
if (e) throw e;
var style = element.currentStyle || Sys.UI.DomElement._getCurrentStyle(element);
if (!style) return true;
return (style.visibility !== 'hidden') && (style.display !== 'none');
}
Sys.UI.DomElement.setVisible = function Sys$UI$DomElement$setVisible(element, value) {
///
///
///
var e = Function._validateParams(arguments, [
{name: "element", domElement: true},
{name: "value", type: Boolean}
]);
if (e) throw e;
if (value !== Sys.UI.DomElement.getVisible(element)) {
Sys.UI.DomElement._ensureOldDisplayMode(element);
element.style.visibility = value ? 'visible' : 'hidden';
if (value || (element._visibilityMode === Sys.UI.VisibilityMode.hide)) {
element.style.display = element._oldDisplayMode;
}
else {
element.style.display = 'none';
}
}
}
Sys.UI.DomElement._ensureOldDisplayMode = function Sys$UI$DomElement$_ensureOldDisplayMode(element) {
if (!element._oldDisplayMode) {
var style = element.currentStyle || Sys.UI.DomElement._getCurrentStyle(element);
element._oldDisplayMode = style ? style.display : null;
if (!element._oldDisplayMode || element._oldDisplayMode === 'none') {
// Default is different depending on the tag name (omitting deprecated and non-standard tags)
switch(element.tagName.toUpperCase()) {
case 'DIV': case 'P': case 'ADDRESS': case 'BLOCKQUOTE': case 'BODY': case 'COL':
case 'COLGROUP': case 'DD': case 'DL': case 'DT': case 'FIELDSET': case 'FORM':
case 'H1': case 'H2': case 'H3': case 'H4': case 'H5': case 'H6': case 'HR':
case 'IFRAME': case 'LEGEND': case 'OL': case 'PRE': case 'TABLE': case 'TD':
case 'TH': case 'TR': case 'UL':
element._oldDisplayMode = 'block';
break;
case 'LI':
element._oldDisplayMode = 'list-item';
break;
default:
element._oldDisplayMode = 'inline';
}
}
}
}
Sys.UI.DomElement._getWindow = function Sys$UI$DomElement$_getWindow(element) {
var doc = element.ownerDocument || element.document || element;
return doc.defaultView || doc.parentWindow;
}
Sys.UI.DomElement._getCurrentStyle = function Sys$UI$DomElement$_getCurrentStyle(element) {
if (element.nodeType === 3) return null;
var w = Sys.UI.DomElement._getWindow(element);
if (element.documentElement) element = element.documentElement;
var computedStyle = (w && (element !== w) && w.getComputedStyle) ?
w.getComputedStyle(element, null) :
element.currentStyle || element.style;
if (!computedStyle && (Sys.Browser.agent === Sys.Browser.Safari) && element.style) {
// Safari has an interesting bug (fixed in WebKit) where an element with display:none will have a null computed style.
var oldDisplay = element.style.display;
var oldPosition = element.style.position;
element.style.position = 'absolute';
element.style.display = 'block';
var style = w.getComputedStyle(element, null);
element.style.display = oldDisplay;
element.style.position = oldPosition;
// Need a clone as the display property may be wrong and can't be fixed on the original object.
computedStyle = {};
for (var n in style) {
computedStyle[n] = style[n];
}
computedStyle.display = 'none';
}
return computedStyle;
}
Sys.IContainer = function Sys$IContainer() {
throw Error.notImplemented();
}
function Sys$IContainer$addComponent(component) {
///
///
var e = Function._validateParams(arguments, [
{name: "component", type: Sys.Component}
]);
if (e) throw e;
throw Error.notImplemented();
}
function Sys$IContainer$removeComponent(component) {
///
///
var e = Function._validateParams(arguments, [
{name: "component", type: Sys.Component}
]);
if (e) throw e;
throw Error.notImplemented();
}
function Sys$IContainer$findComponent(id) {
///
///
///
var e = Function._validateParams(arguments, [
{name: "id", type: String}
]);
if (e) throw e;
throw Error.notImplemented();
}
function Sys$IContainer$getComponents() {
///
///
if (arguments.length !== 0) throw Error.parameterCount();
throw Error.notImplemented();
}
Sys.IContainer.prototype = {
addComponent: Sys$IContainer$addComponent,
removeComponent: Sys$IContainer$removeComponent,
findComponent: Sys$IContainer$findComponent,
getComponents: Sys$IContainer$getComponents
}
Sys.IContainer.registerInterface("Sys.IContainer");
// This ScriptLoader works by injecting script tags into the DOM sequentially, waiting for each script
// to finish loading before proceeding to the next one.
// It supports a timeout which applies to ALL scripts.
// A call to Sys.Application.notifyScriptLoaded() must be at the bottom of each script, as that is
// the only reliable way to know when the script has finished loading in all browsers.
// It does however attach to the loaded, readystatechange, and error events on the script element, and it uses
// these event handlers to know when the script has loaded but the call to notifyScriptLoaded may not have been
// executed, which is treated as an error.
Sys._ScriptLoader = function Sys$_ScriptLoader() {
this._scriptsToLoad = null;
this._scriptLoadedDelegate = Function.createDelegate(this, this._scriptLoadedHandler);
}
function Sys$_ScriptLoader$dispose() {
this._stopLoading();
if(this._events) {
delete this._events;
}
this._scriptLoadedDelegate = null;
}
function Sys$_ScriptLoader$loadScripts(scriptTimeout, allScriptsLoadedCallback, scriptLoadFailedCallback, scriptLoadTimeoutCallback) {
///
///
///
///
///
var e = Function._validateParams(arguments, [
{name: "scriptTimeout", type: Number, integer: true},
{name: "allScriptsLoadedCallback", type: Function, mayBeNull: true},
{name: "scriptLoadFailedCallback", type: Function, mayBeNull: true},
{name: "scriptLoadTimeoutCallback", type: Function, mayBeNull: true}
]);
if (e) throw e;
if(this._loading) {
throw Error.invalidOperation(Sys.Res.scriptLoaderAlreadyLoading);
}
this._loading = true;
this._allScriptsLoadedCallback = allScriptsLoadedCallback;
this._scriptLoadFailedCallback = scriptLoadFailedCallback;
this._scriptLoadTimeoutCallback = scriptLoadTimeoutCallback;
this._loadScriptsInternal();
}
function Sys$_ScriptLoader$notifyScriptLoaded() {
///
if (arguments.length !== 0) throw Error.parameterCount();
// called at the bottom of scripts that have been loaded. This is how we know the script is finished
// mainly for Safari which doesn't support the load event.
if(!this._loading) {
// this can happen if someone disposes() the Script Loader while it is loading scripts
// OR if someone includes a reference inline -- which should be a no-op
return;
}
this._currentTask._notified++;
if(Sys.Browser.agent === Sys.Browser.Safari) {
if(this._currentTask._notified === 1) {
// the loaded event is never going to happen in Safari. But once we know that script within the loaded script
// is executing, we can know when it is finished by setting a 0 timeout, it will run after the loaded script
// is finished.
// On the first (and only the first) notification for this script, set a timeout that processes the script
// as if its loaded event fired. Only the first notification because if we did it for all we'd get one loaded event
// for each call.
window.setTimeout(Function.createDelegate(this, function() {
this._scriptLoadedHandler(this._currentTask.get_scriptElement(), true);
}), 0);
}
}
// in other browsers, the loaded handler will be called natively by the loaded/readystatechange event.
// Waiting rather than processing the next script immediately means we can detect scripts that incorrectly contain
// multiple notifyScriptLoaded() callbacks.
}
function Sys$_ScriptLoader$queueCustomScriptTag(scriptAttributes) {
///
///
var e = Function._validateParams(arguments, [
{name: "scriptAttributes"}
]);
if (e) throw e;
if(!this._scriptsToLoad) {
this._scriptsToLoad = [];
}
Array.add(this._scriptsToLoad, scriptAttributes);
}
function Sys$_ScriptLoader$queueScriptBlock(scriptContent) {
///
///
var e = Function._validateParams(arguments, [
{name: "scriptContent", type: String}
]);
if (e) throw e;
if(!this._scriptsToLoad) {
this._scriptsToLoad = [];
}
Array.add(this._scriptsToLoad, {text: scriptContent});
}
function Sys$_ScriptLoader$queueScriptReference(scriptUrl) {
///
///
var e = Function._validateParams(arguments, [
{name: "scriptUrl", type: String}
]);
if (e) throw e;
if(!this._scriptsToLoad) {
this._scriptsToLoad = [];
}
Array.add(this._scriptsToLoad, {src: scriptUrl});
}
function Sys$_ScriptLoader$_createScriptElement(queuedScript) {
var scriptElement = document.createElement('SCRIPT');
// Initialize default script type to JavaScript - but it might get overwritten
// if a custom script tag has a different type attribute.
scriptElement.type = 'text/javascript';
// Apply script element attributes
for (var attr in queuedScript) {
scriptElement[attr] = queuedScript[attr];
}
return scriptElement;
}
function Sys$_ScriptLoader$_loadScriptsInternal() {
// Load up the next script in the list
if (this._scriptsToLoad && this._scriptsToLoad.length > 0) {
var nextScript = Array.dequeue(this._scriptsToLoad);
// Inject a script element into the DOM
var scriptElement = this._createScriptElement(nextScript);
if (scriptElement.text && Sys.Browser.agent === Sys.Browser.Safari) {
// Safari requires the inline script to be in the innerHTML attribute
scriptElement.innerHTML = scriptElement.text;
delete scriptElement.text;
}
// AtlasWhidbey 36149: If they queue an empty script block "", we can't tell the difference between
// a script block queue entry and a src entry with just if(!element.text).
// dont use scriptElement.src --> FF resolves that to the current directory, IE leaves it blank.
// nextScript.src is always a string if it's a non block script.
if (typeof(nextScript.src) === "string") {
// We only need to worry about timing out and loading if the script tag has a 'src'.
this._currentTask = new Sys._ScriptLoaderTask(scriptElement, this._scriptLoadedDelegate);
// note: task is responsible for disposing of _itself_. This is necessary so that the ScriptLoader can continue
// with script loading after a script notifies it has loaded. The task sticks around until the dom element finishes
// completely, and disposes itself automatically.
// note: its possible for notify to occur before this method even returns in IE! So it should remain the last possible statement.
this._currentTask.execute();
}
else {
// script is literal script, so just load the script by adding the new element to the DOM
document.getElementsByTagName('HEAD')[0].appendChild(scriptElement);
// DevDiv 74151: Do not assume the script executes synchronously. Use a setTimeout to delay
// proceeding, which ensures the script executes before we continue. This was first introduced
// as a workaround for a Firefox bug, but we do it for all browsers in order to avoid making
// an assumption that may be wrong in the future. Executing the script synchronously is not
// in any spec or recommendation.
var scriptLoader = this; // used in the setTimeout closure
window.setTimeout(function() {
// cleanup (removes the script element in release mode).
Sys._ScriptLoader._clearScript(scriptElement);
// Resume script loading progress.
scriptLoader._loadScriptsInternal();
}, 0);
}
}
else {
// When there are no more scripts to load, call the final event
var callback = this._allScriptsLoadedCallback;
this._stopLoading();
if(callback) {
callback(this);
}
}
}
function Sys$_ScriptLoader$_raiseError(multipleCallbacks) {
// Abort script loading and raise an error.
var callback = this._scriptLoadFailedCallback;
var scriptElement = this._currentTask.get_scriptElement();
this._stopLoading();
if(callback) {
callback(this, scriptElement, multipleCallbacks);
}
else {
throw Sys._ScriptLoader._errorScriptLoadFailed(scriptElement.src, multipleCallbacks);
}
}
function Sys$_ScriptLoader$_scriptLoadedHandler(scriptElement, loaded) {
// called by the ScriptLoaderTask when the script element has finished loading, which could be because it loaded or
// errored out (for browsers that support the error event).
// In Safari this is called indirectly via a setTimeout in the notifyScriptLoaded method.
if(loaded && this._currentTask._notified) {
if(this._currentTask._notified > 1) {
// the script contained more than one notify callback
this._raiseError(true);
}
else {
// script loaded and contained a single notify callback, move on to next script
// DevDiv Bugs 123213: Note that scriptElement.src is read as un-htmlencoded, even if it was html encoded originally
Array.add(Sys._ScriptLoader._getLoadedScripts(), scriptElement.src);
this._currentTask.dispose();
this._currentTask = null;
this._loadScriptsInternal();
}
}
else {
// script loaded with an error or it did not contain a notify callback.
this._raiseError(false);
}
}
function Sys$_ScriptLoader$_scriptLoadTimeoutHandler() {
var callback = this._scriptLoadTimeoutCallback;
this._stopLoading();
if(callback) {
callback(this);
}
}
function Sys$_ScriptLoader$_stopLoading() {
if(this._timeoutCookie) {
window.clearTimeout(this._timeoutCookie);
this._timeoutCookie = null;
}
if(this._currentTask) {
this._currentTask.dispose();
this._currentTask = null;
}
this._scriptsToLoad = null;
this._loading = null;
this._allScriptsLoadedCallback = null;
this._scriptLoadFailedCallback = null;
this._scriptLoadTimeoutCallback = null;
}
Sys._ScriptLoader.prototype = {
dispose: Sys$_ScriptLoader$dispose,
loadScripts: Sys$_ScriptLoader$loadScripts,
notifyScriptLoaded: Sys$_ScriptLoader$notifyScriptLoaded,
queueCustomScriptTag: Sys$_ScriptLoader$queueCustomScriptTag,
queueScriptBlock: Sys$_ScriptLoader$queueScriptBlock,
queueScriptReference: Sys$_ScriptLoader$queueScriptReference,
_createScriptElement: Sys$_ScriptLoader$_createScriptElement,
_loadScriptsInternal: Sys$_ScriptLoader$_loadScriptsInternal,
_raiseError: Sys$_ScriptLoader$_raiseError,
_scriptLoadedHandler: Sys$_ScriptLoader$_scriptLoadedHandler,
_scriptLoadTimeoutHandler: Sys$_ScriptLoader$_scriptLoadTimeoutHandler,
_stopLoading: Sys$_ScriptLoader$_stopLoading
}
Sys._ScriptLoader.registerClass('Sys._ScriptLoader', null, Sys.IDisposable);
Sys._ScriptLoader.getInstance = function Sys$_ScriptLoader$getInstance() {
var sl = Sys._ScriptLoader._activeInstance;
if(!sl) {
sl = Sys._ScriptLoader._activeInstance = new Sys._ScriptLoader();
}
return sl;
}
Sys._ScriptLoader.isScriptLoaded = function Sys$_ScriptLoader$isScriptLoaded(scriptSrc) {
// For Firefox we need to resolve the script src attribute
// since the script elements already in the DOM are always
// resolved. To do this we create a dummy element to see
// what it would resolve to.
var dummyScript = document.createElement('script');
dummyScript.src = scriptSrc;
return Array.contains(Sys._ScriptLoader._getLoadedScripts(), dummyScript.src);
}
Sys._ScriptLoader.readLoadedScripts = function Sys$_ScriptLoader$readLoadedScripts() {
// enumerates the SCRIPT elements in the DOM and ensures we have their SRC's in the referencedScripts array.
if(!Sys._ScriptLoader._referencedScripts) {
var referencedScripts = Sys._ScriptLoader._referencedScripts = [];
var existingScripts = document.getElementsByTagName('SCRIPT');
for (i = existingScripts.length - 1; i >= 0; i--) {
var scriptNode = existingScripts[i];
var scriptSrc = scriptNode.src;
if (scriptSrc.length) {
if (!Array.contains(referencedScripts, scriptSrc)) {
Array.add(referencedScripts, scriptSrc);
}
}
}
}
}
Sys._ScriptLoader._clearScript = function Sys$_ScriptLoader$_clearScript(scriptElement) {
if (!Sys.Debug.isDebug) {
// In release mode we clear out the script elements that we add
// so that they don't clutter up the DOM.
scriptElement.parentNode.removeChild(scriptElement);
}
}
Sys._ScriptLoader._errorScriptLoadFailed = function Sys$_ScriptLoader$_errorScriptLoadFailed(scriptUrl, multipleCallbacks) {
var errorMessage;
if(multipleCallbacks) {
errorMessage = Sys.Res.scriptLoadMultipleCallbacks;
}
else {
// a much more detailed message is displayed in debug mode
errorMessage = Sys.Res.scriptLoadFailedDebug;
}
var displayMessage = "Sys.ScriptLoadFailedException: " + String.format(errorMessage, scriptUrl);
var e = Error.create(displayMessage, {name: 'Sys.ScriptLoadFailedException', 'scriptUrl': scriptUrl });
e.popStackFrame();
return e;
}
Sys._ScriptLoader._getLoadedScripts = function Sys$_ScriptLoader$_getLoadedScripts() {
if(!Sys._ScriptLoader._referencedScripts) {
Sys._ScriptLoader._referencedScripts = [];
Sys._ScriptLoader.readLoadedScripts();
}
return Sys._ScriptLoader._referencedScripts;
}
// ScriptLoaderTask loads a single script by injecting a dynamic script tag into the DOM.
// It calls the completed callback when the script element's load/readystatechange or error event occus.
// The ScriptLoader itself increments the _notified field each time notifyScriptLoaded is called from
// within the script (it should only be once). When the completed callback is called, ScriptLoader ensures
// the script was successfully loaded and contained exactly 1 notifyScriptLoaded callback.
// The task should be disposed of after use, as it contains references to the script element.
Sys._ScriptLoaderTask = function Sys$_ScriptLoaderTask(scriptElement, completedCallback) {
///
///
///
var e = Function._validateParams(arguments, [
{name: "scriptElement", domElement: true},
{name: "completedCallback", type: Function}
]);
if (e) throw e;
this._scriptElement = scriptElement;
this._completedCallback = completedCallback;
this._notified = 0;
}
function Sys$_ScriptLoaderTask$get_scriptElement() {
///
if (arguments.length !== 0) throw Error.parameterCount();
return this._scriptElement;
}
function Sys$_ScriptLoaderTask$dispose() {
// disposes of the task by removing the load handlers, aborting the window timeout, and releasing the ref to the dom element
if(this._disposed) {
// already disposed
return;
}
this._disposed = true;
this._removeScriptElementHandlers();
// remove script element from DOM
Sys._ScriptLoader._clearScript(this._scriptElement);
this._scriptElement = null;
}
function Sys$_ScriptLoaderTask$execute() {
///
if (arguments.length !== 0) throw Error.parameterCount();
this._addScriptElementHandlers();
document.getElementsByTagName('HEAD')[0].appendChild(this._scriptElement);
}
function Sys$_ScriptLoaderTask$_addScriptElementHandlers() {
// adds the necessary event handlers to the script node to know when it is finished loading
this._scriptLoadDelegate = Function.createDelegate(this, this._scriptLoadHandler);
if (Sys.Browser.agent !== Sys.Browser.InternetExplorer) {
this._scriptElement.readyState = 'loaded';
$addHandler(this._scriptElement, 'load', this._scriptLoadDelegate);
}
else {
$addHandler(this._scriptElement, 'readystatechange', this._scriptLoadDelegate);
}
// FF throws onerror if the script doesn't exist, not loaded.
// DevDev Bugs 86101 -- cant use DomElement.addHandler because it throws for 'error' events.
if (this._scriptElement.addEventListener) {
this._scriptErrorDelegate = Function.createDelegate(this, this._scriptErrorHandler);
this._scriptElement.addEventListener('error', this._scriptErrorDelegate, false);
}
}
function Sys$_ScriptLoaderTask$_removeScriptElementHandlers() {
// removes the load and error handlers from the script element
if(this._scriptLoadDelegate) {
var scriptElement = this.get_scriptElement();
if (Sys.Browser.agent !== Sys.Browser.InternetExplorer) {
$removeHandler(scriptElement, 'load', this._scriptLoadDelegate);
}
else {
$removeHandler(scriptElement, 'readystatechange', this._scriptLoadDelegate);
}
if (this._scriptErrorDelegate) {
// DevDev Bugs 86101 -- cant use DomElement.removeHandler because addHandler throws for 'error' events.
this._scriptElement.removeEventListener('error', this._scriptErrorDelegate, false);
this._scriptErrorDelegate = null;
}
this._scriptLoadDelegate = null;
}
}
function Sys$_ScriptLoaderTask$_scriptErrorHandler() {
// handler for when the script element's error event occurs
if(this._disposed) {
return;
}
// false == did not load successfully (404, etc)
this._completedCallback(this.get_scriptElement(), false);
}
function Sys$_ScriptLoaderTask$_scriptLoadHandler() {
// handler for when the script element's load/readystatechange event occurs
if(this._disposed) {
return;
}
var scriptElement = this.get_scriptElement();
if ((scriptElement.readyState !== 'loaded') &&
(scriptElement.readyState !== 'complete')) {
return;
}
// process the loaded event on a timeout so it is queued behind the task that executes the referenced script.
// Without this, if there is an alert open, the loaded event can occur BEFORE the script itself executes, leading
// us to believe the script did not contain the notify callback when really it just hasn't executed yet.
// The timeout ensures we don't run that logic until after the script has a chance to execute.
var _this = this;
window.setTimeout(function() {
_this._completedCallback(scriptElement, true);
}, 0);
}
Sys._ScriptLoaderTask.prototype = {
get_scriptElement: Sys$_ScriptLoaderTask$get_scriptElement,
dispose: Sys$_ScriptLoaderTask$dispose,
execute: Sys$_ScriptLoaderTask$execute,
_addScriptElementHandlers: Sys$_ScriptLoaderTask$_addScriptElementHandlers,
_removeScriptElementHandlers: Sys$_ScriptLoaderTask$_removeScriptElementHandlers,
_scriptErrorHandler: Sys$_ScriptLoaderTask$_scriptErrorHandler,
_scriptLoadHandler: Sys$_ScriptLoaderTask$_scriptLoadHandler
}
Sys._ScriptLoaderTask.registerClass("Sys._ScriptLoaderTask", null, Sys.IDisposable);
Sys.ApplicationLoadEventArgs = function Sys$ApplicationLoadEventArgs(components, isPartialLoad) {
///
///
///
var e = Function._validateParams(arguments, [
{name: "components", type: Array, elementType: Sys.Component},
{name: "isPartialLoad", type: Boolean}
]);
if (e) throw e;
Sys.ApplicationLoadEventArgs.initializeBase(this);
this._components = components;
this._isPartialLoad = isPartialLoad;
}
function Sys$ApplicationLoadEventArgs$get_components() {
///
if (arguments.length !== 0) throw Error.parameterCount();
return this._components;
}
function Sys$ApplicationLoadEventArgs$get_isPartialLoad() {
///
if (arguments.length !== 0) throw Error.parameterCount();
return this._isPartialLoad;
}
Sys.ApplicationLoadEventArgs.prototype = {
get_components: Sys$ApplicationLoadEventArgs$get_components,
get_isPartialLoad: Sys$ApplicationLoadEventArgs$get_isPartialLoad
}
Sys.ApplicationLoadEventArgs.registerClass('Sys.ApplicationLoadEventArgs', Sys.EventArgs);
Sys._Application = function Sys$_Application() {
Sys._Application.initializeBase(this);
this._disposableObjects = [];
this._components = {};
this._createdComponents = [];
this._secondPassComponents = [];
this._unloadHandlerDelegate = Function.createDelegate(this, this._unloadHandler);
this._loadHandlerDelegate = Function.createDelegate(this, this._loadHandler);
Sys.UI.DomEvent.addHandler(window, "unload", this._unloadHandlerDelegate);
Sys.UI.DomEvent.addHandler(window, "load", this._loadHandlerDelegate);
}
function Sys$_Application$get_isCreatingComponents() {
///
if (arguments.length !== 0) throw Error.parameterCount();
return this._creatingComponents;
}
function Sys$_Application$add_load(handler) {
///
var e = Function._validateParams(arguments, [{name: "handler", type: Function}]);
if (e) throw e;
this.get_events().addHandler("load", handler);
}
function Sys$_Application$remove_load(handler) {
var e = Function._validateParams(arguments, [{name: "handler", type: Function}]);
if (e) throw e;
this.get_events().removeHandler("load", handler);
}
function Sys$_Application$add_init(handler) {
///
var e = Function._validateParams(arguments, [{name: "handler", type: Function}]);
if (e) throw e;
if (this._initialized) {
handler(this, Sys.EventArgs.Empty);
}
else {
this.get_events().addHandler("init", handler);
}
}
function Sys$_Application$remove_init(handler) {
var e = Function._validateParams(arguments, [{name: "handler", type: Function}]);
if (e) throw e;
this.get_events().removeHandler("init", handler);
}
function Sys$_Application$add_unload(handler) {
///
var e = Function._validateParams(arguments, [{name: "handler", type: Function}]);
if (e) throw e;
this.get_events().addHandler("unload", handler);
}
function Sys$_Application$remove_unload(handler) {
var e = Function._validateParams(arguments, [{name: "handler", type: Function}]);
if (e) throw e;
this.get_events().removeHandler("unload", handler);
}
function Sys$_Application$addComponent(component) {
///
///
var e = Function._validateParams(arguments, [
{name: "component", type: Sys.Component}
]);
if (e) throw e;
var id = component.get_id();
if (!id) throw Error.invalidOperation(Sys.Res.cantAddWithoutId);
if (typeof(this._components[id]) !== 'undefined') throw Error.invalidOperation(String.format(Sys.Res.appDuplicateComponent, id));
this._components[id] = component;
}
function Sys$_Application$beginCreateComponents() {
this._creatingComponents = true;
}
function Sys$_Application$dispose() {
if (!this._disposing) {
this._disposing = true;
if (window.pageUnload) {
window.pageUnload(this, Sys.EventArgs.Empty);
}
var unloadHandler = this.get_events().getHandler("unload");
if (unloadHandler) {
unloadHandler(this, Sys.EventArgs.Empty);
}
var disposableObjects = Array.clone(this._disposableObjects);
for (var i = 0, l = disposableObjects.length; i < l; i++) {
disposableObjects[i].dispose();
}
Array.clear(this._disposableObjects);
Sys.UI.DomEvent.removeHandler(window, "unload", this._unloadHandlerDelegate);
if(this._loadHandlerDelegate) {
Sys.UI.DomEvent.removeHandler(window, "load", this._loadHandlerDelegate);
this._loadHandlerDelegate = null;
}
var sl = Sys._ScriptLoader.getInstance();
if(sl) {
sl.dispose();
}
Sys._Application.callBaseMethod(this, 'dispose');
}
}
function Sys$_Application$endCreateComponents() {
var components = this._secondPassComponents;
for (var i = 0, l = components.length; i < l; i++) {
var component = components[i].component;
Sys$Component$_setReferences(component, components[i].references);
component.endUpdate();
}
this._secondPassComponents = [];
this._creatingComponents = false;
}
function Sys$_Application$findComponent(id, parent) {
///
///
///
///
var e = Function._validateParams(arguments, [
{name: "id", type: String},
{name: "parent", mayBeNull: true, optional: true}
]);
if (e) throw e;
// Need to reference the application singleton directly beause the $find alias
// points to the instance function without context. The 'this' pointer won't work here.
return (parent ?
((Sys.IContainer.isInstanceOfType(parent)) ?
parent.findComponent(id) :
parent[id] || null) :
Sys.Application._components[id] || null);
}
function Sys$_Application$getComponents() {
///
///
if (arguments.length !== 0) throw Error.parameterCount();
var res = [];
var components = this._components;
for (var name in components) {
res[res.length] = components[name];
}
return res;
}
function Sys$_Application$initialize() {
if(!this._initialized && !this._initializing) {
this._initializing = true;
// Raise the init events on a timeout so it is queued. This delays the component creation until after the body is
// is ready for use. Without this, if a component adds a dom element to body it will be modifying the body before
// window.onload, which causes an "operation aborted" error in IE. We use this trick for all browsers for consistency.
window.setTimeout(Function.createDelegate(this, this._doInitialize), 0);
}
}
function Sys$_Application$notifyScriptLoaded() {
///
if (arguments.length !== 0) throw Error.parameterCount();
var sl = Sys._ScriptLoader.getInstance();
if(sl) {
sl.notifyScriptLoaded();
}
}
function Sys$_Application$registerDisposableObject(object) {
///
///
var e = Function._validateParams(arguments, [
{name: "object", type: Sys.IDisposable}
]);
if (e) throw e;
if (!this._disposing) {
this._disposableObjects[this._disposableObjects.length] = object;
}
}
function Sys$_Application$raiseLoad() {
var h = this.get_events().getHandler("load");
var args = new Sys.ApplicationLoadEventArgs(Array.clone(this._createdComponents), !this._initializing);
if (h) {
h(this, args);
}
if (window.pageLoad) {
window.pageLoad(this, args);
}
this._createdComponents = [];
}
function Sys$_Application$removeComponent(component) {
///
///
var e = Function._validateParams(arguments, [
{name: "component", type: Sys.Component}
]);
if (e) throw e;
var id = component.get_id();
if (id) delete this._components[id];
}
function Sys$_Application$unregisterDisposableObject(object) {
///
///
var e = Function._validateParams(arguments, [
{name: "object", type: Sys.IDisposable}
]);
if (e) throw e;
if (!this._disposing) {
Array.remove(this._disposableObjects, object);
}
}
function Sys$_Application$_addComponentToSecondPass(component, references) {
this._secondPassComponents[this._secondPassComponents.length] = {component: component, references: references};
}
function Sys$_Application$_doInitialize() {
Sys._Application.callBaseMethod(this, 'initialize');
var handler = this.get_events().getHandler("init");
if (handler) {
this.beginCreateComponents();
handler(this, Sys.EventArgs.Empty);
this.endCreateComponents();
}
this.raiseLoad();
this._initializing = false;
}
function Sys$_Application$_loadHandler() {
// Called from window.onload. Note that the app may already be initialized because SM inlines a call to app.initialize.
// Who ever calls it first, wins.
if(this._loadHandlerDelegate) {
Sys.UI.DomEvent.removeHandler(window, "load", this._loadHandlerDelegate);
this._loadHandlerDelegate = null;
}
this.initialize();
}
function Sys$_Application$_unloadHandler(event) {
this.dispose();
}
Sys._Application.prototype = {
_creatingComponents: false,
_disposing: false,
get_isCreatingComponents: Sys$_Application$get_isCreatingComponents,
add_load: Sys$_Application$add_load,
remove_load: Sys$_Application$remove_load,
add_init: Sys$_Application$add_init,
remove_init: Sys$_Application$remove_init,
add_unload: Sys$_Application$add_unload,
remove_unload: Sys$_Application$remove_unload,
addComponent: Sys$_Application$addComponent,
beginCreateComponents: Sys$_Application$beginCreateComponents,
dispose: Sys$_Application$dispose,
endCreateComponents: Sys$_Application$endCreateComponents,
findComponent: Sys$_Application$findComponent,
getComponents: Sys$_Application$getComponents,
initialize: Sys$_Application$initialize,
notifyScriptLoaded: Sys$_Application$notifyScriptLoaded,
registerDisposableObject: Sys$_Application$registerDisposableObject,
raiseLoad: Sys$_Application$raiseLoad,
removeComponent: Sys$_Application$removeComponent,
unregisterDisposableObject: Sys$_Application$unregisterDisposableObject,
_addComponentToSecondPass: Sys$_Application$_addComponentToSecondPass,
_doInitialize: Sys$_Application$_doInitialize,
_loadHandler: Sys$_Application$_loadHandler,
_unloadHandler: Sys$_Application$_unloadHandler
}
Sys._Application.registerClass('Sys._Application', Sys.Component, Sys.IContainer);
Sys.Application = new Sys._Application();
var $find = Sys.Application.findComponent;
Type.registerNamespace('Sys.Net');
Sys.Net.WebRequestExecutor = function Sys$Net$WebRequestExecutor() {
///
if (arguments.length !== 0) throw Error.parameterCount();
this._webRequest = null;
this._resultObject = null;
}
function Sys$Net$WebRequestExecutor$get_webRequest() {
///
if (arguments.length !== 0) throw Error.parameterCount();
return this._webRequest;
}
function Sys$Net$WebRequestExecutor$_set_webRequest(value) {
if (this.get_started()) {
throw Error.invalidOperation(String.format(Sys.Res.cannotCallOnceStarted, 'set_webRequest'));
}
this._webRequest = value;
}
function Sys$Net$WebRequestExecutor$get_started() {
///
if (arguments.length !== 0) throw Error.parameterCount();
throw Error.notImplemented();
}
function Sys$Net$WebRequestExecutor$get_responseAvailable() {
///
if (arguments.length !== 0) throw Error.parameterCount();
throw Error.notImplemented();
}
function Sys$Net$WebRequestExecutor$get_timedOut() {
///
if (arguments.length !== 0) throw Error.parameterCount();
throw Error.notImplemented();
}
function Sys$Net$WebRequestExecutor$get_aborted() {
///
if (arguments.length !== 0) throw Error.parameterCount();
throw Error.notImplemented();
}
function Sys$Net$WebRequestExecutor$get_responseData() {
///
if (arguments.length !== 0) throw Error.parameterCount();
throw Error.notImplemented();
}
function Sys$Net$WebRequestExecutor$get_statusCode() {
///
if (arguments.length !== 0) throw Error.parameterCount();
throw Error.notImplemented();
}
function Sys$Net$WebRequestExecutor$get_statusText() {
///
if (arguments.length !== 0) throw Error.parameterCount();
throw Error.notImplemented();
}
function Sys$Net$WebRequestExecutor$get_xml() {
///
if (arguments.length !== 0) throw Error.parameterCount();
throw Error.notImplemented();
}
function Sys$Net$WebRequestExecutor$get_object() {
///
if (arguments.length !== 0) throw Error.parameterCount();
if (!this._resultObject) {
this._resultObject = Sys.Serialization.JavaScriptSerializer.deserialize(this.get_responseData());
}
return this._resultObject;
}
function Sys$Net$WebRequestExecutor$executeRequest() {
///
if (arguments.length !== 0) throw Error.parameterCount();
throw Error.notImplemented();
}
function Sys$Net$WebRequestExecutor$abort() {
///
if (arguments.length !== 0) throw Error.parameterCount();
throw Error.notImplemented();
}
function Sys$Net$WebRequestExecutor$getResponseHeader(header) {
///
///
var e = Function._validateParams(arguments, [
{name: "header", type: String}
]);
if (e) throw e;
throw Error.notImplemented();
}
function Sys$Net$WebRequestExecutor$getAllResponseHeaders() {
///
if (arguments.length !== 0) throw Error.parameterCount();
throw Error.notImplemented();
}
Sys.Net.WebRequestExecutor.prototype = {
get_webRequest: Sys$Net$WebRequestExecutor$get_webRequest,
_set_webRequest: Sys$Net$WebRequestExecutor$_set_webRequest,
// properties
get_started: Sys$Net$WebRequestExecutor$get_started,
get_responseAvailable: Sys$Net$WebRequestExecutor$get_responseAvailable,
get_timedOut: Sys$Net$WebRequestExecutor$get_timedOut,
get_aborted: Sys$Net$WebRequestExecutor$get_aborted,
get_responseData: Sys$Net$WebRequestExecutor$get_responseData,
get_statusCode: Sys$Net$WebRequestExecutor$get_statusCode,
get_statusText: Sys$Net$WebRequestExecutor$get_statusText,
get_xml: Sys$Net$WebRequestExecutor$get_xml,
get_object: Sys$Net$WebRequestExecutor$get_object,
// methods
executeRequest: Sys$Net$WebRequestExecutor$executeRequest,
abort: Sys$Net$WebRequestExecutor$abort,
getResponseHeader: Sys$Net$WebRequestExecutor$getResponseHeader,
getAllResponseHeaders: Sys$Net$WebRequestExecutor$getAllResponseHeaders
}
Sys.Net.WebRequestExecutor.registerClass('Sys.Net.WebRequestExecutor');
Sys.Net.XMLDOM = function Sys$Net$XMLDOM(markup) {
if (!window.DOMParser) {
// DevDiv Bugs 150054: Msxml2.DOMDocument (version independent ProgID) required for mobile IE
var progIDs = [ 'Msxml2.DOMDocument.3.0', 'Msxml2.DOMDocument' ];
for (var i = 0, l = progIDs.length; i < l; i++) {
try {
var xmlDOM = new ActiveXObject(progIDs[i]);
xmlDOM.async = false;
xmlDOM.loadXML(markup);
xmlDOM.setProperty('SelectionLanguage', 'XPath');
return xmlDOM;
}
catch (ex) {
}
}
}
else {
// Mozilla browsers have a DOMParser
try {
var domParser = new window.DOMParser();
return domParser.parseFromString(markup, 'text/xml');
}
catch (ex) {
}
}
return null;
}
Sys.Net.XMLHttpExecutor = function Sys$Net$XMLHttpExecutor() {
///
if (arguments.length !== 0) throw Error.parameterCount();
Sys.Net.XMLHttpExecutor.initializeBase(this);
var _this = this;
this._xmlHttpRequest = null;
this._webRequest = null;
this._responseAvailable = false;
this._timedOut = false;
this._timer = null;
this._aborted = false;
this._started = false;
this._onReadyStateChange = function this$_onReadyStateChange() {
/*
readyState values:
0 = uninitialized
1 = loading
2 = loaded
3 = interactive
4 = complete
*/
if (_this._xmlHttpRequest.readyState === 4 /*complete*/) {
// DevDiv 58581:
// When a request is pending when the page is closed (navigated away, postback, etc)
// in FF and Safari, the request is aborted just as if abort() was called on the
// xmlhttprequest object.
// However, even aborted requests have a readyState of 4, which we treat as successful.
// This happened for example if a regular postback occurred during a partial update request.
// In FF if you access the 'status' field on an aborted request, an error is thrown,
// so the error console displayed an error when this happened.
// On Safari it isn't an error, but status is undefined. That caused PRM to get the completed
// event, and since the status is not 200, it raises an error.
// IE and Opera ignore pending requests, or their readyState isn't 4.
try {
if (typeof(_this._xmlHttpRequest.status) === "undefined") {
// its an aborted request in Safari, ignore it
return;
}
}
catch(ex) {
// its an aborted request in Firefox, ignore it
return;
}
_this._clearTimer();
_this._responseAvailable = true;
_this._webRequest.completed(Sys.EventArgs.Empty);
if (_this._xmlHttpRequest != null) {
_this._xmlHttpRequest.onreadystatechange = Function.emptyMethod;
_this._xmlHttpRequest = null;
}
}
}
this._clearTimer = function this$_clearTimer() {
if (_this._timer != null) {
window.clearTimeout(_this._timer);
_this._timer = null;
}
}
this._onTimeout = function this$_onTimeout() {
if (!_this._responseAvailable) {
_this._clearTimer();
_this._timedOut = true;
_this._xmlHttpRequest.onreadystatechange = Function.emptyMethod;
_this._xmlHttpRequest.abort();
_this._webRequest.completed(Sys.EventArgs.Empty);
_this._xmlHttpRequest = null;
}
}
}
function Sys$Net$XMLHttpExecutor$get_timedOut() {
///
if (arguments.length !== 0) throw Error.parameterCount();
return this._timedOut;
}
function Sys$Net$XMLHttpExecutor$get_started() {
///
if (arguments.length !== 0) throw Error.parameterCount();
return this._started;
}
function Sys$Net$XMLHttpExecutor$get_responseAvailable() {
///
if (arguments.length !== 0) throw Error.parameterCount();
return this._responseAvailable;
}
function Sys$Net$XMLHttpExecutor$get_aborted() {
///
if (arguments.length !== 0) throw Error.parameterCount();
return this._aborted;
}
function Sys$Net$XMLHttpExecutor$executeRequest() {
///
if (arguments.length !== 0) throw Error.parameterCount();
this._webRequest = this.get_webRequest();
if (this._started) {
throw Error.invalidOperation(String.format(Sys.Res.cannotCallOnceStarted, 'executeRequest'));
}
if (this._webRequest === null) {
throw Error.invalidOperation(Sys.Res.nullWebRequest);
}
var body = this._webRequest.get_body();
var headers = this._webRequest.get_headers();
this._xmlHttpRequest = new XMLHttpRequest();
this._xmlHttpRequest.onreadystatechange = this._onReadyStateChange;
var verb = this._webRequest.get_httpVerb();
this._xmlHttpRequest.open(verb, this._webRequest.getResolvedUrl(), true /*async*/);
if (headers) {
for (var header in headers) {
var val = headers[header];
if (typeof(val) !== "function")
this._xmlHttpRequest.setRequestHeader(header, val);
}
}
if (verb.toLowerCase() === "post") {
// If it's a POST but no Content-Type was specified, default to application/x-www-form-urlencoded; charset=utf-8
if ((headers === null) || !headers['Content-Type']) {
// DevDiv 109456: Include charset=utf-8. Javascript encoding methods always use utf-8, server may be set to assume other encoding.
this._xmlHttpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8');
}
// DevDiv 15893: If POST with no body, default to ""(FireFox needs this)
if (!body) {
body = "";
}
}
var timeout = this._webRequest.get_timeout();
if (timeout > 0) {
this._timer = window.setTimeout(Function.createDelegate(this, this._onTimeout), timeout);
}
this._xmlHttpRequest.send(body);
this._started = true;
}
function Sys$Net$XMLHttpExecutor$getResponseHeader(header) {
///
///
///
var e = Function._validateParams(arguments, [
{name: "header", type: String}
]);
if (e) throw e;
if (!this._responseAvailable) {
throw Error.invalidOperation(String.format(Sys.Res.cannotCallBeforeResponse, 'getResponseHeader'));
}
if (!this._xmlHttpRequest) {
throw Error.invalidOperation(String.format(Sys.Res.cannotCallOutsideHandler, 'getResponseHeader'));
}
var result;
try {
result = this._xmlHttpRequest.getResponseHeader(header);
} catch (e) {
}
if (!result) result = "";
return result;
}
function Sys$Net$XMLHttpExecutor$getAllResponseHeaders() {
///
///
if (arguments.length !== 0) throw Error.parameterCount();
if (!this._responseAvailable) {
throw Error.invalidOperation(String.format(Sys.Res.cannotCallBeforeResponse, 'getAllResponseHeaders'));
}
if (!this._xmlHttpRequest) {
throw Error.invalidOperation(String.format(Sys.Res.cannotCallOutsideHandler, 'getAllResponseHeaders'));
}
return this._xmlHttpRequest.getAllResponseHeaders();
}
function Sys$Net$XMLHttpExecutor$get_responseData() {
///
if (arguments.length !== 0) throw Error.parameterCount();
if (!this._responseAvailable) {
throw Error.invalidOperation(String.format(Sys.Res.cannotCallBeforeResponse, 'get_responseData'));
}
if (!this._xmlHttpRequest) {
throw Error.invalidOperation(String.format(Sys.Res.cannotCallOutsideHandler, 'get_responseData'));
}
return this._xmlHttpRequest.responseText;
}
function Sys$Net$XMLHttpExecutor$get_statusCode() {
///
if (arguments.length !== 0) throw Error.parameterCount();
if (!this._responseAvailable) {
throw Error.invalidOperation(String.format(Sys.Res.cannotCallBeforeResponse, 'get_statusCode'));
}
if (!this._xmlHttpRequest) {
throw Error.invalidOperation(String.format(Sys.Res.cannotCallOutsideHandler, 'get_statusCode'));
}
var result = 0;
try {
result = this._xmlHttpRequest.status;
}
catch(ex) {
}
return result;
}
function Sys$Net$XMLHttpExecutor$get_statusText() {
///
if (arguments.length !== 0) throw Error.parameterCount();
if (!this._responseAvailable) {
throw Error.invalidOperation(String.format(Sys.Res.cannotCallBeforeResponse, 'get_statusText'));
}
if (!this._xmlHttpRequest) {
throw Error.invalidOperation(String.format(Sys.Res.cannotCallOutsideHandler, 'get_statusText'));
}
return this._xmlHttpRequest.statusText;
}
function Sys$Net$XMLHttpExecutor$get_xml() {
///
if (arguments.length !== 0) throw Error.parameterCount();
if (!this._responseAvailable) {
throw Error.invalidOperation(String.format(Sys.Res.cannotCallBeforeResponse, 'get_xml'));
}
if (!this._xmlHttpRequest) {
throw Error.invalidOperation(String.format(Sys.Res.cannotCallOutsideHandler, 'get_xml'));
}
var xml = this._xmlHttpRequest.responseXML;
if (!xml || !xml.documentElement) {
// This happens if the server doesn't set the content type to text/xml.
xml = Sys.Net.XMLDOM(this._xmlHttpRequest.responseText);
// If we still couldn't get an XML DOM, the data is probably not XML
if (!xml || !xml.documentElement)
return null;
}
// REVIEW: todo this used to use Sys.Runtime get_hostType
else if (navigator.userAgent.indexOf('MSIE') !== -1) {
xml.setProperty('SelectionLanguage', 'XPath');
}
// For Firefox parser errors have document elements of parser error
if (xml.documentElement.namespaceURI === "http://www.mozilla.org/newlayout/xml/parsererror.xml" &&
xml.documentElement.tagName === "parsererror") {
return null;
}
// For Safari, parser errors are always the first child of the root
if (xml.documentElement.firstChild && xml.documentElement.firstChild.tagName === "parsererror") {
return null;
}
return xml;
}
function Sys$Net$XMLHttpExecutor$abort() {
///
if (arguments.length !== 0) throw Error.parameterCount();
if (!this._started) {
throw Error.invalidOperation(Sys.Res.cannotAbortBeforeStart);
}
// aborts are no ops if we are done, timedout, or aborted already
if (this._aborted || this._responseAvailable || this._timedOut)
return;
this._aborted = true;
this._clearTimer();
if (this._xmlHttpRequest && !this._responseAvailable) {
// Remove the onreadystatechange first otherwise abort would trigger readyState to become 4
this._xmlHttpRequest.onreadystatechange = Function.emptyMethod;
this._xmlHttpRequest.abort();
this._xmlHttpRequest = null;
// DevDiv 59229: Call completed on the request instead of raising the event directly
this._webRequest.completed(Sys.EventArgs.Empty);
}
}
Sys.Net.XMLHttpExecutor.prototype = {
get_timedOut: Sys$Net$XMLHttpExecutor$get_timedOut,
get_started: Sys$Net$XMLHttpExecutor$get_started,
get_responseAvailable: Sys$Net$XMLHttpExecutor$get_responseAvailable,
get_aborted: Sys$Net$XMLHttpExecutor$get_aborted,
executeRequest: Sys$Net$XMLHttpExecutor$executeRequest,
getResponseHeader: Sys$Net$XMLHttpExecutor$getResponseHeader,
getAllResponseHeaders: Sys$Net$XMLHttpExecutor$getAllResponseHeaders,
get_responseData: Sys$Net$XMLHttpExecutor$get_responseData,
get_statusCode: Sys$Net$XMLHttpExecutor$get_statusCode,
get_statusText: Sys$Net$XMLHttpExecutor$get_statusText,
get_xml: Sys$Net$XMLHttpExecutor$get_xml,
abort: Sys$Net$XMLHttpExecutor$abort
}
Sys.Net.XMLHttpExecutor.registerClass('Sys.Net.XMLHttpExecutor', Sys.Net.WebRequestExecutor);
Sys.Net._WebRequestManager = function Sys$Net$_WebRequestManager() {
this._this = this;
this._defaultTimeout = 0;
this._defaultExecutorType = "Sys.Net.XMLHttpExecutor";
}
function Sys$Net$_WebRequestManager$add_invokingRequest(handler) {
///
var e = Function._validateParams(arguments, [{name: "handler", type: Function}]);
if (e) throw e;
this._get_eventHandlerList().addHandler("invokingRequest", handler);
}
function Sys$Net$_WebRequestManager$remove_invokingRequest(handler) {
var e = Function._validateParams(arguments, [{name: "handler", type: Function}]);
if (e) throw e;
this._get_eventHandlerList().removeHandler("invokingRequest", handler);
}
function Sys$Net$_WebRequestManager$add_completedRequest(handler) {
///
var e = Function._validateParams(arguments, [{name: "handler", type: Function}]);
if (e) throw e;
this._get_eventHandlerList().addHandler("completedRequest", handler);
}
function Sys$Net$_WebRequestManager$remove_completedRequest(handler) {
var e = Function._validateParams(arguments, [{name: "handler", type: Function}]);
if (e) throw e;
this._get_eventHandlerList().removeHandler("completedRequest", handler);
}
function Sys$Net$_WebRequestManager$_get_eventHandlerList() {
if (!this._events) {
this._events = new Sys.EventHandlerList();
}
return this._events;
}
function Sys$Net$_WebRequestManager$get_defaultTimeout() {
///
if (arguments.length !== 0) throw Error.parameterCount();
return this._defaultTimeout;
}
function Sys$Net$_WebRequestManager$set_defaultTimeout(value) {
var e = Function._validateParams(arguments, [{name: "value", type: Number}]);
if (e) throw e;
if (value < 0) {
throw Error.argumentOutOfRange("value", value, Sys.Res.invalidTimeout);
}
this._defaultTimeout = value;
}
function Sys$Net$_WebRequestManager$get_defaultExecutorType() {
///
if (arguments.length !== 0) throw Error.parameterCount();
return this._defaultExecutorType;
}
function Sys$Net$_WebRequestManager$set_defaultExecutorType(value) {
var e = Function._validateParams(arguments, [{name: "value", type: String}]);
if (e) throw e;
this._defaultExecutorType = value;
}
function Sys$Net$_WebRequestManager$executeRequest(webRequest) {
///
///
var e = Function._validateParams(arguments, [
{name: "webRequest", type: Sys.Net.WebRequest}
]);
if (e) throw e;
var executor = webRequest.get_executor();
// if the request didn't set an executor, use the request manager default executor
if (!executor) {
// TODO: Optimize this by caching the type
var failed = false;
try {
var executorType = eval(this._defaultExecutorType);
executor = new executorType();
} catch (e) {
failed = true;
}
if (failed || !Sys.Net.WebRequestExecutor.isInstanceOfType(executor) || !executor) {
throw Error.argument("defaultExecutorType", String.format(Sys.Res.invalidExecutorType, this._defaultExecutorType));
}
webRequest.set_executor(executor);
}
// skip the request if it has been aborted;
if (executor.get_aborted()) {
return;
}
var evArgs = new Sys.Net.NetworkRequestEventArgs(webRequest);
var handler = this._get_eventHandlerList().getHandler("invokingRequest");
if (handler) {
handler(this, evArgs);
}
if (!evArgs.get_cancel()) {
executor.executeRequest();
}
}
Sys.Net._WebRequestManager.prototype = {
add_invokingRequest: Sys$Net$_WebRequestManager$add_invokingRequest,
remove_invokingRequest: Sys$Net$_WebRequestManager$remove_invokingRequest,
add_completedRequest: Sys$Net$_WebRequestManager$add_completedRequest,
remove_completedRequest: Sys$Net$_WebRequestManager$remove_completedRequest,
_get_eventHandlerList: Sys$Net$_WebRequestManager$_get_eventHandlerList,
get_defaultTimeout: Sys$Net$_WebRequestManager$get_defaultTimeout,
set_defaultTimeout: Sys$Net$_WebRequestManager$set_defaultTimeout,
get_defaultExecutorType: Sys$Net$_WebRequestManager$get_defaultExecutorType,
set_defaultExecutorType: Sys$Net$_WebRequestManager$set_defaultExecutorType,
executeRequest: Sys$Net$_WebRequestManager$executeRequest
}
Sys.Net._WebRequestManager.registerClass('Sys.Net._WebRequestManager');
// Create a single instance of the class
Sys.Net.WebRequestManager = new Sys.Net._WebRequestManager();
Sys.Net.NetworkRequestEventArgs = function Sys$Net$NetworkRequestEventArgs(webRequest) {
///
///
var e = Function._validateParams(arguments, [
{name: "webRequest", type: Sys.Net.WebRequest}
]);
if (e) throw e;
Sys.Net.NetworkRequestEventArgs.initializeBase(this);
this._webRequest = webRequest;
}
function Sys$Net$NetworkRequestEventArgs$get_webRequest() {
///
if (arguments.length !== 0) throw Error.parameterCount();
return this._webRequest;
}
Sys.Net.NetworkRequestEventArgs.prototype = {
get_webRequest: Sys$Net$NetworkRequestEventArgs$get_webRequest
}
Sys.Net.NetworkRequestEventArgs.registerClass('Sys.Net.NetworkRequestEventArgs', Sys.CancelEventArgs);
Sys.Net.WebRequest = function Sys$Net$WebRequest() {
///
if (arguments.length !== 0) throw Error.parameterCount();
this._url = "";
this._headers = { };
this._body = null;
this._userContext = null;
this._httpVerb = null;
this._executor = null;
this._invokeCalled = false;
this._timeout = 0;
}
// Properties about the request data
function Sys$Net$WebRequest$add_completed(handler) {
///
var e = Function._validateParams(arguments, [{name: "handler", type: Function}]);
if (e) throw e;
this._get_eventHandlerList().addHandler("completed", handler);
}
function Sys$Net$WebRequest$remove_completed(handler) {
var e = Function._validateParams(arguments, [{name: "handler", type: Function}]);
if (e) throw e;
this._get_eventHandlerList().removeHandler("completed", handler);
}
function Sys$Net$WebRequest$completed(eventArgs) {
///
///
var e = Function._validateParams(arguments, [
{name: "eventArgs", type: Sys.EventArgs}
]);
if (e) throw e;
var handler = Sys.Net.WebRequestManager._get_eventHandlerList().getHandler("completedRequest");
if (handler) {
handler(this._executor, eventArgs);
}
handler = this._get_eventHandlerList().getHandler("completed");
if (handler) {
handler(this._executor, eventArgs);
}
}
function Sys$Net$WebRequest$_get_eventHandlerList() {
if (!this._events) {
this._events = new Sys.EventHandlerList();
}
return this._events;
}
function Sys$Net$WebRequest$get_url() {
///
if (arguments.length !== 0) throw Error.parameterCount();
return this._url;
}
function Sys$Net$WebRequest$set_url(value) {
var e = Function._validateParams(arguments, [{name: "value", type: String}]);
if (e) throw e;
this._url = value;
}
function Sys$Net$WebRequest$get_headers() {
///
if (arguments.length !== 0) throw Error.parameterCount();
return this._headers;
}
function Sys$Net$WebRequest$get_httpVerb() {
///
if (arguments.length !== 0) throw Error.parameterCount();
// Default is GET if no body, and POST otherwise
if (this._httpVerb === null) {
if (this._body === null) {
return "GET";
}
return "POST";
}
return this._httpVerb;
}
function Sys$Net$WebRequest$set_httpVerb(value) {
var e = Function._validateParams(arguments, [{name: "value", type: String}]);
if (e) throw e;
if (value.length === 0) {
throw Error.argument('value', Sys.Res.invalidHttpVerb);
}
this._httpVerb = value;
}
function Sys$Net$WebRequest$get_body() {
///
if (arguments.length !== 0) throw Error.parameterCount();
return this._body;
}
function Sys$Net$WebRequest$set_body(value) {
var e = Function._validateParams(arguments, [{name: "value", mayBeNull: true}]);
if (e) throw e;
this._body = value;
}
function Sys$Net$WebRequest$get_userContext() {
///
if (arguments.length !== 0) throw Error.parameterCount();
return this._userContext;
}
function Sys$Net$WebRequest$set_userContext(value) {
var e = Function._validateParams(arguments, [{name: "value", mayBeNull: true}]);
if (e) throw e;
this._userContext = value;
}
function Sys$Net$WebRequest$get_executor() {
///
if (arguments.length !== 0) throw Error.parameterCount();
return this._executor;
}
function Sys$Net$WebRequest$set_executor(value) {
var e = Function._validateParams(arguments, [{name: "value", type: Sys.Net.WebRequestExecutor}]);
if (e) throw e;
if (this._executor !== null && this._executor.get_started()) {
throw Error.invalidOperation(Sys.Res.setExecutorAfterActive);
}
this._executor = value;
this._executor._set_webRequest(this);
}
function Sys$Net$WebRequest$get_timeout() {
///
if (arguments.length !== 0) throw Error.parameterCount();
if (this._timeout === 0) {
return Sys.Net.WebRequestManager.get_defaultTimeout();
}
return this._timeout;
}
function Sys$Net$WebRequest$set_timeout(value) {
var e = Function._validateParams(arguments, [{name: "value", type: Number}]);
if (e) throw e;
if (value < 0) {
throw Error.argumentOutOfRange("value", value, Sys.Res.invalidTimeout);
}
this._timeout = value;
}
function Sys$Net$WebRequest$getResolvedUrl() {
///
///
if (arguments.length !== 0) throw Error.parameterCount();
return Sys.Net.WebRequest._resolveUrl(this._url);
}
function Sys$Net$WebRequest$invoke() {
///
if (arguments.length !== 0) throw Error.parameterCount();
if (this._invokeCalled) {
throw Error.invalidOperation(Sys.Res.invokeCalledTwice);
}
Sys.Net.WebRequestManager.executeRequest(this);
this._invokeCalled = true;
}
Sys.Net.WebRequest.prototype = {
add_completed: Sys$Net$WebRequest$add_completed,
remove_completed: Sys$Net$WebRequest$remove_completed,
completed: Sys$Net$WebRequest$completed,
_get_eventHandlerList: Sys$Net$WebRequest$_get_eventHandlerList,
get_url: Sys$Net$WebRequest$get_url,
set_url: Sys$Net$WebRequest$set_url,
get_headers: Sys$Net$WebRequest$get_headers,
get_httpVerb: Sys$Net$WebRequest$get_httpVerb,
set_httpVerb: Sys$Net$WebRequest$set_httpVerb,
get_body: Sys$Net$WebRequest$get_body,
set_body: Sys$Net$WebRequest$set_body,
get_userContext: Sys$Net$WebRequest$get_userContext,
set_userContext: Sys$Net$WebRequest$set_userContext,
get_executor: Sys$Net$WebRequest$get_executor,
set_executor: Sys$Net$WebRequest$set_executor,
get_timeout: Sys$Net$WebRequest$get_timeout,
set_timeout: Sys$Net$WebRequest$set_timeout,
getResolvedUrl: Sys$Net$WebRequest$getResolvedUrl,
invoke: Sys$Net$WebRequest$invoke
}
// Given a url and an optional base url, return an absolute url combining the url and base url
Sys.Net.WebRequest._resolveUrl = function Sys$Net$WebRequest$_resolveUrl(url, baseUrl) {
// If the url contains a host, we are done
if (url && url.indexOf('://') !== -1) {
return url;
}
// If a base url isn't passed in, we use either the base element if specified or the URL from the browser
if (!baseUrl || baseUrl.length === 0) {
var baseElement = document.getElementsByTagName('base')[0];
if (baseElement && baseElement.href && baseElement.href.length > 0) {
baseUrl = baseElement.href;
}
else {
baseUrl = document.URL;
}
}
// strip off any querystrings
var qsStart = baseUrl.indexOf('?');
if (qsStart !== -1) {
baseUrl = baseUrl.substr(0, qsStart);
}
baseUrl = baseUrl.substr(0, baseUrl.lastIndexOf('/') + 1);
// If a url wasn't specified, we just use the base
if (!url || url.length === 0) {
return baseUrl;
}
// For absolute path url, we need to rebase it against the base url, stripping off everything after the http://host
if (url.charAt(0) === '/') {
var slashslash = baseUrl.indexOf('://');
if (slashslash === -1) {
throw Error.argument("baseUrl", Sys.Res.badBaseUrl1);
}
var nextSlash = baseUrl.indexOf('/', slashslash + 3);
if (nextSlash === -1) {
throw Error.argument("baseUrl", Sys.Res.badBaseUrl2);
}
return baseUrl.substr(0, nextSlash) + url;
}
// Otherwise for relative urls we just combine with the base url stripping off the last path component (filename typically)
// Note the app path always contains a trailing slash so when resolving app paths, we never strip off anything important
else {
var lastSlash = baseUrl.lastIndexOf('/');
if (lastSlash === -1) {
throw Error.argument("baseUrl", Sys.Res.badBaseUrl3);
}
return baseUrl.substr(0, lastSlash+1) + url;
}
}
Sys.Net.WebRequest._createQueryString = function Sys$Net$WebRequest$_createQueryString(queryString, encodeMethod) {
// By default, use URI encoding
if (!encodeMethod)
encodeMethod = encodeURIComponent;
var sb = new Sys.StringBuilder();
var i = 0;
for (var arg in queryString) {
var obj = queryString[arg];
if (typeof(obj) === "function") continue;
var val = Sys.Serialization.JavaScriptSerializer.serialize(obj);
if (i !== 0) {
sb.append('&');
}
sb.append(arg);
sb.append('=');
sb.append(encodeMethod(val));
i++;
}
return sb.toString();
}
Sys.Net.WebRequest._createUrl = function Sys$Net$WebRequest$_createUrl(url, queryString) {
if (!queryString) {
return url;
}
var qs = Sys.Net.WebRequest._createQueryString(queryString);
if (qs.length > 0) {
var sep = '?';
if (url && url.indexOf('?') !== -1)
sep = '&';
return url + sep + qs;
} else {
return url;
}
}
Sys.Net.WebRequest.registerClass('Sys.Net.WebRequest');
Sys.Net.WebServiceProxy = function Sys$Net$WebServiceProxy() {
}
function Sys$Net$WebServiceProxy$get_timeout() {
///
if (arguments.length !== 0) throw Error.parameterCount();
return this._timeout;
}
function Sys$Net$WebServiceProxy$set_timeout(value) {
var e = Function._validateParams(arguments, [{name: "value", type: Number}]);
if (e) throw e;
if (value < 0) { throw Error.argumentOutOfRange('value', value, Sys.Res.invalidTimeout); }
this._timeout = value;
}
function Sys$Net$WebServiceProxy$get_defaultUserContext() {
///
if (arguments.length !== 0) throw Error.parameterCount();
return this._userContext;
}
function Sys$Net$WebServiceProxy$set_defaultUserContext(value) {
var e = Function._validateParams(arguments, [{name: "value", mayBeNull: true}]);
if (e) throw e;
this._userContext = value;
}
function Sys$Net$WebServiceProxy$get_defaultSucceededCallback() {
///
if (arguments.length !== 0) throw Error.parameterCount();
return this._succeeded;
}
function Sys$Net$WebServiceProxy$set_defaultSucceededCallback(value) {
var e = Function._validateParams(arguments, [{name: "value", type: Function, mayBeNull: true}]);
if (e) throw e;
this._succeeded = value;
}
function Sys$Net$WebServiceProxy$get_defaultFailedCallback() {
///
if (arguments.length !== 0) throw Error.parameterCount();
return this._failed;
}
function Sys$Net$WebServiceProxy$set_defaultFailedCallback(value) {
var e = Function._validateParams(arguments, [{name: "value", type: Function, mayBeNull: true}]);
if (e) throw e;
this._failed = value;
}
function Sys$Net$WebServiceProxy$get_path() {
///
if (arguments.length !== 0) throw Error.parameterCount();
return this._path;
}
function Sys$Net$WebServiceProxy$set_path(value) {
var e = Function._validateParams(arguments, [{name: "value", type: String}]);
if (e) throw e;
this._path = value;
}
function Sys$Net$WebServiceProxy$_invoke(servicePath, methodName, useGet, params, onSuccess, onFailure, userContext) {
///
///
///
///
///
///
///
///
///
var e = Function._validateParams(arguments, [
{name: "servicePath", type: String},
{name: "methodName", type: String},
{name: "useGet", type: Boolean},
{name: "params"},
{name: "onSuccess", type: Function, mayBeNull: true, optional: true},
{name: "onFailure", type: Function, mayBeNull: true, optional: true},
{name: "userContext", mayBeNull: true, optional: true}
]);
if (e) throw e;
// Resolve against the defaults callbacks/context
if (onSuccess === null || typeof onSuccess === 'undefined') onSuccess = this.get_defaultSucceededCallback();
if (onFailure === null || typeof onFailure === 'undefined') onFailure = this.get_defaultFailedCallback();
if (userContext === null || typeof userContext === 'undefined') userContext = this.get_defaultUserContext();
return Sys.Net.WebServiceProxy.invoke(servicePath, methodName, useGet, params, onSuccess, onFailure, userContext, this.get_timeout());
}
Sys.Net.WebServiceProxy.prototype = {
get_timeout: Sys$Net$WebServiceProxy$get_timeout,
set_timeout: Sys$Net$WebServiceProxy$set_timeout,
get_defaultUserContext: Sys$Net$WebServiceProxy$get_defaultUserContext,
set_defaultUserContext: Sys$Net$WebServiceProxy$set_defaultUserContext,
get_defaultSucceededCallback: Sys$Net$WebServiceProxy$get_defaultSucceededCallback,
set_defaultSucceededCallback: Sys$Net$WebServiceProxy$set_defaultSucceededCallback,
get_defaultFailedCallback: Sys$Net$WebServiceProxy$get_defaultFailedCallback,
set_defaultFailedCallback: Sys$Net$WebServiceProxy$set_defaultFailedCallback,
get_path: Sys$Net$WebServiceProxy$get_path,
set_path: Sys$Net$WebServiceProxy$set_path,
_invoke: Sys$Net$WebServiceProxy$_invoke
}
Sys.Net.WebServiceProxy.registerClass('Sys.Net.WebServiceProxy');
Sys.Net.WebServiceProxy.invoke = function Sys$Net$WebServiceProxy$invoke(servicePath, methodName, useGet, params, onSuccess, onFailure, userContext, timeout) {
///
///
///
///
///
///
///
///
///
///
var e = Function._validateParams(arguments, [
{name: "servicePath", type: String},
{name: "methodName", type: String},
{name: "useGet", type: Boolean, optional: true},
{name: "params", mayBeNull: true, optional: true},
{name: "onSuccess", type: Function, mayBeNull: true, optional: true},
{name: "onFailure", type: Function, mayBeNull: true, optional: true},
{name: "userContext", mayBeNull: true, optional: true},
{name: "timeout", type: Number, optional: true}
]);
if (e) throw e;
// Create a web request to make the method call
var request = new Sys.Net.WebRequest();
request.get_headers()['Content-Type'] = 'application/json; charset=utf-8';
if (!params) params = {};
var urlParams = params;
// If using POST, or we don't have any paramaters, start with a blank dictionary
if (!useGet || !urlParams) urlParams = {};
request.set_url(Sys.Net.WebRequest._createUrl(servicePath+"/"+encodeURIComponent(methodName), urlParams));
var body = null;
// No body when using GET
if (!useGet) {
body = Sys.Serialization.JavaScriptSerializer.serialize(params);
// If there are no parameters, send an empty body (though it will still be a POST)
if (body === "{}") body = "";
}
// Put together the body as a JSON string
request.set_body(body);
request.add_completed(onComplete);
if (timeout && timeout > 0) request.set_timeout(timeout);
request.invoke();
function onComplete(response, eventArgs) {
if (response.get_responseAvailable()) {
var statusCode = response.get_statusCode();
var result = null;
try {
var contentType = response.getResponseHeader("Content-Type");
if (contentType.startsWith("application/json")) {
result = response.get_object();
}
else if (contentType.startsWith("text/xml")) {
result = response.get_xml();
}
// Default to the response text
else {
result = response.get_responseData();
}
} catch (ex) {
}
var error = response.getResponseHeader("jsonerror");
var errorObj = (error === "true");
if (errorObj) {
if (result) {
result = new Sys.Net.WebServiceError(false, result.Message, result.StackTrace, result.ExceptionType);
}
}
else if (contentType.startsWith("application/json")) {
//DevDiv 88409: Change JSON wire format to prevent CSRF attack
//The return value is wrapped inside an object with , 'd' field set to return value
if (!result || typeof(result.d) === "undefined") {
throw Sys.Net.WebServiceProxy._createFailedError(methodName, String.format(Sys.Res.webServiceInvalidJsonWrapper, methodName));
}
result = result.d;
}
if (((statusCode < 200) || (statusCode >= 300)) || errorObj) {
if (onFailure) {
if (!result || !errorObj) {
result = new Sys.Net.WebServiceError(false /*timedout*/, String.format(Sys.Res.webServiceFailedNoMsg, methodName), "", "");
}
result._statusCode = statusCode;
onFailure(result, userContext, methodName);
}
else {
// In debug mode, if no error was registered, display some trace information
var error;
if (result && errorObj) {
// If we got a result, we're likely dealing with an error in the method itself
error = result.get_exceptionType() + "-- " + result.get_message();
}
else {
// Otherwise, it's probably a 'top-level' error, in which case we dump the
// whole response in the trace
error = response.get_responseData();
}
// DevDiv 89485: throw, not alert()
throw Sys.Net.WebServiceProxy._createFailedError(methodName, String.format(Sys.Res.webServiceFailed, methodName, error));
}
}
else if (onSuccess) {
onSuccess(result, userContext, methodName);
}
}
else {
var msg;
if (response.get_timedOut()) {
msg = String.format(Sys.Res.webServiceTimedOut, methodName);
}
else {
msg = String.format(Sys.Res.webServiceFailedNoMsg, methodName)
}
if (onFailure) {
onFailure(new Sys.Net.WebServiceError(response.get_timedOut(), msg, "", ""), userContext, methodName);
}
else {
// In debug mode, if no error was registered, display some trace information
// DevDiv 89485: throw, don't alert()
throw Sys.Net.WebServiceProxy._createFailedError(methodName, msg);
}
}
}
return request;
}
Sys.Net.WebServiceProxy._createFailedError = function Sys$Net$WebServiceProxy$_createFailedError(methodName, errorMessage) {
var displayMessage = "Sys.Net.WebServiceFailedException: " + errorMessage;
var e = Error.create(displayMessage, { 'name': 'Sys.Net.WebServiceFailedException', 'methodName': methodName });
e.popStackFrame();
return e;
}
Sys.Net.WebServiceProxy._defaultFailedCallback = function Sys$Net$WebServiceProxy$_defaultFailedCallback(err, methodName) {
var error = err.get_exceptionType() + "-- " + err.get_message();
throw Sys.Net.WebServiceProxy._createFailedError(methodName, String.format(Sys.Res.webServiceFailed, methodName, error));
}
// Generate a constructor that knows how to build objects of a particular server type,
// and then initialize it from the fields of an arbitrary object.
Sys.Net.WebServiceProxy._generateTypedConstructor = function Sys$Net$WebServiceProxy$_generateTypedConstructor(type) {
return function(properties) {
// If an object was passed in, copy all its fields
if (properties) {
for (var name in properties) {
this[name] = properties[name];
}
}
this.__type = type;
}
}
// Class returned to client if server throws an exception during ProcessRequest
Sys.Net.WebServiceError = function Sys$Net$WebServiceError(timedOut, message, stackTrace, exceptionType) {
///
///
///
///
///
var e = Function._validateParams(arguments, [
{name: "timedOut", type: Boolean},
{name: "message", type: String, mayBeNull: true},
{name: "stackTrace", type: String, mayBeNull: true},
{name: "exceptionType", type: String, mayBeNull: true}
]);
if (e) throw e;
this._timedOut = timedOut;
this._message = message;
this._stackTrace = stackTrace;
this._exceptionType = exceptionType;
this._statusCode = -1;
}
function Sys$Net$WebServiceError$get_timedOut() {
///
if (arguments.length !== 0) throw Error.parameterCount();
return this._timedOut;
}
function Sys$Net$WebServiceError$get_statusCode() {
///
if (arguments.length !== 0) throw Error.parameterCount();
return this._statusCode;
}
function Sys$Net$WebServiceError$get_message() {
///
if (arguments.length !== 0) throw Error.parameterCount();
return this._message;
}
function Sys$Net$WebServiceError$get_stackTrace() {
///
if (arguments.length !== 0) throw Error.parameterCount();
return this._stackTrace;
}
function Sys$Net$WebServiceError$get_exceptionType() {
///
if (arguments.length !== 0) throw Error.parameterCount();
return this._exceptionType;
}
Sys.Net.WebServiceError.prototype = {
get_timedOut: Sys$Net$WebServiceError$get_timedOut,
get_statusCode: Sys$Net$WebServiceError$get_statusCode,
get_message: Sys$Net$WebServiceError$get_message,
get_stackTrace: Sys$Net$WebServiceError$get_stackTrace,
get_exceptionType: Sys$Net$WebServiceError$get_exceptionType
}
Sys.Net.WebServiceError.registerClass('Sys.Net.WebServiceError');
Type.registerNamespace('Sys.Services');
Sys.Services._ProfileService = function Sys$Services$_ProfileService() {
Sys.Services._ProfileService.initializeBase(this);
this.properties = {};
}
Sys.Services._ProfileService.DefaultWebServicePath = '';
function Sys$Services$_ProfileService$get_defaultLoadCompletedCallback() {
///
if (arguments.length !== 0) throw Error.parameterCount();
return this._defaultLoadCompletedCallback;
}
function Sys$Services$_ProfileService$set_defaultLoadCompletedCallback(value) {
var e = Function._validateParams(arguments, [{name: "value", type: Function, mayBeNull: true}]);
if (e) throw e;
this._defaultLoadCompletedCallback = value;
}
function Sys$Services$_ProfileService$get_defaultSaveCompletedCallback() {
///
if (arguments.length !== 0) throw Error.parameterCount();
return this._defaultSaveCompletedCallback;
}
function Sys$Services$_ProfileService$set_defaultSaveCompletedCallback(value) {
var e = Function._validateParams(arguments, [{name: "value", type: Function, mayBeNull: true}]);
if (e) throw e;
this._defaultSaveCompletedCallback = value;
}
function Sys$Services$_ProfileService$get_path() {
///
if (arguments.length !== 0) throw Error.parameterCount();
// override from base to ensure returned value is '' even if usercode sets to null.
// also refactored from v1 to ensure empty string on getter instead of setter.
return this._path || '';
}
function Sys$Services$_ProfileService$load(propertyNames, loadCompletedCallback, failedCallback, userContext) {
///
///
///
///
///
var e = Function._validateParams(arguments, [
{name: "propertyNames", type: Array, mayBeNull: true, optional: true, elementType: String},
{name: "loadCompletedCallback", type: Function, mayBeNull: true, optional: true},
{name: "failedCallback", type: Function, mayBeNull: true, optional: true},
{name: "userContext", mayBeNull: true, optional: true}
]);
if (e) throw e;
var parameters;
var methodName;
if (!propertyNames) {
methodName = "GetAllPropertiesForCurrentUser";
parameters = { authenticatedUserOnly: false };
}
else {
methodName = "GetPropertiesForCurrentUser";
parameters = { properties: this._clonePropertyNames(propertyNames), authenticatedUserOnly: false };
}
this._invoke(this._get_path(),
methodName,
false,
parameters,
Function.createDelegate(this, this._onLoadComplete),
Function.createDelegate(this, this._onLoadFailed),
[loadCompletedCallback, failedCallback, userContext]);
}
function Sys$Services$_ProfileService$save(propertyNames, saveCompletedCallback, failedCallback, userContext) {
///
///
///
///
///
var e = Function._validateParams(arguments, [
{name: "propertyNames", type: Array, mayBeNull: true, optional: true, elementType: String},
{name: "saveCompletedCallback", type: Function, mayBeNull: true, optional: true},
{name: "failedCallback", type: Function, mayBeNull: true, optional: true},
{name: "userContext", mayBeNull: true, optional: true}
]);
if (e) throw e;
var flattenedProperties = this._flattenProperties(propertyNames, this.properties);
this._invoke(this._get_path(),
"SetPropertiesForCurrentUser",
false,
{ values: flattenedProperties.value, authenticatedUserOnly: false },
Function.createDelegate(this, this._onSaveComplete),
Function.createDelegate(this, this._onSaveFailed),
[saveCompletedCallback, failedCallback, userContext, flattenedProperties.count]);
}
function Sys$Services$_ProfileService$_clonePropertyNames(arr) {
var nodups = [];
var seen = {};
for (var i=0; i < arr.length; i++) {
var prop = arr[i];
if(!seen[prop]) { Array.add(nodups, prop); seen[prop]=true; };
}
return nodups;
}
function Sys$Services$_ProfileService$_flattenProperties(/*string[]*/propertyNames, properties, groupName) {
var flattenedProperties = {};
var val;
var key;
var count = 0;
if (propertyNames && propertyNames.length === 0) {
return { value: flattenedProperties, count: 0 };
}
for (var property in properties) {
val = properties[property];
key = groupName ? groupName + "." + property : property;
// is it a property group?
if(Sys.Services.ProfileGroup.isInstanceOfType(val)) {
var obj = this._flattenProperties(propertyNames, val, key);
var groupProperties = obj.value;
count += obj.count; // count all the group's properties we're about to merge in
// merge in group's properties
// NOTE: We don't use Array.addRange because flattenedProperties is not an Array.
// It can't be an array because it polutes the associative array and we need it to be purely properties.
// Array.prototype.addRange.apply() doesn't work either.
// NOTE: In the case where a group exists but has no inner properties of its own, the for loop will short out
// and there will be no keys added to the collection, as expected.
for(var subKey in groupProperties) {
var subVal = groupProperties[subKey];
flattenedProperties[subKey] = subVal;
}
}
else {
// is this a specified property (or use all properties)?
if(!propertyNames || Array.indexOf(propertyNames, key) !== -1) {
flattenedProperties[key] = val;
count++; // keep track of how many properties are in the flattened dictionary
}
}
}
return { value: flattenedProperties, count: count };
}
function Sys$Services$_ProfileService$_get_path() {
var path = this.get_path();
if (!path.length) {
path = Sys.Services._ProfileService.DefaultWebServicePath;
}
if (!path || !path.length) {
throw Error.invalidOperation(Sys.Res.servicePathNotSet);
}
return path;
}
function Sys$Services$_ProfileService$_onLoadComplete(result, context, methodName) {
if (typeof(result) !== "object") {
throw Error.invalidOperation(String.format(Sys.Res.webServiceInvalidReturnType, methodName, "Object"));
}
var unflattened = this._unflattenProperties(result);
for (var name in unflattened) {
this.properties[name] = unflattened[name];
}
var callback = context[0] || this.get_defaultLoadCompletedCallback() || this.get_defaultSucceededCallback();
if (callback) {
var userContext = context[2] || this.get_defaultUserContext();
callback(result.length, userContext, "Sys.Services.ProfileService.load");
}
}
function Sys$Services$_ProfileService$_onLoadFailed(err, context, methodName) {
var callback = context[1] || this.get_defaultFailedCallback();
if (callback) {
var userContext = context[2] || this.get_defaultUserContext();
callback(err, userContext, "Sys.Services.ProfileService.load");
}
else {
Sys.Net.WebServiceProxy._defaultFailedCallback(err, methodName);
}
}
function Sys$Services$_ProfileService$_onSaveComplete(result, context, methodName) {
// context[3] is the number of properties we sent to the server.
var count = context[3];
if (result !== null) { // dont use if(result), might be number 0
if (result instanceof Array) {
// result is a list of properties that failed. Subtract the count to get the # succeeded
count -= result.length;
}
else if (typeof(result) === 'number') {
// legacy server API -- the number of successful properties is returned directly
count = result;
}
else {
// no other types allowed
throw Error.invalidOperation(String.format(Sys.Res.webServiceInvalidReturnType, methodName, "Array"));
}
}
// else: if result is null, treat as an empty array (no failures)
var callback = context[0] || this.get_defaultSaveCompletedCallback() || this.get_defaultSucceededCallback();
if (callback) {
var userContext = context[2] || this.get_defaultUserContext();
callback(count, userContext, "Sys.Services.ProfileService.save");
}
}
function Sys$Services$_ProfileService$_onSaveFailed(err, context, methodName) {
var callback = context[1] || this.get_defaultFailedCallback();
if (callback) {
var userContext = context[2] || this.get_defaultUserContext();
callback(err, userContext, "Sys.Services.ProfileService.save");
}
else {
Sys.Net.WebServiceProxy._defaultFailedCallback(err, methodName);
}
}
function Sys$Services$_ProfileService$_unflattenProperties(properties) {
var unflattenedProperties = {};
var dotIndex;
var val;
var count = 0;
for (var key in properties) {
count++;
val = properties[key];
dotIndex = key.indexOf('.');
if (dotIndex !== -1) {
var groupName = key.substr(0, dotIndex);
key = key.substr(dotIndex+1);
var group = unflattenedProperties[groupName];
if (!group || !Sys.Services.ProfileGroup.isInstanceOfType(group)) {
group = new Sys.Services.ProfileGroup();
unflattenedProperties[groupName] = group;
}
group[key] = val;
}
else {
unflattenedProperties[key] = val;
}
}
properties.length = count;
return unflattenedProperties;
}
Sys.Services._ProfileService.prototype = {
_defaultLoadCompletedCallback: null,
_defaultSaveCompletedCallback: null,
_path: '',
_timeout: 0,
get_defaultLoadCompletedCallback: Sys$Services$_ProfileService$get_defaultLoadCompletedCallback,
set_defaultLoadCompletedCallback: Sys$Services$_ProfileService$set_defaultLoadCompletedCallback,
get_defaultSaveCompletedCallback: Sys$Services$_ProfileService$get_defaultSaveCompletedCallback,
set_defaultSaveCompletedCallback: Sys$Services$_ProfileService$set_defaultSaveCompletedCallback,
get_path: Sys$Services$_ProfileService$get_path,
load: Sys$Services$_ProfileService$load,
save: Sys$Services$_ProfileService$save,
// DevDiv 31283: calling load with two of the same property names throws an error, so we strip dups
_clonePropertyNames: Sys$Services$_ProfileService$_clonePropertyNames,
// convert properties like properties.ProfileGroup.ProfileSetting to properties["ProfileGroup.ProfileSetting"].
// propertyNames: list of properties that should be included in the flattened list (others are excluded)
// properties: object containing properties to flatten
// groupName: current group name used for recursion
_flattenProperties: Sys$Services$_ProfileService$_flattenProperties,
_get_path: Sys$Services$_ProfileService$_get_path,
_onLoadComplete: Sys$Services$_ProfileService$_onLoadComplete,
_onLoadFailed: Sys$Services$_ProfileService$_onLoadFailed,
_onSaveComplete: Sys$Services$_ProfileService$_onSaveComplete,
_onSaveFailed: Sys$Services$_ProfileService$_onSaveFailed,
_unflattenProperties: Sys$Services$_ProfileService$_unflattenProperties
}
Sys.Services._ProfileService.registerClass('Sys.Services._ProfileService', Sys.Net.WebServiceProxy);
Sys.Services.ProfileService = new Sys.Services._ProfileService();
Sys.Services.ProfileGroup = function Sys$Services$ProfileGroup(properties) {
///
///
var e = Function._validateParams(arguments, [
{name: "properties", mayBeNull: true, optional: true}
]);
if (e) throw e;
if (properties) {
for (var property in properties) {
this[property] = properties[property];
}
}
}
Sys.Services.ProfileGroup.registerClass('Sys.Services.ProfileGroup');
Sys.Services._AuthenticationService = function Sys$Services$_AuthenticationService() {
///
if (arguments.length !== 0) throw Error.parameterCount();
Sys.Services._AuthenticationService.initializeBase(this);
}
Sys.Services._AuthenticationService.DefaultWebServicePath = '';
function Sys$Services$_AuthenticationService$get_defaultLoginCompletedCallback() {
///
if (arguments.length !== 0) throw Error.parameterCount();
return this._defaultLoginCompletedCallback;
}
function Sys$Services$_AuthenticationService$set_defaultLoginCompletedCallback(value) {
var e = Function._validateParams(arguments, [{name: "value", type: Function, mayBeNull: true}]);
if (e) throw e;
this._defaultLoginCompletedCallback = value;
}
function Sys$Services$_AuthenticationService$get_defaultLogoutCompletedCallback() {
///
if (arguments.length !== 0) throw Error.parameterCount();
return this._defaultLogoutCompletedCallback;
}
function Sys$Services$_AuthenticationService$set_defaultLogoutCompletedCallback(value) {
var e = Function._validateParams(arguments, [{name: "value", type: Function, mayBeNull: true}]);
if (e) throw e;
this._defaultLogoutCompletedCallback = value;
}
function Sys$Services$_AuthenticationService$get_isLoggedIn() {
///
if (arguments.length !== 0) throw Error.parameterCount();
return this._authenticated;
}
function Sys$Services$_AuthenticationService$get_path() {
///
if (arguments.length !== 0) throw Error.parameterCount();
// override from base to ensure returned value is '' even if usercode sets to null.
// also refactored from v1 to ensure empty string on getter instead of setter.
return this._path || '';
}
function Sys$Services$_AuthenticationService$login(username, password, isPersistent, customInfo, redirectUrl, loginCompletedCallback, failedCallback, userContext) {
///
///
///
///
///
///
///
///
///
var e = Function._validateParams(arguments, [
{name: "username", type: String},
{name: "password", type: String, mayBeNull: true},
{name: "isPersistent", type: Boolean, mayBeNull: true, optional: true},
{name: "customInfo", type: String, mayBeNull: true, optional: true},
{name: "redirectUrl", type: String, mayBeNull: true, optional: true},
{name: "loginCompletedCallback", type: Function, mayBeNull: true, optional: true},
{name: "failedCallback", type: Function, mayBeNull: true, optional: true},
{name: "userContext", mayBeNull: true, optional: true}
]);
if (e) throw e;
// note: use of internal type here, but theres no other way
this._invoke(this._get_path(), "Login", false,
{ userName: username, password: password, createPersistentCookie: isPersistent },
Function.createDelegate(this, this._onLoginComplete),
Function.createDelegate(this, this._onLoginFailed),
[username, password, isPersistent, customInfo, redirectUrl, loginCompletedCallback, failedCallback, userContext]);
}
function Sys$Services$_AuthenticationService$logout(redirectUrl, logoutCompletedCallback, failedCallback, userContext) {
///
///
///
///
///
var e = Function._validateParams(arguments, [
{name: "redirectUrl", type: String, mayBeNull: true, optional: true},
{name: "logoutCompletedCallback", type: Function, mayBeNull: true, optional: true},
{name: "failedCallback", type: Function, mayBeNull: true, optional: true},
{name: "userContext", mayBeNull: true, optional: true}
]);
if (e) throw e;
// note: use of internal type here, but theres no other way
this._invoke(this._get_path(), "Logout", false, {},
Function.createDelegate(this, this._onLogoutComplete),
Function.createDelegate(this, this._onLogoutFailed),
[redirectUrl, logoutCompletedCallback, failedCallback, userContext]);
}
function Sys$Services$_AuthenticationService$_get_path() {
var path = this.get_path();
if(!path.length) {
path = Sys.Services._AuthenticationService.DefaultWebServicePath;
}
if(!path || !path.length) {
throw Error.invalidOperation(Sys.Res.servicePathNotSet);
}
return path;
}
function Sys$Services$_AuthenticationService$_onLoginComplete(result, /*login param list*/context, methodName) {
if(typeof(result) !== "boolean") {
throw Error.invalidOperation(String.format(Sys.Res.webServiceInvalidReturnType, methodName, "Boolean"));
}
var redirectUrl = context[4];
var userContext = context[7] || this.get_defaultUserContext();
var callback = context[5] || this.get_defaultLoginCompletedCallback() || this.get_defaultSucceededCallback();
if(result) {
this._authenticated = true;
if (callback) {
callback(true, userContext, "Sys.Services.AuthenticationService.login");
}
if (typeof(redirectUrl) !== "undefined" && redirectUrl !== null) {
// url may be empty which is a valid link
window.location.href = redirectUrl;
}
}
else if (callback) {
callback(false, userContext, "Sys.Services.AuthenticationService.login");
}
}
function Sys$Services$_AuthenticationService$_onLoginFailed(err, context, methodName) {
var callback = context[6] || this.get_defaultFailedCallback();
if (callback) {
var userContext = context[7] || this.get_defaultUserContext();
callback(err, userContext, "Sys.Services.AuthenticationService.login");
}
else {
Sys.Net.WebServiceProxy._defaultFailedCallback(err, methodName);
}
}
function Sys$Services$_AuthenticationService$_onLogoutComplete(result, context, methodName) {
if(result !== null) {
throw Error.invalidOperation(String.format(Sys.Res.webServiceInvalidReturnType, methodName, "null"));
}
var redirectUrl = context[0];
var userContext = context[3] || this.get_defaultUserContext();
var callback = context[1] || this.get_defaultLogoutCompletedCallback() || this.get_defaultSucceededCallback();
this._authenticated = false;
if (callback) {
callback(null, userContext, "Sys.Services.AuthenticationService.logout");
}
// always redirect when logging out
if(!redirectUrl) {
window.location.reload();
}
else {
window.location.href = redirectUrl;
}
}
function Sys$Services$_AuthenticationService$_onLogoutFailed(err, context, methodName) {
var callback = context[2] || this.get_defaultFailedCallback();
if (callback) {
callback(err, context[3], "Sys.Services.AuthenticationService.logout");
}
else {
Sys.Net.WebServiceProxy._defaultFailedCallback(err, methodName);
}
}
function Sys$Services$_AuthenticationService$_setAuthenticated(authenticated) {
this._authenticated = authenticated;
}
Sys.Services._AuthenticationService.prototype = {
_defaultLoginCompletedCallback: null,
_defaultLogoutCompletedCallback: null,
_path: '',
_timeout: 0,
_authenticated: false,
get_defaultLoginCompletedCallback: Sys$Services$_AuthenticationService$get_defaultLoginCompletedCallback,
set_defaultLoginCompletedCallback: Sys$Services$_AuthenticationService$set_defaultLoginCompletedCallback,
get_defaultLogoutCompletedCallback: Sys$Services$_AuthenticationService$get_defaultLogoutCompletedCallback,
set_defaultLogoutCompletedCallback: Sys$Services$_AuthenticationService$set_defaultLogoutCompletedCallback,
get_isLoggedIn: Sys$Services$_AuthenticationService$get_isLoggedIn,
get_path: Sys$Services$_AuthenticationService$get_path,
login: Sys$Services$_AuthenticationService$login,
logout: Sys$Services$_AuthenticationService$logout,
_get_path: Sys$Services$_AuthenticationService$_get_path,
_onLoginComplete: Sys$Services$_AuthenticationService$_onLoginComplete,
_onLoginFailed: Sys$Services$_AuthenticationService$_onLoginFailed,
_onLogoutComplete: Sys$Services$_AuthenticationService$_onLogoutComplete,
_onLogoutFailed: Sys$Services$_AuthenticationService$_onLogoutFailed,
_setAuthenticated: Sys$Services$_AuthenticationService$_setAuthenticated
}
Sys.Services._AuthenticationService.registerClass('Sys.Services._AuthenticationService', Sys.Net.WebServiceProxy);
Sys.Services.AuthenticationService = new Sys.Services._AuthenticationService();
Sys.Services._RoleService = function Sys$Services$_RoleService() {
Sys.Services._RoleService.initializeBase(this);
this._roles = [];
}
Sys.Services._RoleService.DefaultWebServicePath = '';
function Sys$Services$_RoleService$get_defaultLoadCompletedCallback() {
///
if (arguments.length !== 0) throw Error.parameterCount();
return this._defaultLoadCompletedCallback;
}
function Sys$Services$_RoleService$set_defaultLoadCompletedCallback(value) {
var e = Function._validateParams(arguments, [{name: "value", type: Function, mayBeNull: true}]);
if (e) throw e;
this._defaultLoadCompletedCallback = value;
}
function Sys$Services$_RoleService$get_path() {
///
if (arguments.length !== 0) throw Error.parameterCount();
// override from base to ensure returned value is '' even if usercode sets to null, consistent with other appservices in v1.
return this._path || '';
}
function Sys$Services$_RoleService$get_roles() {
///
if (arguments.length !== 0) throw Error.parameterCount();
return Array.clone(this._roles);
}
function Sys$Services$_RoleService$isUserInRole(role) {
///
///
var e = Function._validateParams(arguments, [
{name: "role", type: String}
]);
if (e) throw e;
var v = this._get_rolesIndex()[role.trim().toLowerCase()];
return !!v;
}
function Sys$Services$_RoleService$load(loadCompletedCallback, failedCallback, userContext) {
///
///
///
///
var e = Function._validateParams(arguments, [
{name: "loadCompletedCallback", type: Function, mayBeNull: true, optional: true},
{name: "failedCallback", type: Function, mayBeNull: true, optional: true},
{name: "userContext", mayBeNull: true, optional: true}
]);
if (e) throw e;
Sys.Net.WebServiceProxy.invoke(
this._get_path(),
"GetRolesForCurrentUser",
false,
{} /* no params*/,
Function.createDelegate(this, this._onLoadComplete),
Function.createDelegate(this, this._onLoadFailed),
[loadCompletedCallback, failedCallback, userContext],
this.get_timeout());
}
function Sys$Services$_RoleService$_get_path() {
var path = this.get_path();
if(!path || !path.length) {
path = Sys.Services._RoleService.DefaultWebServicePath;
}
if(!path || !path.length) {
throw Error.invalidOperation(Sys.Res.servicePathNotSet);
}
return path;
}
function Sys$Services$_RoleService$_get_rolesIndex() {
if (!this._rolesIndex) {
var index = {};
for(var i=0; i < this._roles.length; i++) {
index[this._roles[i].toLowerCase()] = true;
}
this._rolesIndex = index;
}
return this._rolesIndex;
}
function Sys$Services$_RoleService$_onLoadComplete(result, context, methodName) {
if(result && !(result instanceof Array)) {
throw Error.invalidOperation(String.format(Sys.Res.webServiceInvalidReturnType, methodName, "Array"));
}
this._roles = result;
this._rolesIndex = null;
var callback = context[0] || this.get_defaultLoadCompletedCallback() || this.get_defaultSucceededCallback();
if (callback) {
var userContext = context[2] || this.get_defaultUserContext();
var clonedResult = Array.clone(result);
callback(clonedResult, userContext, "Sys.Services.RoleService.load");
}
}
function Sys$Services$_RoleService$_onLoadFailed(err, context, methodName) {
var callback = context[1] || this.get_defaultFailedCallback();
if (callback) {
var userContext = context[2] || this.get_defaultUserContext();
callback(err, userContext, "Sys.Services.RoleService.load");
}
else {
Sys.Net.WebServiceProxy._defaultFailedCallback(err, methodName);
}
}
Sys.Services._RoleService.prototype = {
_defaultLoadCompletedCallback: null,
_rolesIndex: null,
_timeout: 0,
_path: '',
get_defaultLoadCompletedCallback: Sys$Services$_RoleService$get_defaultLoadCompletedCallback,
set_defaultLoadCompletedCallback: Sys$Services$_RoleService$set_defaultLoadCompletedCallback,
get_path: Sys$Services$_RoleService$get_path,
get_roles: Sys$Services$_RoleService$get_roles,
isUserInRole: Sys$Services$_RoleService$isUserInRole,
load: Sys$Services$_RoleService$load,
_get_path: Sys$Services$_RoleService$_get_path,
_get_rolesIndex: Sys$Services$_RoleService$_get_rolesIndex,
_onLoadComplete: Sys$Services$_RoleService$_onLoadComplete,
_onLoadFailed: Sys$Services$_RoleService$_onLoadFailed
}
Sys.Services._RoleService.registerClass('Sys.Services._RoleService', Sys.Net.WebServiceProxy);
Sys.Services.RoleService = new Sys.Services._RoleService();
Type.registerNamespace('Sys.Serialization');
Sys.Serialization.JavaScriptSerializer = function Sys$Serialization$JavaScriptSerializer() {
///
if (arguments.length !== 0) throw Error.parameterCount();
// DevDiv #62350: Considered making all methods static and removing this constructor,
// but this would have been a breaking change from Atlas 1.0 to Atlas Orcas so was rejected.
}
Sys.Serialization.JavaScriptSerializer.registerClass('Sys.Serialization.JavaScriptSerializer');
Sys.Serialization.JavaScriptSerializer._serverTypeFieldName = '__type';
// DevDiv Bugs 139383:
// Escape the backslashes so to _stringRegEx so we pass an escape sequence to the RegExp,
// not the literal character. Safari does not support the literal characters, and it fails on iPhone 1.01.
Sys.Serialization.JavaScriptSerializer._stringRegEx = new RegExp('["\\b\\f\\n\\r\\t\\\\\\x00-\\x1F]', 'i');
Sys.Serialization.JavaScriptSerializer._dateRegEx = new RegExp('(^|[^\\\\])\\"\\\\/Date\\((-?[0-9]+)(?:[a-zA-Z]|(?:\\+|-)[0-9]{4})?\\)\\\\/\\"', 'g');
Sys.Serialization.JavaScriptSerializer._jsonRegEx = new RegExp('[^,:{}\\[\\]0-9.\\-+Eaeflnr-u \\n\\r\\t]', 'g');
Sys.Serialization.JavaScriptSerializer._jsonStringRegEx = new RegExp('"(\\\\.|[^"\\\\])*"', 'g');
Sys.Serialization.JavaScriptSerializer._serializeBooleanWithBuilder = function Sys$Serialization$JavaScriptSerializer$_serializeBooleanWithBuilder(object, stringBuilder) {
stringBuilder.append(object.toString());
}
Sys.Serialization.JavaScriptSerializer._serializeNumberWithBuilder = function Sys$Serialization$JavaScriptSerializer$_serializeNumberWithBuilder(object, stringBuilder) {
if (isFinite(object)) {
stringBuilder.append(String(object));
}
else {
throw Error.invalidOperation(Sys.Res.cannotSerializeNonFiniteNumbers);
}
}
Sys.Serialization.JavaScriptSerializer._serializeStringWithBuilder = function Sys$Serialization$JavaScriptSerializer$_serializeStringWithBuilder(object, stringBuilder) {
stringBuilder.append('"');
// DevDiv 139383: Removed Safari check here.
// Safari 2 supports \x## escapes in regular expressions as long as they are escaped in the regex pattern
if (Sys.Serialization.JavaScriptSerializer._stringRegEx.test(object)) {
var length = object.length;
for (i = 0; i < length; ++i) {
var curChar = object.charAt(i);
// currently '/u001f' or below are escaped
if (curChar >= ' ') {
// Handle backslashes and quotes by escaping
if (curChar === '\\' || curChar === '"') {
stringBuilder.append('\\');
}
stringBuilder.append(curChar);
}
else {
switch (curChar) {
case '\b':
stringBuilder.append('\\b');
break;
case '\f':
stringBuilder.append('\\f');
break;
case '\n':
stringBuilder.append('\\n');
break;
case '\r':
stringBuilder.append('\\r');
break;
case '\t':
stringBuilder.append('\\t');
break;
default:
// Add the escaped code
stringBuilder.append('\\u00');
if (curChar.charCodeAt() < 16) stringBuilder.append('0');
stringBuilder.append(curChar.charCodeAt().toString(16));
}
}
}
} else {
stringBuilder.append(object);
}
stringBuilder.append('"');
}
Sys.Serialization.JavaScriptSerializer._serializeWithBuilder = function Sys$Serialization$JavaScriptSerializer$_serializeWithBuilder(object, stringBuilder, sort, prevObjects) {
var i;
switch (typeof object) {
case 'object':
if (object) {
if (prevObjects){
// The loop below makes serilzation O(n^2) worst case for linked list like struture
// where in depth of graph is in linear proportion to number of elements.
// However the depth of graph is limited by call stack size(less than 1000 in IE7) hence
// the performance hit is within reasonable bounds for debug mode
for( var j = 0; j < prevObjects.length; j++) {
if (prevObjects[j] === object) {
throw Error.invalidOperation(Sys.Res.cannotSerializeObjectWithCycle);
}
}
}
else {
prevObjects = new Array();
}
try {
Array.add(prevObjects, object);
if (Number.isInstanceOfType(object)){
Sys.Serialization.JavaScriptSerializer._serializeNumberWithBuilder(object, stringBuilder);
}
else if (Boolean.isInstanceOfType(object)){
Sys.Serialization.JavaScriptSerializer._serializeBooleanWithBuilder(object, stringBuilder);
}
else if (String.isInstanceOfType(object)){
Sys.Serialization.JavaScriptSerializer._serializeStringWithBuilder(object, stringBuilder);
}
// Arrays
else if (Array.isInstanceOfType(object)) {
stringBuilder.append('[');
for (i = 0; i < object.length; ++i) {
if (i > 0) {
stringBuilder.append(',');
}
Sys.Serialization.JavaScriptSerializer._serializeWithBuilder(object[i], stringBuilder,false,prevObjects);
}
stringBuilder.append(']');
}
else {
// DivDev 41125: Do not confuse atlas serialized strings with dates
// Currently it always serialize as \/Date({milliseconds from 1970/1/1})\/
// For example \/Date(123)\/
if (Date.isInstanceOfType(object)) {
stringBuilder.append('"\\/Date(');
stringBuilder.append(object.getTime());
stringBuilder.append(')\\/"');
break;
}
var properties = [];
var propertyCount = 0;
for (var name in object) {
// skip internal properties that should not be serialized.
if (name.startsWith('$')) {
continue;
}
//DevDiv 74427 : Need to make sure that _type is first item on JSON serialization
if (name === Sys.Serialization.JavaScriptSerializer._serverTypeFieldName && propertyCount !== 0){
// if current propery Name is __type, swap it with the first element on property array.
properties[propertyCount++] = properties[0];
properties[0] = name;
}
else{
properties[propertyCount++] = name;
}
}
if (sort) properties.sort();
stringBuilder.append('{');
var needComma = false;
for (i=0; i
///
///
var e = Function._validateParams(arguments, [
{name: "object", mayBeNull: true}
]);
if (e) throw e;
var stringBuilder = new Sys.StringBuilder();
Sys.Serialization.JavaScriptSerializer._serializeWithBuilder(object, stringBuilder, false);
return stringBuilder.toString();
}
Sys.Serialization.JavaScriptSerializer.deserialize = function Sys$Serialization$JavaScriptSerializer$deserialize(data, secure) {
///
///
///
///
var e = Function._validateParams(arguments, [
{name: "data", type: String},
{name: "secure", type: Boolean, optional: true}
]);
if (e) throw e;
if (data.length === 0) throw Error.argument('data', Sys.Res.cannotDeserializeEmptyString);
// DevDiv 41127: Never confuse atlas serialized strings with dates.
// DevDiv 74430: JavasciptSerializer will need to handle date time offset - following WCF design
// serilzed dates might look like "\/Date(123)\/" or "\/Date(123A)" or "Date(123+4567)" or Date(123-4567)"
// the regex escaped version of this pattern is \"\\/Date\(123(?:[a-zA-Z]|(?:\+|-)[0-9]{4})?\)\\/\"
// but we must also do js escaping to put it in the string. Escape all \ with \\
// Result: \\"\\\\/Date\\(123(?:[a-zA-Z]|(?:\\+|-)[0-9]{4})?\\)\\\\/\\"
// The 123 can really be any number with an optional -, and we want to capture it.
// Regex for that is: (-?[0-9]+)
// Result: \\"\\\\/Date\\((-?[0-9]+)(?:[a-zA-Z]|(?:\\+|-)[0-9]{4})?\\)\\\\/\\"
// We want to avoid replacing serialized strings that happen to contain this string as a substring.
// We can do that by excluding matches that start with a slash \ since that means the first quote is escaped.
// The first quote of a real date string will never be escaped and so will never be preceeded with \
// So we want to add regex pattern (^|[^\\]) to the beginning, which means "beginning of string or anything but slash".
// JS Escaped version: (^|[^\\\\])
// Result: (^|[^\\\\])\\"\\\\/Date\\((-?[0-9]+)(?:[a-zA-Z]|(?:\\+|-)[0-9]{4})?\\)\\\\/\\"
// Finally, the replace string is $1new Date($2). We must include $1 so we put back the potentially matched character we captured.
try {
var exp = data.replace(Sys.Serialization.JavaScriptSerializer._dateRegEx, "$1new Date($2)");
if (secure && Sys.Serialization.JavaScriptSerializer._jsonRegEx.test(
exp.replace(Sys.Serialization.JavaScriptSerializer._jsonStringRegEx, ''))) throw null;
return eval('(' + exp + ')');
}
catch (e) {
throw Error.argument('data', Sys.Res.cannotDeserializeInvalidJson);
}
}
// CultureInfo must go after JavaScriptSerializer since it deserializes the __cultureInfo object inline.
Sys.CultureInfo = function Sys$CultureInfo(name, numberFormat, dateTimeFormat) {
///
///
///
///
var e = Function._validateParams(arguments, [
{name: "name", type: String},
{name: "numberFormat", type: Object},
{name: "dateTimeFormat", type: Object}
]);
if (e) throw e;
this.name = name;
this.numberFormat = numberFormat;
this.dateTimeFormat = dateTimeFormat;
}
function Sys$CultureInfo$_getDateTimeFormats() {
if (! this._dateTimeFormats) {
var dtf = this.dateTimeFormat;
this._dateTimeFormats =
[ dtf.MonthDayPattern,
dtf.YearMonthPattern,
dtf.ShortDatePattern,
dtf.ShortTimePattern,
dtf.LongDatePattern,
dtf.LongTimePattern,
dtf.FullDateTimePattern,
dtf.RFC1123Pattern,
dtf.SortableDateTimePattern,
dtf.UniversalSortableDateTimePattern ];
}
return this._dateTimeFormats;
}
function Sys$CultureInfo$_getMonthIndex(value) {
if (!this._upperMonths) {
this._upperMonths = this._toUpperArray(this.dateTimeFormat.MonthNames);
}
return Array.indexOf(this._upperMonths, this._toUpper(value));
}
function Sys$CultureInfo$_getAbbrMonthIndex(value) {
if (!this._upperAbbrMonths) {
this._upperAbbrMonths = this._toUpperArray(this.dateTimeFormat.AbbreviatedMonthNames);
}
return Array.indexOf(this._upperAbbrMonths, this._toUpper(value));
}
function Sys$CultureInfo$_getDayIndex(value) {
if (!this._upperDays) {
this._upperDays = this._toUpperArray(this.dateTimeFormat.DayNames);
}
return Array.indexOf(this._upperDays, this._toUpper(value));
}
function Sys$CultureInfo$_getAbbrDayIndex(value) {
if (!this._upperAbbrDays) {
this._upperAbbrDays = this._toUpperArray(this.dateTimeFormat.AbbreviatedDayNames);
}
return Array.indexOf(this._upperAbbrDays, this._toUpper(value));
}
function Sys$CultureInfo$_toUpperArray(arr) {
var result = [];
for (var i = 0, il = arr.length; i < il; i++) {
result[i] = this._toUpper(arr[i]);
}
return result;
}
function Sys$CultureInfo$_toUpper(value) {
// 'he-IL' has non-breaking space (\u00A0) in weekday names. In this case replace
// didn't work using the space escape code ('\s'), so must match the exact character.
return value.split("\u00A0").join(' ').toUpperCase();
}
Sys.CultureInfo.prototype = {
_getDateTimeFormats: Sys$CultureInfo$_getDateTimeFormats,
_getMonthIndex: Sys$CultureInfo$_getMonthIndex,
_getAbbrMonthIndex: Sys$CultureInfo$_getAbbrMonthIndex,
_getDayIndex: Sys$CultureInfo$_getDayIndex,
_getAbbrDayIndex: Sys$CultureInfo$_getAbbrDayIndex,
_toUpperArray: Sys$CultureInfo$_toUpperArray,
_toUpper: Sys$CultureInfo$_toUpper
}
Sys.CultureInfo._parse = function Sys$CultureInfo$_parse(value) {
var cultureInfo = Sys.Serialization.JavaScriptSerializer.deserialize(value);
return new Sys.CultureInfo(cultureInfo.name, cultureInfo.numberFormat, cultureInfo.dateTimeFormat);
}
Sys.CultureInfo.registerClass('Sys.CultureInfo');
// Make sure the invariant and 'en-US' cultureInfos contained in this file contain unicode in
// place of the non-ascii characters so it matches the encoding of the MicrosoftAjax.js script.
// This is especially required when jsCrunch builds the release script, because it will not
// convert non-ascii characters to unicode correctly for the current MicrosoftAjax.js encoding.
Sys.CultureInfo.InvariantCulture = Sys.CultureInfo._parse('{"name":"","numberFormat":{"CurrencyDecimalDigits":2,"CurrencyDecimalSeparator":".","IsReadOnly":true,"CurrencyGroupSizes":[3],"NumberGroupSizes":[3],"PercentGroupSizes":[3],"CurrencyGroupSeparator":",","CurrencySymbol":"\u00A4","NaNSymbol":"NaN","CurrencyNegativePattern":0,"NumberNegativePattern":1,"PercentPositivePattern":0,"PercentNegativePattern":0,"NegativeInfinitySymbol":"-Infinity","NegativeSign":"-","NumberDecimalDigits":2,"NumberDecimalSeparator":".","NumberGroupSeparator":",","CurrencyPositivePattern":0,"PositiveInfinitySymbol":"Infinity","PositiveSign":"+","PercentDecimalDigits":2,"PercentDecimalSeparator":".","PercentGroupSeparator":",","PercentSymbol":"%","PerMilleSymbol":"\u2030","NativeDigits":["0","1","2","3","4","5","6","7","8","9"],"DigitSubstitution":1},"dateTimeFormat":{"AMDesignator":"AM","Calendar":{"MinSupportedDateTime":"@-62135568000000@","MaxSupportedDateTime":"@253402300799999@","AlgorithmType":1,"CalendarType":1,"Eras":[1],"TwoDigitYearMax":2029,"IsReadOnly":true},"DateSeparator":"/","FirstDayOfWeek":0,"CalendarWeekRule":0,"FullDateTimePattern":"dddd, dd MMMM yyyy HH:mm:ss","LongDatePattern":"dddd, dd MMMM yyyy","LongTimePattern":"HH:mm:ss","MonthDayPattern":"MMMM dd","PMDesignator":"PM","RFC1123Pattern":"ddd, dd MMM yyyy HH\':\'mm\':\'ss \'GMT\'","ShortDatePattern":"MM/dd/yyyy","ShortTimePattern":"HH:mm","SortableDateTimePattern":"yyyy\'-\'MM\'-\'dd\'T\'HH\':\'mm\':\'ss","TimeSeparator":":","UniversalSortableDateTimePattern":"yyyy\'-\'MM\'-\'dd HH\':\'mm\':\'ss\'Z\'","YearMonthPattern":"yyyy MMMM","AbbreviatedDayNames":["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],"ShortestDayNames":["Su","Mo","Tu","We","Th","Fr","Sa"],"DayNames":["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],"AbbreviatedMonthNames":["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec",""],"MonthNames":["January","February","March","April","May","June","July","August","September","October","November","December",""],"IsReadOnly":true,"NativeCalendarName":"Gregorian Calendar","AbbreviatedMonthGenitiveNames":["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec",""],"MonthGenitiveNames":["January","February","March","April","May","June","July","August","September","October","November","December",""]}}');
if (typeof(__cultureInfo) === 'undefined') {
var __cultureInfo = '{"name":"en-US","numberFormat":{"CurrencyDecimalDigits":2,"CurrencyDecimalSeparator":".","IsReadOnly":false,"CurrencyGroupSizes":[3],"NumberGroupSizes":[3],"PercentGroupSizes":[3],"CurrencyGroupSeparator":",","CurrencySymbol":"$","NaNSymbol":"NaN","CurrencyNegativePattern":0,"NumberNegativePattern":1,"PercentPositivePattern":0,"PercentNegativePattern":0,"NegativeInfinitySymbol":"-Infinity","NegativeSign":"-","NumberDecimalDigits":2,"NumberDecimalSeparator":".","NumberGroupSeparator":",","CurrencyPositivePattern":0,"PositiveInfinitySymbol":"Infinity","PositiveSign":"+","PercentDecimalDigits":2,"PercentDecimalSeparator":".","PercentGroupSeparator":",","PercentSymbol":"%","PerMilleSymbol":"\u2030","NativeDigits":["0","1","2","3","4","5","6","7","8","9"],"DigitSubstitution":1},"dateTimeFormat":{"AMDesignator":"AM","Calendar":{"MinSupportedDateTime":"@-62135568000000@","MaxSupportedDateTime":"@253402300799999@","AlgorithmType":1,"CalendarType":1,"Eras":[1],"TwoDigitYearMax":2029,"IsReadOnly":false},"DateSeparator":"/","FirstDayOfWeek":0,"CalendarWeekRule":0,"FullDateTimePattern":"dddd, MMMM dd, yyyy h:mm:ss tt","LongDatePattern":"dddd, MMMM dd, yyyy","LongTimePattern":"h:mm:ss tt","MonthDayPattern":"MMMM dd","PMDesignator":"PM","RFC1123Pattern":"ddd, dd MMM yyyy HH\':\'mm\':\'ss \'GMT\'","ShortDatePattern":"M/d/yyyy","ShortTimePattern":"h:mm tt","SortableDateTimePattern":"yyyy\'-\'MM\'-\'dd\'T\'HH\':\'mm\':\'ss","TimeSeparator":":","UniversalSortableDateTimePattern":"yyyy\'-\'MM\'-\'dd HH\':\'mm\':\'ss\'Z\'","YearMonthPattern":"MMMM, yyyy","AbbreviatedDayNames":["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],"ShortestDayNames":["Su","Mo","Tu","We","Th","Fr","Sa"],"DayNames":["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],"AbbreviatedMonthNames":["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec",""],"MonthNames":["January","February","March","April","May","June","July","August","September","October","November","December",""],"IsReadOnly":false,"NativeCalendarName":"Gregorian Calendar","AbbreviatedMonthGenitiveNames":["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec",""],"MonthGenitiveNames":["January","February","March","April","May","June","July","August","September","October","November","December",""]}}';
}
Sys.CultureInfo.CurrentCulture = Sys.CultureInfo._parse(__cultureInfo);
delete __cultureInfo;
Sys.UI.Behavior = function Sys$UI$Behavior(element) {
///
///
var e = Function._validateParams(arguments, [
{name: "element", domElement: true}
]);
if (e) throw e;
Sys.UI.Behavior.initializeBase(this);
this._element = element;
var behaviors = element._behaviors;
if (!behaviors) {
element._behaviors = [this];
}
else {
behaviors[behaviors.length] = this;
}
}
function Sys$UI$Behavior$get_element() {
///
if (arguments.length !== 0) throw Error.parameterCount();
return this._element;
}
function Sys$UI$Behavior$get_id() {
///
if (arguments.length !== 0) throw Error.parameterCount();
var baseId = Sys.UI.Behavior.callBaseMethod(this, 'get_id');
if (baseId) return baseId;
if (!this._element || !this._element.id) return '';
return this._element.id + '$' + this.get_name();
}
function Sys$UI$Behavior$get_name() {
///
if (arguments.length !== 0) throw Error.parameterCount();
if (this._name) return this._name;
var name = Object.getTypeName(this);
var i = name.lastIndexOf('.');
if (i != -1) name = name.substr(i + 1);
if (!this.get_isInitialized()) this._name = name;
return name;
}
function Sys$UI$Behavior$set_name(value) {
var e = Function._validateParams(arguments, [{name: "value", type: String}]);
if (e) throw e;
if ((value === '') || (value.charAt(0) === ' ') || (value.charAt(value.length - 1) === ' '))
throw Error.argument('value', Sys.Res.invalidId);
if (typeof(this._element[value]) !== 'undefined')
throw Error.invalidOperation(String.format(Sys.Res.behaviorDuplicateName, value));
if (this.get_isInitialized()) throw Error.invalidOperation(Sys.Res.cantSetNameAfterInit);
this._name = value;
}
function Sys$UI$Behavior$initialize() {
Sys.UI.Behavior.callBaseMethod(this, 'initialize');
var name = this.get_name();
if (name) this._element[name] = this;
}
function Sys$UI$Behavior$dispose() {
Sys.UI.Behavior.callBaseMethod(this, 'dispose');
if (this._element) {
var name = this.get_name();
if (name) {
this._element[name] = null;
}
Array.remove(this._element._behaviors, this);
delete this._element;
}
}
Sys.UI.Behavior.prototype = {
_name: null,
get_element: Sys$UI$Behavior$get_element,
get_id: Sys$UI$Behavior$get_id,
get_name: Sys$UI$Behavior$get_name,
set_name: Sys$UI$Behavior$set_name,
initialize: Sys$UI$Behavior$initialize,
dispose: Sys$UI$Behavior$dispose
}
Sys.UI.Behavior.registerClass('Sys.UI.Behavior', Sys.Component);
Sys.UI.Behavior.getBehaviorByName = function Sys$UI$Behavior$getBehaviorByName(element, name) {
///
///
///
///
var e = Function._validateParams(arguments, [
{name: "element", domElement: true},
{name: "name", type: String}
]);
if (e) throw e;
var b = element[name];
return (b && Sys.UI.Behavior.isInstanceOfType(b)) ? b : null;
}
Sys.UI.Behavior.getBehaviors = function Sys$UI$Behavior$getBehaviors(element) {
///
///
///
var e = Function._validateParams(arguments, [
{name: "element", domElement: true}
]);
if (e) throw e;
if (!element._behaviors) return [];
return Array.clone(element._behaviors);
}
Sys.UI.Behavior.getBehaviorsByType = function Sys$UI$Behavior$getBehaviorsByType(element, type) {
///
///
///
///
var e = Function._validateParams(arguments, [
{name: "element", domElement: true},
{name: "type", type: Type}
]);
if (e) throw e;
var behaviors = element._behaviors;
var results = [];
if (behaviors) {
for (var i = 0, l = behaviors.length; i < l; i++) {
if (type.isInstanceOfType(behaviors[i])) {
results[results.length] = behaviors[i];
}
}
}
return results;
}
Sys.UI.VisibilityMode = function Sys$UI$VisibilityMode() {
///
///
///
if (arguments.length !== 0) throw Error.parameterCount();
throw Error.notImplemented();
}
Sys.UI.VisibilityMode.prototype = {
hide: 0,
collapse: 1
}
Sys.UI.VisibilityMode.registerEnum("Sys.UI.VisibilityMode");
Sys.UI.Control = function Sys$UI$Control(element) {
///
///
var e = Function._validateParams(arguments, [
{name: "element", domElement: true}
]);
if (e) throw e;
if (typeof(element.control) != 'undefined') throw Error.invalidOperation(Sys.Res.controlAlreadyDefined);
Sys.UI.Control.initializeBase(this);
this._element = element;
element.control = this;
}
function Sys$UI$Control$get_element() {
///
if (arguments.length !== 0) throw Error.parameterCount();
return this._element;
}
function Sys$UI$Control$get_id() {
///
if (arguments.length !== 0) throw Error.parameterCount();
if (!this._element) return '';
return this._element.id;
}
function Sys$UI$Control$set_id(value) {
var e = Function._validateParams(arguments, [{name: "value", type: String}]);
if (e) throw e;
throw Error.invalidOperation(Sys.Res.cantSetId);
}
function Sys$UI$Control$get_parent() {
///
if (arguments.length !== 0) throw Error.parameterCount();
if (this._parent) return this._parent;
if (!this._element) return null;
var parentElement = this._element.parentNode;
while (parentElement) {
if (parentElement.control) {
return parentElement.control;
}
parentElement = parentElement.parentNode;
}
return null;
}
function Sys$UI$Control$set_parent(value) {
var e = Function._validateParams(arguments, [{name: "value", type: Sys.UI.Control}]);
if (e) throw e;
if (!this._element) throw Error.invalidOperation(Sys.Res.cantBeCalledAfterDispose);
var parents = [this];
var current = value;
while (current) {
if (Array.contains(parents, current)) throw Error.invalidOperation(Sys.Res.circularParentChain);
parents[parents.length] = current;
current = current.get_parent();
}
this._parent = value;
}
function Sys$UI$Control$get_visibilityMode() {
///
if (arguments.length !== 0) throw Error.parameterCount();
if (!this._element) throw Error.invalidOperation(Sys.Res.cantBeCalledAfterDispose);
return Sys.UI.DomElement.getVisibilityMode(this._element);
}
function Sys$UI$Control$set_visibilityMode(value) {
var e = Function._validateParams(arguments, [{name: "value", type: Sys.UI.VisibilityMode}]);
if (e) throw e;
if (!this._element) throw Error.invalidOperation(Sys.Res.cantBeCalledAfterDispose);
Sys.UI.DomElement.setVisibilityMode(this._element, value);
}
function Sys$UI$Control$get_visible() {
///
if (arguments.length !== 0) throw Error.parameterCount();
if (!this._element) throw Error.invalidOperation(Sys.Res.cantBeCalledAfterDispose);
return Sys.UI.DomElement.getVisible(this._element);
}
function Sys$UI$Control$set_visible(value) {
var e = Function._validateParams(arguments, [{name: "value", type: Boolean}]);
if (e) throw e;
if (!this._element) throw Error.invalidOperation(Sys.Res.cantBeCalledAfterDispose);
Sys.UI.DomElement.setVisible(this._element, value)
}
function Sys$UI$Control$addCssClass(className) {
///
///
var e = Function._validateParams(arguments, [
{name: "className", type: String}
]);
if (e) throw e;
if (!this._element) throw Error.invalidOperation(Sys.Res.cantBeCalledAfterDispose);
Sys.UI.DomElement.addCssClass(this._element, className);
}
function Sys$UI$Control$dispose() {
Sys.UI.Control.callBaseMethod(this, 'dispose');
if (this._element) {
this._element.control = undefined;
delete this._element;
}
if (this._parent) delete this._parent;
}
function Sys$UI$Control$onBubbleEvent(source, args) {
///
///
///
///
var e = Function._validateParams(arguments, [
{name: "source"},
{name: "args", type: Sys.EventArgs}
]);
if (e) throw e;
return false;
}
function Sys$UI$Control$raiseBubbleEvent(source, args) {
///
///
///
var e = Function._validateParams(arguments, [
{name: "source"},
{name: "args", type: Sys.EventArgs}
]);
if (e) throw e;
var currentTarget = this.get_parent();
while (currentTarget) {
if (currentTarget.onBubbleEvent(source, args)) {
return;
}
currentTarget = currentTarget.get_parent();
}
}
function Sys$UI$Control$removeCssClass(className) {
///
///
var e = Function._validateParams(arguments, [
{name: "className", type: String}
]);
if (e) throw e;
if (!this._element) throw Error.invalidOperation(Sys.Res.cantBeCalledAfterDispose);
Sys.UI.DomElement.removeCssClass(this._element, className);
}
function Sys$UI$Control$toggleCssClass(className) {
///
///
var e = Function._validateParams(arguments, [
{name: "className", type: String}
]);
if (e) throw e;
if (!this._element) throw Error.invalidOperation(Sys.Res.cantBeCalledAfterDispose);
Sys.UI.DomElement.toggleCssClass(this._element, className);
}
Sys.UI.Control.prototype = {
_parent: null,
_visibilityMode: Sys.UI.VisibilityMode.hide,
get_element: Sys$UI$Control$get_element,
get_id: Sys$UI$Control$get_id,
set_id: Sys$UI$Control$set_id,
get_parent: Sys$UI$Control$get_parent,
set_parent: Sys$UI$Control$set_parent,
get_visibilityMode: Sys$UI$Control$get_visibilityMode,
set_visibilityMode: Sys$UI$Control$set_visibilityMode,
get_visible: Sys$UI$Control$get_visible,
set_visible: Sys$UI$Control$set_visible,
addCssClass: Sys$UI$Control$addCssClass,
dispose: Sys$UI$Control$dispose,
onBubbleEvent: Sys$UI$Control$onBubbleEvent,
raiseBubbleEvent: Sys$UI$Control$raiseBubbleEvent,
removeCssClass: Sys$UI$Control$removeCssClass,
toggleCssClass: Sys$UI$Control$toggleCssClass
}
Sys.UI.Control.registerClass('Sys.UI.Control', Sys.Component);
Type.registerNamespace('Sys');
Sys.Res={
"argumentTypeName":"Value is not the name of an existing type.",
"methodRegisteredTwice":"Method {0} has already been registered.",
"cantSetIdAfterInit":"The id property can\u0027t be set on this object after initialization.",
"cantBeCalledAfterDispose":"Can\u0027t be called after dispose.",
"componentCantSetIdAfterAddedToApp":"The id property of a component can\u0027t be set after it\u0027s been added to the Application object.",
"behaviorDuplicateName":"A behavior with name \u0027{0}\u0027 already exists or it is the name of an existing property on the target element.",
"notATypeName":"Value is not a valid type name.",
"typeShouldBeTypeOrString":"Value is not a valid type or a valid type name.",
"boolTrueOrFalse":"Value must be \u0027true\u0027 or \u0027false\u0027.",
"stringFormatInvalid":"The format string is invalid.",
"referenceNotFound":"Component \u0027{0}\u0027 was not found.",
"enumReservedName":"\u0027{0}\u0027 is a reserved name that can\u0027t be used as an enum value name.",
"eventHandlerNotFound":"Handler not found.",
"circularParentChain":"The chain of control parents can\u0027t have circular references.",
"undefinedEvent":"\u0027{0}\u0027 is not an event.",
"notAMethod":"{0} is not a method.",
"propertyUndefined":"\u0027{0}\u0027 is not a property or an existing field.",
"eventHandlerInvalid":"Handler was not added through the Sys.UI.DomEvent.addHandler method.",
"scriptLoadFailedDebug":"The script \u0027{0}\u0027 failed to load. Check for:\r\n Inaccessible path.\r\n Script errors. (IE) Enable \u0027Display a notification about every script error\u0027 under advanced settings.\r\n Missing call to Sys.Application.notifyScriptLoaded().",
"propertyNotWritable":"\u0027{0}\u0027 is not a writable property.",
"enumInvalidValueName":"\u0027{0}\u0027 is not a valid name for an enum value.",
"controlAlreadyDefined":"A control is already associated with the element.",
"addHandlerCantBeUsedForError":"Can\u0027t add a handler for the error event using this method. Please set the window.onerror property instead.",
"namespaceContainsObject":"Object {0} already exists and is not a namespace.",
"cantAddNonFunctionhandler":"Can\u0027t add a handler that is not a function.",
"scriptLoaderAlreadyLoading":"ScriptLoader.loadScripts cannot be called while the ScriptLoader is already loading scripts.",
"invalidNameSpace":"Value is not a valid namespace identifier.",
"notAnInterface":"Value is not a valid interface.",
"eventHandlerNotFunction":"Handler must be a function.",
"propertyNotAnArray":"\u0027{0}\u0027 is not an Array property.",
"typeRegisteredTwice":"Type {0} has already been registered. The type may be defined multiple times or the script file that defines it may have already been loaded. A possible cause is a change of settings during a partial update.",
"cantSetNameAfterInit":"The name property can\u0027t be set on this object after initialization.",
"appDuplicateComponent":"Two components with the same id \u0027{0}\u0027 can\u0027t be added to the application.",
"appComponentMustBeInitialized":"Components must be initialized before they are added to the Application object.",
"baseNotAClass":"Value is not a class.",
"methodNotFound":"No method found with name \u0027{0}\u0027.",
"arrayParseBadFormat":"Value must be a valid string representation for an array. It must start with a \u0027[\u0027 and end with a \u0027]\u0027.",
"cantSetId":"The id property can\u0027t be set on this object.",
"stringFormatBraceMismatch":"The format string contains an unmatched opening or closing brace.",
"enumValueNotInteger":"An enumeration definition can only contain integer values.",
"propertyNullOrUndefined":"Cannot set the properties of \u0027{0}\u0027 because it returned a null value.",
"argumentDomNode":"Value must be a DOM element or a text node.",
"componentCantSetIdTwice":"The id property of a component can\u0027t be set more than once.",
"createComponentOnDom":"Value must be null for Components that are not Controls or Behaviors.",
"createNotComponent":"{0} does not derive from Sys.Component.",
"createNoDom":"Value must not be null for Controls and Behaviors.",
"cantAddWithoutId":"Can\u0027t add a component that doesn\u0027t have an id.",
"badTypeName":"Value is not the name of the type being registered or the name is a reserved word.",
"argumentInteger":"Value must be an integer.",
"scriptLoadMultipleCallbacks":"The script \u0027{0}\u0027 contains multiple calls to Sys.Application.notifyScriptLoaded(). Only one is allowed.",
"invokeCalledTwice":"Cannot call invoke more than once.",
"webServiceFailed":"The server method \u0027{0}\u0027 failed with the following error: {1}",
"webServiceInvalidJsonWrapper":"The server method \u0027{0}\u0027 returned invalid data. The \u0027d\u0027 property is missing from the JSON wrapper.",
"argumentType":"Object cannot be converted to the required type.",
"argumentNull":"Value cannot be null.",
"controlCantSetId":"The id property can\u0027t be set on a control.",
"formatBadFormatSpecifier":"Format specifier was invalid.",
"webServiceFailedNoMsg":"The server method \u0027{0}\u0027 failed.",
"argumentDomElement":"Value must be a DOM element.",
"invalidExecutorType":"Could not create a valid Sys.Net.WebRequestExecutor from: {0}.",
"cannotCallBeforeResponse":"Cannot call {0} when responseAvailable is false.",
"actualValue":"Actual value was {0}.",
"enumInvalidValue":"\u0027{0}\u0027 is not a valid value for enum {1}.",
"scriptLoadFailed":"The script \u0027{0}\u0027 could not be loaded.",
"parameterCount":"Parameter count mismatch.",
"cannotDeserializeEmptyString":"Cannot deserialize empty string.",
"formatInvalidString":"Input string was not in a correct format.",
"invalidTimeout":"Value must be greater than or equal to zero.",
"cannotAbortBeforeStart":"Cannot abort when executor has not started.",
"argument":"Value does not fall within the expected range.",
"cannotDeserializeInvalidJson":"Cannot deserialize. The data does not correspond to valid JSON.",
"invalidHttpVerb":"httpVerb cannot be set to an empty or null string.",
"nullWebRequest":"Cannot call executeRequest with a null webRequest.",
"eventHandlerInvalid":"Handler was not added through the Sys.UI.DomEvent.addHandler method.",
"cannotSerializeNonFiniteNumbers":"Cannot serialize non finite numbers.",
"argumentUndefined":"Value cannot be undefined.",
"webServiceInvalidReturnType":"The server method \u0027{0}\u0027 returned an invalid type. Expected type: {1}",
"servicePathNotSet":"The path to the web service has not been set.",
"argumentTypeWithTypes":"Object of type \u0027{0}\u0027 cannot be converted to type \u0027{1}\u0027.",
"cannotCallOnceStarted":"Cannot call {0} once started.",
"badBaseUrl1":"Base URL does not contain ://.",
"badBaseUrl2":"Base URL does not contain another /.",
"badBaseUrl3":"Cannot find last / in base URL.",
"setExecutorAfterActive":"Cannot set executor after it has become active.",
"paramName":"Parameter name: {0}",
"cannotCallOutsideHandler":"Cannot call {0} outside of a completed event handler.",
"cannotSerializeObjectWithCycle":"Cannot serialize object with cyclic reference within child properties.",
"format":"One of the identified items was in an invalid format.",
"assertFailedCaller":"Assertion Failed: {0}\r\nat {1}",
"argumentOutOfRange":"Specified argument was out of the range of valid values.",
"webServiceTimedOut":"The server method \u0027{0}\u0027 timed out.",
"notImplemented":"The method or operation is not implemented.",
"assertFailed":"Assertion Failed: {0}",
"invalidOperation":"Operation is not valid due to the current state of the object.",
"breakIntoDebugger":"{0}\r\n\r\nBreak into debugger?"
};
if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded(); |