1// Name: MicrosoftAjax.debug.js 2// Assembly: AjaxControlToolkit 3// Version: 4.1.7.123 4// FileVersion: 4.1.7.0123 5// (c) 2010 CodePlex Foundation 6 7(function(window, Sys) { 8 9var merge = function _merge(target) { 10 target = target || {}; 11 foreach(arguments, function(o) { 12 if (o) { 13 forIn(o, function(v, n) { 14 target[n] = v; 15 }); 16 } 17 }, 1); 18 return target; 19} 20var forIn = function _forIn(obj, callback) { 21 for (var x in obj) { 22 callback(obj[x], x); 23 } 24} 25var foreach = function _foreach(arr, callback, start) { 26 var cancelled; 27 if (arr) { 28 arr = arr !== window && typeof(arr.nodeType) === "undefined" && 29 (arr instanceof Array || 30 (typeof(arr.length) === 'number' && (typeof(arr.callee) === "function" || (arr.item && typeof(arr.nodeType) === "undefined") && !arr.addEventListener && !arr.attachEvent))) 31 ? arr : [arr]; 32 for (var i = start||0, l = arr.length; i < l; i++) { 33 if (callback(arr[i], i)) { 34 cancelled = true; 35 break; 36 } 37 } 38 } 39 return !cancelled; 40} 41var callIf = function _callIf(obj, name, args) { 42 var fn = obj[name], 43 exists = typeof(fn) === "function"; 44 if (exists) fn.call(obj, args); 45 return exists; 46} 47if (!Sys || !Sys.loader) { 48 function append(target) { 49 target = target || {}; 50 foreach(arguments, function(o) { 51 if (o) { 52 forIn(o, function(v, n) { 53 if (typeof(target[n]) === "undefined") target[n] = v; 54 }); 55 } 56 }, 1); 57 return target; 58 } 59 60 var attachEvent = !!document.attachEvent; 61 62 function getAndDelete(obj, field) { 63 var r = obj[field]; 64 delete obj[field]; 65 return r; 66 } 67 function foreachCall(obj, field, args) { 68 foreach(getAndDelete(obj, field), function(callback) { 69 callback.apply(null, args||[]); 70 }); 71 } 72 function lazyget(obj, name, value) { 73 return obj ? (obj[name] = obj[name] || value) : value; 74 } 75 function lazypush(obj, name, value) { 76 lazyget(obj, name, []).push(value); 77 } 78 function lazyset(obj, name, key, value) { 79 lazyget(obj, name, {})[key] = value; 80 } 81 function all(tag, element) { 82 return (element||document).getElementsByTagName(tag); 83 } 84 function createElement(tag) { 85 return document.createElement(tag); 86 } 87 function listenOnce(target, name, ieName, callback, isReadyState, isScript) { 88 function onEvent() { 89 if (!attachEvent || !isReadyState || /loaded|complete/.test(target.readyState)) { 90 if (attachEvent) { 91 target.detachEvent(ieName || ("on" + name), onEvent); 92 } 93 else { 94 target.removeEventListener(name, onEvent, false); 95 if (isScript) { 96 target.removeEventListener("error", onEvent, false); 97 } 98 } 99 callback.apply(target); 100 target = null; 101 } 102 } 103 if (attachEvent) { 104 target.attachEvent(ieName || ("on" + name), onEvent); 105 } 106 else { 107 if (target.addEventListener) { 108 target.addEventListener(name, onEvent, false); 109 } 110 if (isScript) { 111 target.addEventListener("error", onEvent, false); 112 } 113 } 114 } 115 function raiseDomReady() { 116 if (Sys._domReady) { 117 Sys._2Pass(getAndDelete(Sys, "_domReadyQueue")); 118 } 119 } 120 function raiseOnReady() { 121 var ready = Sys._ready; 122 if (!ready && Sys._domReady && !(Sys.loader && Sys.loader._loading)) { 123 Sys._ready = ready = true; 124 } 125 if (ready) { 126 Sys._2Pass(getAndDelete(Sys, "_readyQueue")); 127 } 128 } 129 window.Sys = Sys = append(Sys, { 130 version: [3, 0, 31106, 0], 131 __namespace: true, 132 debug: true, 133 scripts: {}, 134 activateDom: true, 135 composites: {}, 136 components: {}, 137 plugins: {}, 138 create: {}, 139 converters: {}, 140 _domLoaded: function _domLoaded() { 141 if (Sys._domChecked) return; 142 Sys._domChecked = true; 143 function domReady() { 144 if (!Sys._domReady) { 145 Sys._domReady = true; 146 var autoRequire = Sys._autoRequire; 147 if (autoRequire) { 148 Sys.require(autoRequire, function() { 149 Sys._autoRequire = null; 150 foreachCall(Sys, "_autoQueue"); 151 }, autoToken); 152 } 153 raiseDomReady(); 154 raiseOnReady(); 155 } 156 } 157 listenOnce(window, "load", null, domReady); 158 159 var check; 160 if (attachEvent) { 161 if ((window == window.top) && document.documentElement.doScroll) { 162 var timeout, er, el = createElement("div"); 163 check = function() { 164 try { 165 el.doScroll("left"); 166 } 167 catch (er) { 168 timeout = window.setTimeout(check, 0); 169 return; 170 } 171 el = null; 172 domReady(); 173 } 174 check(); 175 } 176 else { 177 listenOnce(document, null, "onreadystatechange", domReady, true); 178 } 179 } 180 else if (document.addEventListener) { 181 listenOnce(document, "DOMContentLoaded", null, domReady); 182 } 183 }, 184 _getById: function _getById(found, id, single, includeSelf, element, filter) { 185 if (element) {
186 if (includeSelf && (element.id === id)) { 187 found.push(element); 188 } 189 else if (!filter) { 190 foreach(all("*", element), function(element) { 191 if (element.id === id) { 192 found.push(element); 193 return true; 194 } 195 }); 196 } 197 } 198 else { 199 var e = document.getElementById(id); 200 if (e) found.push(e); 201 } 202 return found.length; 203 }, 204 _getByClass: function _getByClass(found, targetClass, single, includeSelf, element, filter) { 205 function pushIfMatch(element) { 206 var ret, className = element.className; 207 if (className && ((className === targetClass) || (className.indexOf(' ' + targetClass) >= 0) || (className.indexOf(targetClass + ' ') >= 0))) { 208 found.push(element); 209 ret = true; 210 } 211 return ret; 212 } 213 var i, l, nodes; 214 if (includeSelf && pushIfMatch(element) && single) { 215 return true; 216 } 217 if (!filter) { 218 element = element || document; 219 var finder = element.querySelectorAll || element.getElementsByClassName; 220 if (finder) { 221 if (element.querySelectorAll) targetClass = "." + targetClass; 222 nodes = finder.call(element, targetClass); 223 for (i = 0, l = nodes.length; i < l; i++) { 224 found.push(nodes[i]); 225 if (single) return true; 226 } 227 } 228 else { 229 nodes = all("*", element); 230 for (i = 0, l = nodes.length; i < l; i++) { 231 if (pushIfMatch(nodes[i]) && single) { 232 return true; 233 } 234 } 235 } 236 } 237 }, 238 query: function query(selector, context) { 239 /// <summary>Queries the DOM for a set of DOM elements.</summary> 240 /// <validationOptions enabled="false" /> 241 /// <param name="selector">Selector for a set of DOM elements based on id (#<id>), class (.<name>), or tag name (<tagname>). Also supports an array of DOM elements or selectors. More complex selectors may be used if jQuery is loaded.</param> 242 /// <param name="context" optional="true" mayBeNull="true">A DOM element (exclusive), array of DOM elements (inclusive), or other Sys.ElementSet or Sys.UI.TemplateContext (exclusive) to restrict the search within.</param> 243 /// <returns type="Sys.ElementSet">An object representing the set of matching elements.</returns> 244 return new Sys.ElementSet(selector, context); 245 }, 246 get: function get(selector, context) { 247 /// <summary>Queries the DOM for a single DOM element.</summary> 248 /// <validationOptions enabled="false" /> 249 /// <param name="selector"> 250 /// Selector for a DOM element based on id (#<id>), class (.<name>), or tag name (<tagname>). More complex selectors may be used if jQuery is loaded. 251 /// If multiple elements match the selector, the first one is returned. 252 /// </param> 253 /// <param name="context" optional="true" mayBeNull="true">An element, array of elements, or Sys.UI.TemplateContext to restrict the query within.</param> 254 /// <returns>The matching element, or null if none match.</returns> 255 return (context && typeof(context.get) === "function") ? 256 context.get(selector) : 257 this._find(selector, context, true); 258 }, 259 _find: function _find(selector, context, single, filter) { 260 var found = [], 261 selectors; 262 if (typeof(selector) === "string") { 263 selectors = [selector]; 264 } 265 else { 266 selectors = selector; 267 } 268 var includeSelf = context instanceof Array, 269 simpleNonTag = /^([\$#\.])((\w|[$:\.\-])+)$/, 270 tag = /^((\w+)|\*)$/; 271 if ((typeof(context) === "string") || (context instanceof Array)) { 272 context = Sys._find(context); 273 } 274 if (context instanceof Sys.ElementSet) { 275 context = context.get(); 276 } 277 foreach(selectors, function(selector) { 278 if (typeof(selector) !== "string") { 279 if (filter) { 280 if (contains(context, selector)) { 281 found.push(selector); 282 } 283 } 284 else { 285 found.push(selector); 286 } 287 } 288 else { 289 var match = simpleNonTag.exec(selector); 290 if (match && match.length === 4) { 291 selector = match[2]; 292 var type = match[1]; 293 if (type === "$") { 294 Sys._getComponent(found, selector, context); 295 } 296 else { 297 var finder = type === "#" ? Sys._getById : Sys._getByClass; 298 if (context) { 299 foreach(context, function(node) { 300 if (node.nodeType === 1) { 301 return finder(found, selector, single, includeSelf, node, filter); 302 } 303 }); 304 } 305 else { 306 finder(found, selector, single); 307 } 308 } 309 } 310 else if (tag.test(selector)) { 311 if (context instanceof Array) { 312 foreach(context, function(node) { 313 if (node.nodeType === 1) { 314 if (includeSelf && (selector === "*" || (node.tagName.toLowerCase() === selector))) { 315 found.push(node); 316 if (single) return true; 317 } 318 if (!filter) { 319 if(!foreach(all(selector, node), function(node) { 320 found.push(node); 321 if (single) return true; 322 })) { 323 return true; 324 } 325 } 326 } 327 }); 328 } 329 else { 330 var nodes = all(selector, context); 331 if (single) { 332 if (nodes[0]) { 333 found.push(nodes[0]); 334 } 335 return true; 336 } 337 foreach(nodes, function(node) { 338 found.push(node); 339 }); 340 } 341 } 342 else if (window.jQuery) { 343 if (!filter) { 344 found.push.apply(found, jQuery(selector, context).get()); 345 } 346 if (includeSelf) { 347 found.push.apply(found, jQuery(context).filter(selector).get()); 348 } 349 } 350 } 351 }); 352 return found.length ? (single ? (found[0] || null) : found) : null; 353 }, 354 onDomReady: function onDomReady(callback) { 355 /// <summary>Registers a function to be called when the DOM is ready.</summary> 356 /// <validationOptions enabled="false" /> 357 /// <param name="callback" type="Function"></param> 358 lazypush(this, "_domReadyQueue", callback); 359 raiseDomReady(); 360 }, 361 onReady: function onReady(callback) { 362 /// <summary>Registers a function to be called when the DOM is ready and when all required resources have been loaded.</summary> 363 /// <validationOptions enabled="false" /> 364 /// <param name="callback" type="Function"></param> 365 lazypush(this, "_readyQueue", callback); 366 raiseOnReady(); 367 }, 368 _set: function(instance, properties) { 369 forIn(properties, function(value, field) { 370 callIf(instance, "add_" + field, value) || 371 callIf(instance, "set_" + field, value) || 372 (instance[field] = value); 373 }); 374 } 375 });
376 377 Sys._getComponent = Sys._getComponent || function() { } 378 379 Sys._2Pass = Sys._2Pass || function _2Pass(callback) { 380 foreach(callback, function(c) { c(); }); 381 } 382 383 var obj; 384 if (!Sys.ElementSet) { 385obj = Sys.ElementSet = function(selector, context) { 386 /// <summary>Represents a set of DOM elements.</summary> 387 /// <param name="selector">The DOM selector, array of DOM selectors, or array of DOM elements to query the document for.</param> 388 /// <param name="context">A DOM selector (exclusive), A DOM element (exclusive), array of DOM elements (inclusive), or other Sys.ElementSet (exclusive) to restrict the search within.</param> 389 this._elements = ((typeof(context) === "object") && typeof(context.query) === "function") ? 390 context.query(selector).get() : 391 Sys._find(selector, context) || []; 392} 393obj.prototype = { 394 __class: true, 395 components: function(type, index) { 396 /// <summary>Gets the set of controls and behaviors associated with the current DOM elements.</summary> 397 /// <param name="type" type="Function" mayBeNull="true" optional="true">Type to limit the search to.</param> 398 /// <param name="index" type="Number" mayBeNull="true" optional="true">Index of the component to limit to.</param> 399 /// <returns type="Sys.ComponentSet" /> 400 var elementSet = new Sys.ElementSet(this.get()); 401 return new Sys.ComponentSet(elementSet, type, index); 402 }, 403 component: function(type, index) { 404 /// <summary>Get the first control or behavior associated with the current set of DOM elements.</summary> 405 /// <param name="type" type="Function" mayBeNull="true" optional="true">Type to limit the search to.</param> 406 /// <param name="index" type="Number" mayBeNull="true" optional="true">Index of the component to return.</param> 407 /// <returns type="Object" mayBeNull="true" /> 408 return this.components(type, index).get(0); 409 }, 410 each: function(callback) { 411 /// <summary>Enumerates all the matched elements, calling the given callback for each with the current element as the context. 412 /// The callback may return false to cancel enumeration.</summary> 413 /// <returns type="Sys.ElementSet"/> 414 var elements = this._elements; 415 for (var i = 0, l = elements.length; i < l; i++) { 416 if (callback.call(elements[i], i) === false) break; 417 } 418 return this; 419 }, 420 get: function(index) { 421 /// <summary>Retrieves the element at the specified index.</summary> 422 /// <param name="index" type="Number">The index of the element to retrieve. Omit to return all elements as an array.</param> 423 /// <returns isDomElement="true">The element at the given index, or an array of all the matched elements.</returns> 424 var elements = this._elements; 425 return (typeof(index) === "undefined") ? (Array.apply(null, elements)) : (elements[index] || null); 426 }, 427 find: function(selector) { 428 /// <summary>Searches the current set of DOM elements with the given selector, including descendents.</summary> 429 /// <param name="selector">DOM selector or array of DOM selectors to search with.</param> 430 /// <returns type="Sys.ElementSet">A new element set with the matched elements.</returns> 431 return new Sys.ElementSet(selector, this); 432 }, 433 filter: function(selector) { 434 /// <summary>Filters the current set of DOM elements by the given selector, excluding descendents.</summary> 435 /// <param name="selector">DOM selector or array of elements to filter by.</param> 436 /// <returns type="Sys.ElementSet">A new element set with the matched elements.</returns> 437 return new Sys.ElementSet(Sys._find(selector, this._elements, false, true)); 438 } 439} 440 } 441 if (!Sys.ComponentSet) { 442obj = Sys.ComponentSet = function ComponentSet(elementSet, query, index) { 443 /// <summary></summary> 444 /// <param name="elementSet" type="Sys.ElementSet" mayBeNull="true" optional="true"></param> 445 /// <param name="query" mayBeNull="true" optional="true">The type of component to filter by, or an array of components to include.</param> 446 /// <param name="index" type="Number" mayBeNull="true" optional="true">The index of the component to retrieve from the filtered list.</param> 447 this._elementSet = elementSet || (elementSet = new Sys.ElementSet()); 448 this._components = this._execute(elementSet, query, index); 449} 450obj.prototype = { 451 __class: true, 452 setProperties: function ComponentSet$setProperties(properties) { 453 /// <summary>Sets properties on the matched components.</summary> 454 /// <param name="properties" type="Object" mayBeNull="false">Object with the names and values of the properties to set.</param> 455 /// <returns type="Sys.ComponentSet" /> 456 return this.each(function() { 457 Sys._set(this, properties); 458 }); 459 }, 460 get: function ComponentSet$get(index) { 461 /// <summary>Returns the component at the specified index, or an array of all matches if not specified.</summary> 462 /// <param name="index" type="Number" mayBeNull="true" optional="true"></param> 463 /// <returns type="Object" mayBeNull="true"/> 464 var components = this._components; 465 return (typeof(index) === "undefined") ? (Array.apply(null, components)) : (components[index || 0] || null); 466 }, 467 each: function ComponentSet$each(callback) { 468 /// <summary>Enumerate all the found components. The index of the component are passed as parameters to a callback. You may return 'fal
468se' to cancel the enumeration.</summary> 469 /// <param name="callback" type="Function" mayBeNull="false">Function called for each component.</param> 470 /// <returns type="Sys.ComponentSet" /> 471 foreach(this._components, function(c, i) { 472 if (callback.call(c, i) === false) { 473 return true; 474 } 475 }); 476 return this; 477 }, 478 elements: function ComponentSet$elements() { 479 /// <summary>Returns the underlying set of elements this component collection came from.</summary> 480 /// <returns type="Sys.ElementSet" /> 481 return this._elementSet; 482 }, 483 _execute: function ComponentSet$_execute(elementSet, query, index) { 484 var components = []; 485 function match(c) { 486 var ctor; 487 return (c instanceof query) || 488 ((ctor = c.constructor) && ( 489 (ctor === query) || 490 (ctor.inheritsFrom && ctor.inheritsFrom(query)) || 491 (ctor.implementsInterface && ctor.implementsInterface(query)))); 492 } 493 if (query instanceof Array) { 494 components.push.apply(components, query); 495 } 496 else { 497 elementSet.each(function() { 498 var c = this.control; 499 if (c && (!query || match(c))) { 500 components.push(c); 501 } 502 foreach(this._behaviors, function(b) { 503 if (!query || match(b)) { 504 components.push(b); 505 } 506 }); 507 }); 508 } 509 if ((typeof(index) !== "undefined")) { 510 if (components[index]) { 511 components = [components[index]]; 512 } 513 else { 514 components = []; 515 } 516 } 517 return components; 518 } 519} 520 } 521 522 obj = null; 523} 524 var getCreate = function _getCreate(options, isPlugin) { 525 var body = [], 526 arglist = [], 527 type = options.type, 528 typeName = options.typeName || (type ? type.getName() : ""), 529 isBehavior = options._isBehavior, 530 description = (options && options.description) || 531 (type && ("Creates an instance of the type '" + typeName + "' and sets the given properties.")) || 532 ""; 533 body.push("/// <summary>", description, "</summary>\n"); 534 foreach(options && options.parameters, function(parameter) { 535 var name = parameter, type = '', desc = ''; 536 if (typeof(parameter) !== "string") { 537 name = parameter.name; 538 type = parameter.type||''; 539 desc = parameter.description||''; 540 } 541 arglist.push(name); 542 body.push('/// <param name="', name, '"'); 543 if (type) { 544 body.push(' type="', type, '"'); 545 } 546 body.push('>', desc, '</param>\n'); 547 }); 548 var returnType; 549 if (!isPlugin) { 550 arglist.push("properties"); 551 body.push('/// <param name="properties" type="Object" mayBeNull="true" optional="true">Additional properties to set on the component.</param>\n'); 552 returnType = isBehavior ? 'Sys.ComponentSet' : typeName; 553 } 554 else { 555 returnType = options.returnType; 556 } 557 if (returnType) { 558 body.push('/// <returns type="', returnType, '" />\n'); 559 } 560 if (isPlugin) { 561 body.push('return Sys.plugins["', options.name, '"].plugin.apply(this, arguments);'); 562 } 563 else { 564 body.push('return Sys._createComp.call(this, arguments.callee._component, arguments.callee._component.defaults, arguments);'); 565 } 566 arglist.push(body.join('')); 567 568 var fn = Function.apply(null, arglist); 569 if (!isPlugin) { 570 fn._component = options; 571 } 572 return fn; 573 574 } 575 Sys._getCreate = getCreate; 576 577function execute() { 578 579var $type, $prototype; 580Sys._foreach = foreach; 581Sys._forIn = forIn; 582Sys._merge = merge; 583Sys._callIf = callIf; 584 585$type = Function;
586$type.__typeName = 'Function'; 587$type.__class = true; 588 589$type.createCallback = function Function$createCallback(method, context) { 590 /// <summary locid="M:J#Function.createCallback">Creates a callback function that retains the parameter initially used during its creation. The callback is used without parameter but this will call the actual method with the parameter. This is especially useful when setting up a handler for a DOM event that must retain a parameter despite the DOM event handler needing to be a function with the event object as the only parameter. In this case, the function will be called with the event as the first parameter and the context as the second. If the callback is called with an arbitrary list of parameters, the context is appended.</summary> 591 /// <param name="method" type="Function">The function for which the callback is created.</param> 592 /// <param name="context" mayBeNull="true">The parameter for the function.</param> 593 /// <returns type="Function">The callback function.</returns> 594 var e = Function._validateParams(arguments, [ 595 {name: "method", type: Function}, 596 {name: "context", mayBeNull: true} 597 ]); 598 if (e) throw e; 599 600 601 return function() { 602 var l = arguments.length; 603 if (l > 0) { 604 var args = []; 605 for (var i = 0; i < l; i++) { 606 args[i] = arguments[i]; 607 } 608 args[l] = context; 609 return method.apply(this, args); 610 } 611 return method.call(this, context); 612 } 613} 614 615$type.createDelegate = function Function$createDelegate(instance, method) { 616 /// <summary locid="M:J#Function.createDelegate">Creates a delegate function that retains the context from its creation (i.e. what 'this' means from within its scope). This is especially useful when setting up an event handler to point to an object method that needs to use the 'this' pointer from within its scope.</summary> 617 /// <param name="instance" mayBeNull="true">The object instance that will be the context for the function (i.e. what 'this' means from within its scope).</param> 618 /// <param name="method" type="Function">The function from which the delegate is created.</param> 619 /// <returns type="Function">The delegate function.</returns> 620 var e = Function._validateParams(arguments, [ 621 {name: "instance", mayBeNull: true}, 622 {name: "method", type: Function} 623 ]); 624 if (e) throw e; 625 626 627 return function() { 628 return method.apply(instance, arguments); 629 } 630} 631 632$type.emptyFunction = $type.emptyMethod = function Function$emptyMethod() { 633 /// <summary locid="M:J#Function.emptyMethod">A function that does nothing.</summary> 634} 635 636$type.validateParameters = function Function$validateParameters(parameters, expectedParameters, validateParameterCount) { 637 /// <summary locid="M:J#Function.validateParameters">Validates the parameters to a method are as expected.</summary> 638 /// <param name="parameters"></param> 639 /// <param name="expectedParameters"></param> 640 /// <param name="validateParameterCount" type="Boolean" optional="true" mayBeNull="true">True if extra parameters are prohibited, false if they should be ignored. The default is true.</param> 641 /// <returns type="Error" mayBeNull="true"></returns> 642 var e = Function._validateParams(arguments, [ 643 {name: "parameters"}, 644 {name: "expectedParameters"}, 645 {name: "validateParameterCount", type: Boolean, mayBeNull: true, optional: true} 646 ]); 647 if (e) throw e; 648 return Function._validateParams(parameters, expectedParameters, validateParameterCount); 649} 650 651$type._validateParams = function Function$_validateParams(params, expectedParams, validateParameterCount) { 652 var e, expectedLength = expectedParams.length; 653 validateParameterCount = validateParameterCount !== false; 654 e = Function._validateParameterCount(params, expectedParams, validateParameterCount); 655 if (e) { 656 e.popStackFrame(); 657 return e; 658 } 659 for (var i = 0, l = params.length; i < l; i++) { 660 var expectedParam = expectedParams[Math.min(i, expectedLength - 1)], 661 paramName = expectedParam.name; 662 if (expectedParam.parameterArray) { 663 paramName += "[" + (i - expectedLength + 1) + "]"; 664 } 665 else if (!validateParameterCount && (i >= expectedLength)) { 666 break; 667 } 668 e = Function._validateParameter(params[i], expectedParam, paramName); 669 if (e) { 670 e.popStackFrame(); 671 return e; 672 } 673 } 674 return null; 675} 676 677$type._validateParameterCount = function Function$_validateParameterCount(params, expectedParams, validateParameterCount) { 678 var i, error, 679 expectedLen = expectedParams.length, 680 actualLen = params.length; 681 if (actualLen < expectedLen) { 682 var minParams = expectedLen; 683 for (i = 0; i < expectedLen; i++) { 684 var param = expectedParams[i]; 685 if (param.optional || param.parameterArray) { 686 minParams--; 687 } 688 } 689 if (actualLen < minParams) { 690 error = true; 691 } 692 } 693 else if (validateParameterCount && (actualLen > expectedLen)) { 694 error = true; 695 for (i = 0; i < expectedLen; i++) { 696 if (expectedParams[i].parameterArray) { 697 error = false; 698 break; 699 } 700 } 701 } 702 703 if (error) { 704 var e = Error.parameterCount(); 705 e.popStackFrame(); 706 return e; 707 } 708 709 return null; 710} 711 712$type._validateParameter = function Function$_validateParameter(param, expectedParam, paramName) { 713 var e, 714 expectedType = expectedParam.type, 715 expectedInteger = !!expectedParam.integer, 716 expectedDomElement = !!expectedParam.domElement, 717 mayBeNull = !!expectedParam.mayBeNull; 718 719 e = Function._validateParameterType(param, expectedType, expectedInteger, expectedDomElement, mayBeNull, paramName); 720 if (e) { 721 e.popStackFrame(); 722 return e; 723 } 724 725 var expectedElementType = expectedParam.elementType, 726 elementMayBeNull = !!expectedParam.elementMayBeNull; 727 if (expectedType === Array && typeof(param) !== "undefined" && param !== null && 728 (expectedElementType || !elementMayBeNull)) { 729 var expectedElementInteger = !!expectedParam.elementInteger, 730 expectedElementDomElement = !!expectedParam.elementDomElement; 731 for (var i=0; i < param.length; i++) { 732 var elem = param[i]; 733 e = Function._validateParameterType(elem, expectedElementType, 734 expectedElementInteger, expectedElementDomElement, elementMayBeNull, 735 paramName + "[" + i + "]"); 736 if (e) { 737 e.popStackFrame(); 738 return e; 739 } 740 } 741 } 742 743 return null; 744} 745 746$type._validateParameterType = function Function$_validateParameterType(param, expectedType, expectedInteger, expectedDomElement, mayBeNull, paramName) { 747 var e, i; 748 749 if (typeof(param) === "undefined" || param === null) { 750 if (mayBeNull) { 751 return null; 752 } 753 e = param === null ? Error.argumentNull(paramName) : Error.argumentUndefined(paramName); 754 e.popStackFrame(); 755 return e; 756 } 757 758 if (expectedType && expectedType.__enum) { 759 if (typeof(param) !== 'number') { 760 e = Error.argumentType(paramName, Object.getType(param), expectedType); 761 e.popStackFrame(); 762 return e; 763 } 764 if ((param % 1) === 0) { 765 var values = expectedType.prototype; 766 if (!expectedType.__flags || (param === 0)) { 767 for (i in values) { 768 if (values[i] === param) return null; 769 } 770 } 771 else { 772 var v = param; 773 for (i in values) {
774 var vali = values[i]; 775 if (vali === 0) continue; 776 if ((vali & param) === vali) { 777 v -= vali; 778 } 779 if (v === 0) return null; 780 } 781 } 782 } 783 e = Error.argumentOutOfRange(paramName, param, String.format(Sys.Res.enumInvalidValue, param, expectedType.getName())); 784 e.popStackFrame(); 785 return e; 786 } 787 788 if (expectedDomElement && (!Sys._isDomElement(param) || (param.nodeType === 3))) { 789 e = Error.argument(paramName, Sys.Res.argumentDomElement); 790 e.popStackFrame(); 791 return e; 792 } 793 794 if (expectedType && !Sys._isInstanceOfType(expectedType, param)) { 795 e = Error.argumentType(paramName, Object.getType(param), expectedType); 796 e.popStackFrame(); 797 return e; 798 } 799 800 if (expectedType === Number && expectedInteger) { 801 if ((param % 1) !== 0) { 802 e = Error.argumentOutOfRange(paramName, param, Sys.Res.argumentInteger); 803 e.popStackFrame(); 804 return e; 805 } 806 } 807 808 return null; 809} 810$type = Error; 811$type.__typeName = 'Error'; 812$type.__class = true; 813 814Sys._errorArgument = function(kind, paramName, message) { 815 var name = "Sys.Argument" + kind + "Exception"; 816 var displayMessage = name + ": " + (message || Sys.Res["argument"+kind]); 817 if (paramName) { 818 displayMessage += "\n" + String.format(Sys.Res.paramName, paramName); 819 } 820 821 var err = Error.create(displayMessage, { name: name, paramName: paramName }); 822 err.popStackFrame(); 823 err.popStackFrame(); 824 return err; 825} 826 827Sys._error = function(kind, message, defaultMessage) { 828 var name = "Sys." + kind + "Exception"; 829 var displayMessage = name + ": " + (message || Sys.Res[defaultMessage]); 830 var err = Error.create(displayMessage, {name: name}); 831 err.popStackFrame(); 832 err.popStackFrame(); 833 return err; 834} 835 836$type.create = function Error$create(message, errorInfo) { 837 /// <summary locid="M:J#Error.create">Use this method to create a new error.</summary> 838 /// <param name="message" type="String" optional="true" mayBeNull="true">The error message.</param> 839 /// <param name="errorInfo" optional="true" mayBeNull="true">A plain JavaScript object that contains extended information about the error. The object should have a 'name' field that contains a string that identifies the error and any additional fields that are necessary to fully describe the error.</param> 840 /// <returns type="Error">An Error object.</returns> 841 var e = Function._validateParams(arguments, [ 842 {name: "message", type: String, mayBeNull: true, optional: true}, 843 {name: "errorInfo", mayBeNull: true, optional: true} 844 ]); 845 if (e) throw e; 846 847 var err = new Error(message); 848 err.message = message; 849 850 if (errorInfo) { 851 for (var v in errorInfo) { 852 err[v] = errorInfo[v]; 853 } 854 } 855 856 err.popStackFrame(); 857 return err; 858} 859 860$type.argument = function Error$argument(paramName, message) { 861 /// <summary locid="M:J#Error.argument">Creates an ArgumentException with a specified error message and the name of the parameter that caused this exception.</summary> 862 /// <param name="paramName" type="String" optional="true" mayBeNull="true">The name of the parameter that caused the exception.</param> 863 /// <param name="message" type="String" optional="true" mayBeNull="true">A message that describes the error.</param> 864 /// <returns>An Error instance that represents an ArgumentException.</returns> 865 var e = Function._validateParams(arguments, [ 866 {name: "paramName", type: String, mayBeNull: true, optional: true}, 867 {name: "message", type: String, mayBeNull: true, optional: true} 868 ]); 869 if (e) throw e; 870 return Sys._errorArgument("", paramName, message); 871} 872 873$type.argumentNull = function Error$argumentNull(paramName, message) { 874 /// <summary locid="M:J#Error.argumentNull">Creates an ArgumentNullException with a specified error message and the name of the parameter that caused this exception.</summary> 875 /// <param name="paramName" type="String" optional="true" mayBeNull="true">The name of the parameter that caused the exception.</param> 876 /// <param name="message" type="String" optional="true" mayBeNull="true">A message that describes the error.</param> 877 /// <returns>An Error instance that represents an ArgumentNullException.</returns> 878 var e = Function._validateParams(arguments, [ 879 {name: "paramName", type: String, mayBeNull: true, optional: true}, 880 {name: "message", type: String, mayBeNull: true, optional: true} 881 ]); 882 if (e) throw e; 883 return Sys._errorArgument("Null", paramName, message); 884} 885 886$type.argumentOutOfRange = function Error$argumentOutOfRange(paramName, actualValue, message) { 887 /// <summary locid="M:J#Error.argumentOutOfRange">Creates an ArgumentOutOfRangeException with a specified error message and the name and actual value of the parameter that caused this exception.</summary> 888 /// <param name="paramName" type="String" optional="true" mayBeNull="true">The name of the parameter that caused the exception.</param> 889 /// <param name="actualValue" optional="true" mayBeNull="true">The actual value of the parameter.</param> 890 /// <param name="message" type="String" optional="true" mayBeNull="true">A message that describes the error.</param> 891 /// <returns>An Error instance that represents an ArgumentOutOfRangeException.</returns> 892 var e = Function._validateParams(arguments, [ 893 {name: "paramName", type: String, mayBeNull: true, optional: true}, 894 {name: "actualValue", mayBeNull: true, optional: true}, 895 {name: "message", type: String, mayBeNull: true, optional: true} 896 ]); 897 if (e) throw e; 898 899 var displayMessage = "Sys.ArgumentOutOfRangeException: " + (message || Sys.Res.argumentOutOfRange); 900 if (paramName) { 901 displayMessage += "\n" + String.format(Sys.Res.paramName, paramName); 902 } 903 904 if (typeof(actualValue) !== "undefined" && actualValue !== null) { 905 displayMessage += "\n" + String.format(Sys.Res.actualValue, actualValue); 906 } 907 908 var err = Error.create(displayMessage, { 909 name: "Sys.ArgumentOutOfRangeException", 910 paramName: paramName, 911 actualValue: actualValue 912 });
913 err.popStackFrame(); 914 return err; 915} 916 917$type.argumentType = function Error$argumentType(paramName, actualType, expectedType, message) { 918 /// <summary locid="M:J#Error.argumentType">Creates an ArgumentTypeException with a specified error message and the name, actual type, and expected type of the parameter that caused this exception.</summary> 919 /// <param name="paramName" type="String" optional="true" mayBeNull="true">The name of the parameter that caused the exception.</param> 920 /// <param name="actualType" type="Type" optional="true" mayBeNull="true">The actual type of the parameter value.</param> 921 /// <param name="expectedType" type="Type" optional="true" mayBeNull="true">The expected type of the parameter value.</param> 922 /// <param name="message" type="String" optional="true" mayBeNull="true">A message that describes the error.</param> 923 /// <returns>An Error instance that represents an ArgumentTypeException.</returns> 924 var e = Function._validateParams(arguments, [ 925 {name: "paramName", type: String, mayBeNull: true, optional: true}, 926 {name: "actualType", type: Type, mayBeNull: true, optional: true}, 927 {name: "expectedType", type: Type, mayBeNull: true, optional: true}, 928 {name: "message", type: String, mayBeNull: true, optional: true} 929 ]); 930 if (e) throw e; 931 932 var displayMessage = "Sys.ArgumentTypeException: "; 933 if (message) { 934 displayMessage += message; 935 } 936 else if (actualType && expectedType) { 937 displayMessage += 938 String.format(Sys.Res.argumentTypeWithTypes, actualType.getName(), expectedType.getName()); 939 } 940 else { 941 displayMessage += Sys.Res.argumentType; 942 } 943 944 if (paramName) { 945 displayMessage += "\n" + String.format(Sys.Res.paramName, paramName); 946 } 947 948 var err = Error.create(displayMessage, { 949 name: "Sys.ArgumentTypeException", 950 paramName: paramName, 951 actualType: actualType, 952 expectedType: expectedType 953 }); 954 err.popStackFrame(); 955 return err; 956} 957 958$type.argumentUndefined = function Error$argumentUndefined(paramName, message) { 959 /// <summary locid="M:J#Error.argumentUndefined">Creates an ArgumentUndefinedException with a specified error message and the name of the parameter that caused this exception.</summary> 960 /// <param name="paramName" type="String" optional="true" mayBeNull="true">The name of the parameter that caused the exception.</param> 961 /// <param name="message" type="String" optional="true" mayBeNull="true">A message that describes the error.</param> 962 /// <returns>An Error instance that represents an ArgumentUndefinedException.</returns> 963 var e = Function._validateParams(arguments, [ 964 {name: "paramName", type: String, mayBeNull: true, optional: true}, 965 {name: "message", type: String, mayBeNull: true, optional: true} 966 ]); 967 if (e) throw e; 968 return Sys._errorArgument("Undefined", paramName, message); 969} 970 971$type.format = function Error$format(message) { 972 /// <summary locid="M:J#Error.format">Creates a format error.</summary> 973 /// <param name="message" type="String" optional="true" mayBeNull="true">The error message.</param> 974 /// <returns>An Error object that represents a FormatException.</returns> 975 var e = Function._validateParams(arguments, [ 976 {name: "message", type: String, mayBeNull: true, optional: true} 977 ]); 978 if (e) throw e; 979 return Sys._error("Format", message, "format"); 980} 981 982$type.invalidOperation = function Error$invalidOperation(message) { 983 /// <summary locid="M:J#Error.invalidOperation">Creates an invalid operation error.</summary> 984 /// <param name="message" type="String" optional="true" mayBeNull="true">The error message.</param> 985 /// <returns>An Error instance that represents an InvalidOperationException.</returns> 986 var e = Function._validateParams(arguments, [ 987 {name: "message", type: String, mayBeNull: true, optional: true} 988 ]); 989 if (e) throw e; 990 return Sys._error("InvalidOperation", message, "invalidOperation"); 991} 992 993$type.notImplemented = function Error$notImplemented(message) { 994 /// <summary locid="M:J#Error.notImplemented">Creates a not implemented error.</summary> 995 /// <param name="message" type="String" optional="true" mayBeNull="true">The error message.</param> 996 /// <returns>An Error instance that represents a NotImplementedException.</returns> 997 var e = Function._validateParams(arguments, [ 998 {name: "message", type: String, mayBeNull: true, optional: true} 999 ]); 1000 if (e) throw e; 1001 return Sys._error("NotImplemented", message, "notImplemented"); 1002} 1003 1004$type.parameterCount = function Error$parameterCount(message) { 1005 /// <summary locid="M:J#Error.parameterCount">Creates a ParameterCountException with a specified error message.</summary> 1006 /// <param name="message" type="String" optional="true" mayBeNull="true">A message that describes the error.</param> 1007 /// <returns>An Error instance that represents a ParameterCountException.</returns> 1008 var e = Function._validateParams(arguments, [ 1009 {name: "message", type: String, mayBeNull: true, optional: true} 1010 ]); 1011 if (e) throw e; 1012 return Sys._error("ParameterCount", message, "parameterCount"); 1013} 1014 1015$type.prototype.popStackFrame = function Error$popStackFrame() { 1016 /// <summary locid="M:J#checkParam">Updates the fileName and lineNumber fields based on the next frame in the stack trace. Call this method whenever an instance of Error is returned from a function. This makes the fileName and lineNumber reported in the FireFox console point to the location where the exception was thrown, not the location where the instance of Error was created.</summary> 1017 if (arguments.length !== 0) throw Error.parameterCount(); 1018 1019 1020 if (typeof(this.stack) === "undefined" || this.stack === null || 1021 typeof(this.fileName) === "undefined" || this.fileName === null || 1022 typeof(this.lineNumber) === "undefined" || this.lineNumber === null) { 1023 return; 1024 } 1025 1026 var stackFrames = this.stack.split("\n"); 1027 1028 var currentFrame = stackFrames[0]; 1029 var pattern = this.fileName + ":" + this.lineNumber; 1030 while(typeof(currentFrame) !== "undefined" && 1031 currentFrame !== null && 1032 currentFrame.indexOf(pattern) < 0) { 1033 stackFrames.shift(); 1034 currentFrame = stackFrames[0]; 1035 } 1036 1037 var nextFrame = stackFrames[1]; 1038 1039 if (typeof(nextFrame) === "undefined" || nextFrame === null) { 1040 return; 1041 } 1042 1043 var nextFrameParts = nextFrame.match(/@(.*):(\d+)$/); 1044 if (typeof(nextFrameParts) === "undefined" || nextFrameParts === null) { 1045 return; 1046 } 1047 1048 this.fileName = nextFrameParts[1]; 1049 1050 this.lineNumber = parseInt(nextFrameParts[2]); 1051 1052 stackFrames.shift(); 1053 this.stack = stackFrames.join("\n"); 1054} 1055$type = Object; 1056$type.__typeName = 'Object'; 1057$type.__class = true; 1058 1059$type.getType = function Object$getType(instance) { 1060 /// <summary locid="M:J#Object.getType"></summary> 1061 /// <param name="instance">The object for which the type must be returned.</param> 1062 /// <returns type="Type">The type of the object.</returns> 1063 var e = Function._validateParams(arguments, [ 1064 {name: "instance"} 1065 ]); 1066 if (e) throw e; 1067 var ctor = instance.constructor; 1068 if (!ctor || (typeof(ctor) !== "function") || !ctor.__typeName || (ctor.__typeName === 'Object')) { 1069 return Object; 1070 } 1071 return ctor; 1072} 1073 1074$type.getTypeName = function Object$getTypeName(instance) { 1075 /// <summary locid="M:J#Object.getTypeName"></summary> 1076 /// <param name="instance">The object for which the type name must be returned.</param> 1077 /// <returns type="String">The name of the type of the object.</returns> 1078 var e = Function._validateParams(arguments, [ 1079 {name: "instance"} 1080 ]); 1081 if (e) throw e; 1082 return Object.getType(instance).getName(); 1083} 1084$type = String; 1085$type.__typeName = 'String'; 1086$type.__class = true; 1087 1088$prototype = $type.prototype; 1089$prototype.endsWith = function String$endsWith(suffix) { 1090 /// <summary locid="M:J#String.endsWith">Determines whether the end of this instance matches the specified string.</summary> 1091 /// <param name="suffix" type="String">
1091A string to compare to.</param> 1092 /// <returns type="Boolean">true if suffix matches the end of this instance; otherwise, false.</returns> 1093 var e = Function._validateParams(arguments, [ 1094 {name: "suffix", type: String} 1095 ]); 1096 if (e) throw e; 1097 return (this.substr(this.length - suffix.length) === suffix); 1098} 1099 1100$prototype.startsWith = function String$startsWith(prefix) { 1101 /// <summary locid="M:J#String.startsWith">Determines whether the beginning of this instance matches the specified string.</summary> 1102 /// <param name="prefix" type="String">The String to compare.</param> 1103 /// <returns type="Boolean">true if prefix matches the beginning of this string; otherwise, false.</returns> 1104 var e = Function._validateParams(arguments, [ 1105 {name: "prefix", type: String} 1106 ]); 1107 if (e) throw e; 1108 return (this.substr(0, prefix.length) === prefix); 1109} 1110 1111$prototype.trim = function String$trim() { 1112 /// <summary locid="M:J#String.trim">Removes all leading and trailing white-space characters from the current String object.</summary> 1113 /// <returns type="String">The string that remains after all white-space characters are removed from the start and end of the current String object.</returns> 1114 if (arguments.length !== 0) throw Error.parameterCount(); 1115 return this.replace(/^\s+|\s+$/g, ''); 1116} 1117 1118$prototype.trimEnd = function String$trimEnd() { 1119 /// <summary locid="M:J#String.trimEnd">Removes all trailing white spaces from the current String object.</summary> 1120 /// <returns type="String">The string that remains after all white-space characters are removed from the end of the current String object.</returns> 1121 if (arguments.length !== 0) throw Error.parameterCount(); 1122 return this.replace(/\s+$/, ''); 1123} 1124 1125$prototype.trimStart = function String$trimStart() { 1126 /// <summary locid="M:J#String.trimStart">Removes all leading white spaces from the current String object.</summary> 1127 /// <returns type="String">The string that remains after all white-space characters are removed from the start of the current String object.</returns> 1128 if (arguments.length !== 0) throw Error.parameterCount(); 1129 return this.replace(/^\s+/, ''); 1130} 1131 1132$type.format = function String$format(format, args) { 1133 /// <summary locid="M:J#String.format">Replaces the format items in a specified String with the text equivalents of the values of corresponding object instances. The invariant culture will be used to format dates and numbers.</summary> 1134 /// <param name="format" type="String">A format string.</param> 1135 /// <param name="args" parameterArray="true" mayBeNull="true">The objects to format.</param> 1136 /// <returns type="String">A copy of format in which the format items have been replaced by the string equivalent of the corresponding instances of object arguments.</returns> 1137 var e = Function._validateParams(arguments, [ 1138 {name: "format", type: String}, 1139 {name: "args", mayBeNull: true, parameterArray: true} 1140 ]); 1141 if (e) throw e; 1142 return String._toFormattedString(false, arguments); 1143} 1144 1145$type._toFormattedString = function String$_toFormattedString(useLocale, args) { 1146 var result = ''; 1147 var format = args[0]; 1148 1149 for (var i=0;;) { 1150 var open = format.indexOf('{', i); 1151 var close = format.indexOf('}', i); 1152 if ((open < 0) && (close < 0)) { 1153 result += format.slice(i); 1154 break; 1155 } 1156 if ((close > 0) && ((close < open) || (open < 0))) { 1157 if (format.charAt(close + 1) !== '}') { 1158 throw Error.argument('format', Sys.Res.stringFormatBraceMismatch); 1159 } 1160 result += format.slice(i, close + 1); 1161 i = close + 2; 1162 continue; 1163 } 1164 1165 result += format.slice(i, open); 1166 i = open + 1; 1167 1168 if (format.charAt(i) === '{') { 1169 result += '{'; 1170 i++; 1171 continue; 1172 } 1173 1174 if (close < 0) throw Error.argument('format', Sys.Res.stringFormatBraceMismatch); 1175 1176 1177 var brace = format.substring(i, close); 1178 var colonIndex = brace.indexOf(':'); 1179 var argNumber = parseInt((colonIndex < 0)? brace : brace.substring(0, colonIndex), 10) + 1; 1180 if (isNaN(argNumber)) throw Error.argument('format', Sys.Res.stringFormatInvalid); 1181 var argFormat = (colonIndex < 0)? '' : brace.substring(colonIndex + 1); 1182 1183 var arg = args[argNumber]; 1184 if (typeof(arg) === "undefined" || arg === null) { 1185 arg = ''; 1186 } 1187 1188 if (arg.toFormattedString) { 1189 result += arg.toFormattedString(argFormat); 1190 } 1191 else if (useLocale && arg.localeFormat) { 1192 result += arg.localeFormat(argFormat); 1193 } 1194 else if (arg.format) { 1195 result += arg.format(argFormat); 1196 } 1197 else 1198 result += arg.toString(); 1199 1200 i = close + 1; 1201 } 1202 1203 return result; 1204} 1205$type = Boolean; 1206$type.__typeName = 'Boolean'; 1207$type.__class = true; 1208 1209$type.parse = function Boolean$parse(value) { 1210 /// <summary locid="M:J#Boolean.parse">Creates a bool from its string representation.</summary> 1211 /// <param name="value" type="String">"true" or "false".</param> 1212 /// <returns type="Boolean"></returns> 1213 var e = Function._validateParams(arguments, [ 1214 {name: "value", type: String} 1215 ], false); 1216 if (e) throw e; 1217 var v = value.trim().toLowerCase(), 1218 r; 1219 if (v === 'false') { 1220 r = false; 1221 } 1222 else if (v === 'true') { 1223 r = true; 1224 } 1225 else { 1226 throw Error.argumentOutOfRange('value', value, Sys.Res.boolTrueOrFalse); 1227 } 1228 return r; 1229} 1230$type = Date; 1231$type.__typeName = 'Date'; 1232$type.__class = true; 1233$type = Number; 1234$type.__typeName = 'Number'; 1235$type.__class = true; 1236$type = RegExp; 1237$type.__typeName = 'RegExp'; 1238$type.__class = true; 1239if (!window) this.window = this; 1240 1241window.Type = $type = Function; 1242 1243$type.__fullyQualifiedIdentifierRegExp = new RegExp("^[^.0-9 \\s|,;:&*=+\\-()\\[\\]{}^%#@!~\\n\\r\\t\\f\\\\]([^ \\s|,;:&*=+\\-()\\[\\]{}^%#@!~\\n\\r\\t\\f\\\\]*[^. \\s|,;:&*=+\\-()\\[\\]{}^%#@!~\\n\\r\\t\\f\\\\])?$", "i"); 1244$type.__identifierRegExp = new RegExp("^[^.0-9 \\s|,;:&*=+\\-()\\[\\]{}^%#@!~\\n\\r\\t\\f\\\\][^. \\s|,;:&*=+\\-()\\[\\]{}^%#@!~\\n\\r\\t\\f\\\\]*$", "i"); 1245 1246$prototype = $type.prototype; 1247$prototype.callBaseMethod = function Type$callBaseMethod(instance, name, baseArguments) { 1248 /// <summary locid="M:J#Type.callBaseMethod"></summary> 1249 /// <param name="instance">The instance for the base method. Usually 'this'.</param> 1250 /// <param name="name" type="String">The name of the base method.</param> 1251 /// <param name="baseArguments" type="Array" optional="true" mayBeNull="true" elementMayBeNull="true">The arguments to pass to the base method.</param> 1252 /// <returns>The return value of the base method.</returns> 1253 var e = Function._validateParams(arguments, [ 1254 {name: "instance"}, 1255 {name: "name", type: String}, 1256 {name: "baseArguments", type: Array, mayBeNull: true, optional: true, elementMayBeNull: true} 1257 ]); 1258 if (e) throw e; 1259 var baseMethod = Sys._getBaseMethod(this, instance, name);
1260 if (!baseMethod) throw Error.invalidOperation(String.format(Sys.Res.methodNotFound, name)); 1261 return baseArguments ? baseMethod.apply(instance, baseArguments) : baseMethod.apply(instance); 1262} 1263 1264$prototype.getBaseMethod = function Type$getBaseMethod(instance, name) { 1265 /// <summary locid="M:J#Type.getBaseMethod">Use this method to get the base implementation of a method from the base class.</summary> 1266 /// <param name="instance">The instance for which the base method is needed. Usually 'this'.</param> 1267 /// <param name="name" type="String">The name of the method to get.</param> 1268 /// <returns type="Function" mayBeNull="true">The base method.</returns> 1269 var e = Function._validateParams(arguments, [ 1270 {name: "instance"}, 1271 {name: "name", type: String} 1272 ]); 1273 if (e) throw e; 1274 return Sys._getBaseMethod(this, instance, name); 1275} 1276 1277$prototype.getBaseType = function Type$getBaseType() { 1278 /// <summary locid="M:J#Type.getBaseType"></summary> 1279 /// <returns type="Type" mayBeNull="true">The base type.</returns> 1280 if (arguments.length !== 0) throw Error.parameterCount(); 1281 return (typeof(this.__baseType) === "undefined") ? null : this.__baseType; 1282} 1283 1284$prototype.getInterfaces = function Type$getInterfaces() { 1285 /// <summary locid="M:J#Type.getInterfaces"></summary> 1286 /// <returns type="Array" elementType="Type" mayBeNull="false" elementMayBeNull="false">A copy of the list of interfaces that the type implements.</returns> 1287 if (arguments.length !== 0) throw Error.parameterCount(); 1288 var result = []; 1289 var type = this; 1290 while(type) { 1291 var interfaces = type.__interfaces; 1292 if (interfaces) { 1293 for (var i = 0, l = interfaces.length; i < l; i++) { 1294 var interfaceType = interfaces[i]; 1295 if (!Array.contains(result, interfaceType)) { 1296 result.push(interfaceType); 1297 } 1298 } 1299 } 1300 type = type.__baseType; 1301 } 1302 return result; 1303} 1304 1305$prototype.getName = function Type$getName() { 1306 /// <summary locid="M:J#Type.getName"></summary> 1307 /// <returns type="String">The name of the type.</returns> 1308 if (arguments.length !== 0) throw Error.parameterCount(); 1309 return (typeof(this.__typeName) === "undefined") ? "" : this.__typeName; 1310} 1311 1312$prototype.implementsInterface = function Type$implementsInterface(interfaceType) { 1313 /// <summary locid="M:J#Type.implementsInterface"></summary> 1314 /// <param name="interfaceType" type="Type">The interface to test.</param> 1315 /// <returns type="Boolean">True if the type implements the interface.</returns> 1316 var e = Function._validateParams(arguments, [ 1317 {name: "interfaceType", type: Type} 1318 ]); 1319 if (e) throw e; 1320 this.resolveInheritance(); 1321 1322 var interfaceName = interfaceType.getName(); 1323 var cache = this.__interfaceCache; 1324 if (cache) { 1325 var cacheEntry = cache[interfaceName]; 1326 if (typeof(cacheEntry) !== 'undefined') return cacheEntry; 1327 } 1328 else { 1329 cache = this.__interfaceCache = {}; 1330 } 1331 1332 var baseType = this; 1333 while (baseType) { 1334 var interfaces = baseType.__interfaces; 1335 if (interfaces && Array.indexOf(interfaces, interfaceType) !== -1) { 1336 return cache[interfaceName] = true; 1337 } 1338 1339 baseType = baseType.__baseType; 1340 } 1341 1342 return cache[interfaceName] = false; 1343} 1344 1345$prototype.inheritsFrom = function Type$inheritsFrom(parentType) { 1346 /// <summary locid="M:J#Type.inheritsFrom"></summary> 1347 /// <param name="parentType" type="Type">The type to test.</param> 1348 /// <returns type="Boolean">True if the type inherits from parentType.</returns> 1349 var e = Function._validateParams(arguments, [ 1350 {name: "parentType", type: Type} 1351 ]); 1352 if (e) throw e; 1353 this.resolveInheritance(); 1354 return Sys._inheritsFrom(this, parentType); 1355} 1356 1357Sys._inheritsFrom = function _inheritsFrom(type, parentType) { 1358 var ret; 1359 if (parentType) { 1360 var baseType = type.__baseType; 1361 while (baseType) { 1362 if (baseType === parentType) { 1363 ret = true; 1364 break; 1365 } 1366 baseType = baseType.__baseType; 1367 } 1368 } 1369 return !!ret; 1370} 1371 1372$prototype.initializeBase = function Type$initializeBase(instance, baseArguments) { 1373 /// <summary locid="M:J#Type.initializeBase">This method initializes the base type in the context of a given instance object (to keep track of the base type, and to effectively inherit the object model of the base class, and initializing members of the base class). This should be called from the derived class constructor.</summary> 1374 /// <param name="instance">The object to initialize base types for. Usually 'this'.</param> 1375 /// <param name="baseArguments" type="Array" optional="true" mayBeNull="true" elementMayBeNull="true">The arguments for the base constructor.</param> 1376 /// <returns>The instance.</returns> 1377 var e = Function._validateParams(arguments, [ 1378 {name: "instance"}, 1379 {name: "baseArguments", type: Array, mayBeNull: true, optional: true, elementMayBeNull: true} 1380 ]); 1381 if (e) throw e; 1382 if (!Sys._isInstanceOfType(this, instance)) throw Error.argumentType('instance', Object.getType(instance), this); 1383 1384 this.resolveInheritance(); 1385 var baseType = this.__baseType; 1386 if (baseType) { 1387 baseArguments ? baseType.apply(instance, baseArguments) : baseType.apply(instance); 1388 } 1389 1390 return instance; 1391} 1392 1393$prototype.isImplementedBy = function Type$isImplementedBy(instance) { 1394 /// <summary locid="M:J#Type.isImplementedBy"></summary> 1395 /// <param name="instance" mayBeNull="true">The object on which the interface must be tested.</param> 1396 /// <returns type="Boolean">True if the instance implements the interface.</returns> 1397 var e = Function._validateParams(arguments, [ 1398 {name: "instance", mayBeNull: true} 1399 ]); 1400 if (e) throw e; 1401 if (typeof(instance) === "undefined" || instance === null) return false; 1402 1403 var instanceType = Object.getType(instance); 1404 return !!(instanceType.implementsInterface && instanceType.implementsInterface(this)); 1405} 1406 1407$prototype.isInstanceOfType = function Type$isInstanceOfType(instance) { 1408 /// <summary locid="M:J#Type.isInstanceOfType"></summary> 1409 /// <param name="instance" mayBeNull="true">The object on which the type must be tested.</param> 1410 /// <returns type="Boolean">True if the object is an instance of the type or one of its derived types.</returns> 1411 var e = Function._validateParams(arguments, [ 1412 {name: "instance", mayBeNull: true} 1413 ]); 1414 if (e) throw e; 1415 return Sys._isInstanceOfType(this, instance); 1416} 1417 1418$prototype.registerClass = function Type$registerClass(typeName, baseType, interfaceTypes) { 1419 /// <summary locid="M:J#Type.registerClass">Registers a class (represented by its ctor function), and optional base type, followed by any number of interfaces.</summary> 1420 /// <param name="typeName" type="String">The fully-qualified name of the type.</param> 1421 /// <param name="baseType" type="Type" optional="true" mayBeNull="true">The base type.</param> 1422 /// <param name="interfaceTypes" parameterArray="true" type="Type">One or several interfaces that the type implements.</param> 1423 /// <returns type="Type">The registered type.</returns> 1424 var e = Function._validateParams(arguments, [ 1425 {name: "typeName", type: String}, 1426 {name: "baseType", type: Type, mayBeNull: true, optional: true}, 1427 {name: "interfaceTypes", type: Type, parameterArray: true} 1428 ]); 1429 if (e) throw e; 1430 if (!Type.__fullyQualifiedIdentifierRegExp.test(typeName)) throw Error.argument('typeName', Sys.Res.notATypeName); 1431 var parsedName; 1432 try { 1433 parsedName = eval(typeName); 1434 } 1435 catch(e) { 1436 throw Error.argument('typeName', Sys.Res.argumentTypeName); 1437 } 1438 if (parsedName !== this) throw Error.argument('typeName', Sys.Res.badTypeName);
1439 if (Sys.__registeredTypes[typeName]) throw Error.invalidOperation(String.format(Sys.Res.typeRegisteredTwice, typeName)); 1440 1441 if ((arguments.length > 1) && (typeof(baseType) === 'undefined')) throw Error.argumentUndefined('baseType'); 1442 var prototype = this.prototype; 1443 prototype.constructor = this; 1444 this.__typeName = typeName; 1445 this.__class = true; 1446 if (baseType) { 1447 this.__baseType = baseType; 1448 this.__basePrototypePending = true; 1449 } 1450 Sys.__upperCaseTypes[typeName.toUpperCase()] = this; 1451 1452 if (interfaceTypes) { 1453 var interfaces = this.__interfaces = []; 1454 this.resolveInheritance(); 1455 for (var i = 2, l = arguments.length; i < l; i++) { 1456 var interfaceType = arguments[i]; 1457 if (!interfaceType.__interface) throw Error.argument('interfaceTypes[' + (i - 2) + ']', Sys.Res.notAnInterface); 1458 for (var methodName in interfaceType.prototype) { 1459 var method = interfaceType.prototype[methodName]; 1460 if (!prototype[methodName]) { 1461 prototype[methodName] = method; 1462 } 1463 } 1464 interfaces.push(interfaceType); 1465 } 1466 } 1467 Sys.__registeredTypes[typeName] = true; 1468 return this; 1469} 1470 1471Sys.registerComponent = function registerComponent(type, options) { 1472 /// <summary locid="M:J#Sys.registerComponent">Generates a create() function for the given type using the optional description and parameters for intellisense.</summary> 1473 /// <param name="type" type="Function">The type to be created.</param> 1474 /// <param name="options" type="Object" optional="true" mayBeNull="true"></param> 1475 var e = Function._validateParams(arguments, [ 1476 {name: "type", type: Function}, 1477 {name: "options", type: Object, mayBeNull: true, optional: true} 1478 ]); 1479 if (e) throw e; 1480 var typeName = type.getName(); 1481 var isControlOrBehavior = Sys.UI && (Sys._inheritsFrom(type, Sys.UI.Control) || Sys._inheritsFrom(type, Sys.UI.Behavior)); 1482 var name = (options && options.name); 1483 if (!name) { 1484 name = typeName; 1485 var i = name.lastIndexOf('.'); 1486 if (i >= 0) { 1487 name = name.substr(i+1); 1488 if (name && name.charAt(0) === "_") return; 1489 } 1490 name = name.substr(0, 1).toLowerCase() + name.substr(1); 1491 } 1492 if (!options) { 1493 options = {}; 1494 } 1495 options.name = name; 1496 options.type = type; 1497 options.typeName = typeName; 1498 options._isBehavior = isControlOrBehavior; 1499 1500 options = Sys.components[name] = merge(Sys.components[name], options); 1501 1502 var fn = Sys._getCreate(options), 1503 target = isControlOrBehavior ? Sys.ElementSet.prototype : Sys.create; 1504 target[name] = fn; 1505} 1506 1507Sys.registerPlugin = function registerPlugin(pluginInfo) { 1508 /// <summary locid="M:J#Sys.registerPlugin"></summary> 1509 /// <param name="pluginInfo" type="Object">An object describing the plugin (name, plugin, dom, global, components)</param> 1510 var e = Function._validateParams(arguments, [ 1511 {name: "pluginInfo", type: Object} 1512 ]); 1513 if (e) throw e; 1514 var name = pluginInfo.name, 1515 fnName = pluginInfo.functionName || name; 1516 Sys.plugins[name] = merge(Sys.plugins[name], pluginInfo); 1517 var plugin = pluginInfo.plugin, 1518 sysTarget; 1519 if (pluginInfo.global) { 1520 sysTarget = Sys; 1521 } 1522 else if (pluginInfo.dom) { 1523 sysTarget = Sys.ElementSet.prototype; 1524 } 1525 else if (pluginInfo.components) { 1526 sysTarget = Sys.ComponentSet.prototype; 1527 } 1528 if (sysTarget) { 1529 sysTarget[fnName] = Sys._getCreate(pluginInfo, true); 1530 } 1531} 1532 1533Sys._createComp = function _createComp(component, defaults, args) { 1534 var type = component.type, 1535 parameters = component.parameters || [], 1536 isBehavior = component._isBehavior, 1537 target = isBehavior ? args[0] : null; 1538 var props = args[parameters.length] || {}; 1539 props = merge({}, defaults, props); 1540 foreach(parameters, function(parameter, i) { 1541 var name = typeof(parameter) === "string" ? parameter : parameter.name, 1542 value = args[i];
1543 if (typeof(value) !== "undefined" && typeof(props[name]) === "undefined") { 1544 props[name] = value; 1545 } 1546 }); 1547 if (this instanceof Sys.ElementSet) { 1548 var components = []; 1549 this.each(function() { 1550 components.push(Sys._create(type, props, this)); 1551 }); 1552 return new Sys.ComponentSet(this, components); 1553 } 1554 else { 1555 return Sys._create(type, props); 1556 } 1557} 1558 1559Sys._create = function _create(type, properties, target) { 1560 var targetType = typeof(target); 1561 if (targetType === "string") { 1562 target = Sys.get(target); 1563 } 1564 var instance; 1565 Sys._2Pass(function() { 1566 instance = targetType === "undefined" ? new type() : new type(target); 1567 callIf(instance, "beginUpdate"); 1568 Sys._set(instance, properties); 1569 var componentType = Sys.Component; 1570 if (!componentType || !componentType._register(instance)) { 1571 callIf(instance, "endUpdate") || callIf(instance, "initialize"); 1572 } 1573 }); 1574 return instance; 1575} 1576 1577$prototype.registerInterface = function Type$registerInterface(typeName) { 1578 /// <summary locid="M:J#Type.registerInterface">Registers an interface (represented by its ctor function).</summary> 1579 /// <param name="typeName" type="String">The fully-qualified name of the interface.</param> 1580 /// <returns type="Type">The registered interface.</returns> 1581 var e = Function._validateParams(arguments, [ 1582 {name: "typeName", type: String} 1583 ]); 1584 if (e) throw e; 1585 if (!Type.__fullyQualifiedIdentifierRegExp.test(typeName)) throw Error.argument('typeName', Sys.Res.notATypeName); 1586 var parsedName; 1587 try { 1588 parsedName = eval(typeName); 1589 } 1590 catch(e) { 1591 throw Error.argument('typeName', Sys.Res.argumentTypeName); 1592 } 1593 if (parsedName !== this) throw Error.argument('typeName', Sys.Res.badTypeName); 1594 if (Sys.__registeredTypes[typeName]) throw Error.invalidOperation(String.format(Sys.Res.typeRegisteredTwice, typeName)); 1595 Sys.__upperCaseTypes[typeName.toUpperCase()] = this; 1596 1597 this.prototype.constructor = this; 1598 this.__typeName = typeName; 1599 this.__interface = true; 1600 Sys.__registeredTypes[typeName] = true; 1601 1602 return this; 1603} 1604 1605$prototype.resolveInheritance = function Type$resolveInheritance() { 1606 /// <summary locid="M:J#Type.resolveInheritance">This method is called on the ctor function instance. It does three things: 1. It stores __baseType as a property of the constructor function 2. It copies members from the baseType's prototype into the prototype associated with the type represented by this ctor, if this type itself doesn't have the same member in its prototype, i.e., it doesn't override the method. 3. It recurses up the inheritance chain to do the same for the base type. Note that this logic runs only once per type, because it is based on true value for __basePrototypePending property off the ctor function.</summary> 1607 if (arguments.length !== 0) throw Error.parameterCount(); 1608 1609 if (this.__basePrototypePending) { 1610 var baseType = this.__baseType; 1611 1612 baseType.resolveInheritance(); 1613 var basePrototype = baseType.prototype, 1614 thisPrototype = this.prototype; 1615 for (var memberName in basePrototype) { 1616 thisPrototype[memberName] = thisPrototype[memberName] || basePrototype[memberName]; 1617 } 1618 delete this.__basePrototypePending; 1619 } 1620} 1621 1622$type.getRootNamespaces = function Type$getRootNamespaces() { 1623 /// <summary locid="M:J#Type.getRootNamespaces"></summary> 1624 /// <returns type="Array">Returns an array containing references to all the root namespaces</returns> 1625 if (arguments.length !== 0) throw Error.parameterCount(); 1626 return Array.clone(Sys.__rootNamespaces); 1627} 1628 1629$type.isClass = function Type$isClass(type) { 1630 /// <summary locid="M:J#Type.isClass"></summary> 1631 /// <param name="type" mayBeNull="true">The type to test.</param> 1632 /// <returns type="Boolean">True if the type is a class.</returns> 1633 var e = Function._validateParams(arguments, [ 1634 {name: "type", mayBeNull: true} 1635 ]); 1636 if (e) throw e; 1637 return !!(type && type.__class); 1638} 1639 1640$type.isInterface = function Type$isInterface(type) { 1641 /// <summary locid="M:J#Type.isInterface"></summary> 1642 /// <param name="type" mayBeNull="true">The type to test.</param> 1643 /// <returns type="Boolean">True if the type is an interface.</returns> 1644 var e = Function._validateParams(arguments, [ 1645 {name: "type", mayBeNull: true} 1646 ]); 1647 if (e) throw e; 1648 return !!(type && type.__interface); 1649} 1650 1651$type.isNamespace = function Type$isNamespace(object) { 1652 /// <summary locid="M:J#Type.isNamespace"></summary> 1653 /// <param name="object" mayBeNull="true">The type to test.</param> 1654 /// <returns type="Boolean">True if the object is a namespace.</returns> 1655 var e = Function._validateParams(arguments, [ 1656 {name: "object", mayBeNull: true} 1657 ]); 1658 if (e) throw e; 1659 return !!(object && object.__namespace); 1660} 1661 1662$type.parse = function Type$parse(typeName, ns) { 1663 /// <summary locid="M:J#Type.parse">If a namespace is specified, the type name is searched for on this namespace in a case-insensitive way. If no namespace is specified, the fully-qualified, case-sensitive type name must be specified.</summary> 1664 /// <param name="typeName" type="String" mayBeNull="true">The name of the type.</param> 1665 /// <param name="ns" optional="true" mayBeNull="true">The namespace where to look for the type.</param> 1666 /// <returns type="Type" mayBeNull="true">The type or null.</returns> 1667 var e = Function._validateParams(arguments, [ 1668 {name: "typeName", type: String, mayBeNull: true}, 1669 {name: "ns", mayBeNull: true, optional: true} 1670 ]); 1671 if (e) throw e; 1672 var fn; 1673 if (ns) { 1674 fn = Sys.__upperCaseTypes[ns.getName().toUpperCase() + '.' + typeName.toUpperCase()]; 1675 return fn || null; 1676 } 1677 if (!typeName) return null; 1678 var htClasses = Type.__htClasses; 1679 if (!htClasses) { 1680 Type.__htClasses = htClasses = {}; 1681 } 1682 fn = htClasses[typeName]; 1683 if (!fn) { 1684 fn = window.eval(typeName); 1685 if (typeof(fn) !== 'function') throw Error.argument('typeName', Sys.Res.notATypeName); 1686 htClasses[typeName] = fn; 1687 } 1688 return fn; 1689} 1690 1691$type.registerNamespace = function Type$registerNamespace(namespacePath) { 1692 /// <summary locid="M:J#Type.registerNamespace">Creates a namespace.</summary> 1693 /// <param name="namespacePath" type="String">The full path of the namespace.</param> 1694 var e = Function._validateParams(arguments, [ 1695 {name: "namespacePath", type: String} 1696 ]); 1697 if (e) throw e; 1698 Type._registerNamespace(namespacePath); 1699} 1700$type._registerNamespace = function Type$_registerNamespace(namespacePath) { 1701 if (!Type.__fullyQualifiedIdentifierRegExp.test(namespacePath)) throw Error.argument('namespacePath', Sys.Res.invalidNameSpace); 1702 var rootObject = window;
1703 var namespaceParts = namespacePath.split('.'); 1704 1705 for (var i = 0, l = namespaceParts.length; i < l; i++) { 1706 var currentPart = namespaceParts[i]; 1707 var ns = rootObject[currentPart]; 1708 var nsType = typeof(ns); 1709 if ((nsType !== "undefined") && (ns !== null)) { 1710 if (nsType === "function") { 1711 throw Error.invalidOperation(String.format(Sys.Res.namespaceContainsClass, namespaceParts.splice(0, i + 1).join('.'))); 1712 } 1713 if ((typeof(ns) !== "object") || (ns instanceof Array)) { 1714 throw Error.invalidOperation(String.format(Sys.Res.namespaceContainsNonObject, namespaceParts.splice(0, i + 1).join('.'))); 1715 } 1716 } 1717 if (!ns) { 1718 ns = rootObject[currentPart] = {}; 1719 } 1720 if (!ns.__namespace) { 1721 if (!i && (namespacePath !== "Sys")) { 1722 Sys.__rootNamespaces.push(ns); 1723 } 1724 ns.__namespace = true; 1725 ns.__typeName = namespaceParts.slice(0, i + 1).join('.'); 1726 var parsedName; 1727 try { 1728 parsedName = eval(ns.__typeName); 1729 } 1730 catch(e) { 1731 parsedName = null; 1732 } 1733 if (parsedName !== ns) { 1734 delete rootObject[currentPart]; 1735 throw Error.argument('namespacePath', Sys.Res.invalidNameSpace); 1736 } 1737 ns.getName = function ns$getName() {return this.__typeName;} 1738 } 1739 rootObject = ns; 1740 } 1741} 1742 1743$type._checkDependency = function Type$_checkDependency(dependency, featureName) { 1744 var scripts = Type._registerScript._scripts, isDependent = (scripts ? (!!scripts[dependency]) : false); 1745 if ((typeof(featureName) !== 'undefined') && !isDependent) { 1746 throw Error.invalidOperation(String.format(Sys.Res.requiredScriptReferenceNotIncluded, 1747 featureName, dependency)); 1748 } 1749 return isDependent; 1750} 1751 1752$type._registerScript = function Type$_registerScript(scriptName, dependencies) { 1753 var scripts = Type._registerScript._scripts; 1754 if (!scripts) { 1755 Type._registerScript._scripts = scripts = {}; 1756 } 1757 if (scripts[scriptName]) { 1758 throw Error.invalidOperation(String.format(Sys.Res.scriptAlreadyLoaded, scriptName)); 1759 } 1760 scripts[scriptName] = true; 1761 if (dependencies) { 1762 for (var i = 0, l = dependencies.length; i < l; i++) { 1763 var dependency = dependencies[i]; 1764 if (!Type._checkDependency(dependency)) { 1765 throw Error.invalidOperation(String.format(Sys.Res.scriptDependencyNotFound, scriptName, dependency)); 1766 } 1767 } 1768 } 1769} 1770 1771$type._registerNamespace("Sys"); 1772Sys.__upperCaseTypes = {}; 1773Sys.__rootNamespaces = [Sys]; 1774Sys.__registeredTypes = {}; 1775 1776Sys._isInstanceOfType = function _isInstanceOfType(type, instance) { 1777 if (typeof(instance) === "undefined" || instance === null) return false; 1778 if (instance instanceof type) return true; 1779 var instanceType = Object.getType(instance); 1780 return !!(instanceType === type) || 1781 (instanceType.inheritsFrom && instanceType.inheritsFrom(type)) || 1782 (instanceType.implementsInterface && instanceType.implementsInterface(type)); 1783} 1784 1785Sys._getBaseMethod = function _getBaseMethod(type, instance, name) { 1786 if (!Sys._isInstanceOfType(type, instance)) throw Error.argumentType('instance', Object.getType(instance), type); 1787 var baseType = type.getBaseType(); 1788 if (baseType) { 1789 var baseMethod = baseType.prototype[name]; 1790 return (baseMethod instanceof Function) ? baseMethod : null; 1791 } 1792 return null; 1793} 1794 1795Sys._isDomElement = function _isDomElement(obj) { 1796 var val = false; 1797 if (typeof (obj.nodeType) !== 'number') { 1798 var doc = obj.ownerDocument || obj.document || obj; 1799 if (doc != obj) { 1800 var w = doc.defaultView || doc.parentWindow; 1801 val = (w != obj); 1802 } 1803 else { 1804 val = !doc.body || !Sys._isDomElement(doc.body); 1805 } 1806 } 1807 return !val; 1808} 1809 1810var isBrowser = Sys._isBrowser = function _isBrowser(name) { 1811 return Sys.Browser.agent === Sys.Browser[name]; 1812} 1813 1814 1815foreach(Sys._ns, $type._registerNamespace); 1816delete Sys._ns; 1817$type = Array; 1818$type.__typeName = 'Array'; 1819$type.__class = true; 1820 1821var indexOf = Sys._indexOf = function _indexOf(array, item, start) { 1822 if (typeof(item) === "undefined") return -1; 1823 var length = array.length; 1824 if (length !== 0) { 1825 start = start - 0; 1826 if (isNaN(start)) { 1827 start = 0; 1828 } 1829 else { 1830 if (isFinite(start)) { 1831 start = start - (start % 1); 1832 } 1833 if (start < 0) { 1834 start = Math.max(0, length + start); 1835 } 1836 } 1837 1838 for (var i = start; i < length; i++) { 1839 if (array[i] === item) { 1840 return i; 1841 } 1842 } 1843 } 1844 return -1; 1845} 1846 1847$type.add = $type.enqueue = function Array$enqueue(array, item) { 1848 /// <summary locid="M:J#Array.enqueue">Adds an element at the end of the array.</summary> 1849 /// <param name="array" type="Array" elementMayBeNull="true">The array to add to.</param> 1850 /// <param name="item" mayBeNull="true">The object to add.</param> 1851 var e = Function._validateParams(arguments, [ 1852 {name: "array", type: Array, elementMayBeNull: true}, 1853 {name: "item", mayBeNull: true} 1854 ]); 1855 if (e) throw e; 1856 array[array.length] = item; 1857} 1858 1859$type.addRange = function Array$addRange(array, items) { 1860 /// <summary locid="M:J#Array.addRange">Adds a range of items at the end of the array.</summary> 1861 /// <param name="array" type="Array" elementMayBeNull="true">The array to add to.</param> 1862 /// <param name="items" type="Array" elementMayBeNull="true">The array of items to append.</param> 1863 var e = Function._validateParams(arguments, [ 1864 {name: "array", type: Array, elementMayBeNull: true}, 1865 {name: "items", type: Array, elementMayBeNull: true} 1866 ]); 1867 if (e) throw e; 1868 1869 array.push.apply(array, items); 1870} 1871 1872$type.clear = function Array$clear(array) { 1873 /// <summary locid="M:J#Array.clear">Clears the array of its elements.</summary> 1874 /// <param name="array" type="Array" elementMayBeNull="true">The array to clear.</param> 1875 var e = Function._validateParams(arguments, [ 1876 {name: "array", type: Array, elementMayBeNull: true} 1877 ]); 1878 if (e) throw e; 1879 array.length = 0; 1880} 1881 1882$type.clone = function Array$clone(array) { 1883 /// <summary locid="M:J#Array.clone">Makes a clone of the array.</summary> 1884 /// <param name="array" type="Array" elementMayBeNull="true">The array to clone.</param> 1885 /// <returns type="Array" elementMayBeNull="true">A clone of the array.</returns> 1886 var e = Function._validateParams(arguments, [ 1887 {name: "array", type: Array, elementMayBeNull: true} 1888 ]); 1889 if (e) throw e; 1890 return array.length === 1 ? [array[0]] : Array.apply(null, array); 1891} 1892 1893$type.contains = function Array$contains(array, item) { 1894 /// <summary locid="M:J#Array.contains">Use this method to determine if an array contains the specified element.</summary> 1895 /// <param name="array" type="Array" elementMayBeNull="true">The array to look into.</param> 1896 /// <param name="item" mayBeNull="true">The object to find in the array.</param> 1897 /// <returns type="Boolean">True if the object was found.</returns> 1898 var e = Function._validateParams(arguments, [ 1899 {name: "array", type: Array, elementMayBeNull: true}, 1900 {name: "item", mayBeNull: true} 1901 ]); 1902 if (e) throw e; 1903 return (indexOf(array, item) >= 0); 1904} 1905 1906$type.dequeue = function Array$dequeue(array) { 1907 /// <summary locid="M:J#Array.dequeue"></summary> 1908 /// <param name="array" type="Array" elementMayBeNull="true">Removes and returns the object at the beginning of the array.</param> 1909 /// <returns mayBeNull="true">The object that is removed from the beginning of the array.</returns> 1910 var e = Function._validateParams(arguments, [ 1911 {name: "array", type: Array, elementMayBeNull: true} 1912 ]); 1913 if (e) throw e; 1914 return array.shift(); 1915} 1916
1917$type.forEach = function Array$forEach(array, method, instance) { 1918 /// <summary locid="M:J#Array.forEach">Calls the specified function on each element of the array.</summary> 1919 /// <param name="array" type="Array" elementMayBeNull="true">The array to enumerate.</param> 1920 /// <param name="method" type="Function">The method to call. The method should take the array element, the index of the element and the array itself as its parameters.</param> 1921 /// <param name="instance" optional="true" mayBeNull="true">The context under which the function must run (i.e. what 'this' means inside the function).</param> 1922 var e = Function._validateParams(arguments, [ 1923 {name: "array", type: Array, elementMayBeNull: true}, 1924 {name: "method", type: Function}, 1925 {name: "instance", mayBeNull: true, optional: true} 1926 ]); 1927 if (e) throw e; 1928 for (var i = 0, l = array.length; i < l; i++) { 1929 var elt = array[i]; 1930 if (typeof(elt) !== 'undefined') method.call(instance, elt, i, array); 1931 } 1932} 1933 1934$type.indexOf = function Array$indexOf(array, item, start) { 1935 /// <summary locid="M:J#Array.indexOf">Finds the index in the array of the provided item.</summary> 1936 /// <param name="array" type="Array" elementMayBeNull="true">The array to look into.</param> 1937 /// <param name="item" optional="true" mayBeNull="true">The object to find.</param> 1938 /// <param name="start" optional="true" mayBeNull="true">The index where the search begins.</param> 1939 /// <returns type="Number">The index of the item or -1 if it wasn't found.</returns> 1940 var e = Function._validateParams(arguments, [ 1941 {name: "array", type: Array, elementMayBeNull: true}, 1942 {name: "item", mayBeNull: true, optional: true}, 1943 {name: "start", mayBeNull: true, optional: true} 1944 ]); 1945 if (e) throw e; 1946 return indexOf(array, item, start); 1947} 1948 1949$type.insert = function Array$insert(array, index, item) { 1950 /// <summary locid="M:J#Array.insert">Inserts an item at the specified index.</summary> 1951 /// <param name="array" type="Array" elementMayBeNull="true">The array to insert into.</param> 1952 /// <param name="index" mayBeNull="true">The index where the item will be inserted.</param> 1953 /// <param name="item" mayBeNull="true">The item to insert.</param> 1954 var e = Function._validateParams(arguments, [ 1955 {name: "array", type: Array, elementMayBeNull: true}, 1956 {name: "index", mayBeNull: true}, 1957 {name: "item", mayBeNull: true} 1958 ]); 1959 if (e) throw e; 1960 array.splice(index, 0, item); 1961} 1962 1963$type.parse = function Array$parse(value) { 1964 /// <summary locid="M:J#Array.parse">Creates an array from a string representation of the form "[elt1, elt2, elt3]".</summary> 1965 /// <param name="value" type="String" mayBeNull="true">The string representation of the array.</param> 1966 /// <returns type="Array" elementMayBeNull="true">An array built from the string representation.</returns> 1967 var e = Function._validateParams(arguments, [ 1968 {name: "value", type: String, mayBeNull: true} 1969 ]); 1970 if (e) throw e; 1971 var v = value ? window.eval("(" + value + ")") : []; 1972 if (!Array.isInstanceOfType(v)) throw Error.argument('value', Sys.Res.arrayParseBadFormat); 1973 return v; 1974} 1975 1976$type.remove = function Array$remove(array, item) { 1977 /// <summary locid="M:J#Array.remove">Removes the first occurence of an item from the array.</summary> 1978 /// <param name="array" type="Array" elementMayBeNull="true">The array to remove from.</param> 1979 /// <param name="item" mayBeNull="true">The item to remove.</param> 1980 /// <returns type="Boolean">True if the item was found.</returns> 1981 var e = Function._validateParams(arguments, [ 1982 {name: "array", type: Array, elementMayBeNull: true}, 1983 {name: "item", mayBeNull: true} 1984 ]); 1985 if (e) throw e; 1986 var index = indexOf(array, item); 1987 if (index >= 0) { 1988 array.splice(index, 1); 1989 } 1990 return (index >= 0); 1991} 1992 1993$type.removeAt = function Array$removeAt(array, index) { 1994 /// <summary locid="M:J#Array.removeAt">Removes the item at the specified index from the array.</summary> 1995 /// <param name="array" type="Array" elementMayBeNull="true">The array to remove from.</param> 1996 /// <param name="index" mayBeNull="true">The index of the item to remove.</param> 1997 var e = Function._validateParams(arguments, [ 1998 {name: "array", type: Array, elementMayBeNull: true}, 1999 {name: "index", mayBeNull: true} 2000 ]); 2001 if (e) throw e; 2002 array.splice(index, 1); 2003} 2004 2005 2006 2007Type._registerScript._scripts = { 2008 "MicrosoftAjaxCore.js": true, 2009 "MicrosoftAjaxGlobalization.js": true, 2010 "MicrosoftAjaxSerialization.js": true, 2011 "MicrosoftAjaxComponentModel.js": true, 2012 "MicrosoftAjaxHistory.js": true, 2013 "MicrosoftAjaxNetwork.js" : true, 2014 "MicrosoftAjaxWebServices.js": true }; 2015 2016$type = Sys.IDisposable = function IDisposable() { 2017 throw Error.notImplemented(); 2018} 2019$type.prototype = { 2020 dispose: function IDisposable$dispose() { 2021 throw Error.notImplemented(); 2022 } 2023} 2024$type.registerInterface('Sys.IDisposable'); 2025$type = Sys.StringBuilder = function StringBuilder(initialText) { 2026 /// <summary locid="M:J#Sys.StringBuilder.#ctor">Provides an optimized mechanism to concatenate a sequence of strings.</summary> 2027 /// <param name="initialText" optional="true" mayBeNull="true">The initial text for the StringBuilder.</param> 2028 var e = Function._validateParams(arguments, [ 2029 {name: "initialText", mayBeNull: true, optional: true} 2030 ]); 2031 if (e) throw e; 2032 this._parts = (typeof(initialText) !== 'undefined' && initialText !== null && initialText !== '') ? 2033 [initialText.toString()] : []; 2034 this._value = {}; 2035 this._len = 0; 2036} 2037 2038$type.prototype = { 2039 append: function StringBuilder$append(text) { 2040 /// <summary locid="M:J#Sys.StringBuilder.append">Appends a new string at the end of the StringBuilder.</summary> 2041 /// <param name="text" mayBeNull="true">The string to append.</param> 2042 /// <returns type="Sys.StringBuilder"></returns> 2043 var e = Function._validateParams(arguments, [ 2044 {name: "text", mayBeNull: true} 2045 ]); 2046 if (e) throw e; 2047 this._parts.push(text); 2048 return this; 2049 }, 2050 2051 appendLine: function StringBuilder$appendLine(text) { 2052 /// <summary locid="M:J#Sys.StringBuilder.appendLine">Appends a new string as a line of text at the end of the StringBuilder.</summary> 2053 /// <param name="text" optional="true" mayBeNull="true">The string to append.</param> 2054 /// <returns type="Sys.StringBuilder"></returns> 2055 var e = Function._validateParams(arguments, [ 2056 {name: "text", mayBeNull: true, optional: true} 2057 ]); 2058 if (e) throw e; 2059 this._parts.push( 2060 ((typeof(text) === 'undefined') || (text === null) || (text === '')) ? 2061 '\r\n' : (text + '\r\n')); 2062 return this; 2063 }, 2064 2065 clear: function StringBuilder$clear() { 2066 /// <summary locid="M:J#Sys.StringBuilder.clear">Clears the StringBuilder of its current contents.</summary> 2067 if (arguments.length !== 0) throw Error.parameterCount(); 2068 this._parts = []; 2069 this._value = {}; 2070 this._len = 0; 2071 }, 2072 2073 isEmpty: function StringBuilder$isEmpty() { 2074 /// <summary locid="M:J#Sys.StringBuilder.isEmpty">Use this method to determine if the StringBuilder has contents.</summary> 2075 /// <returns type="Boolean">True if the StringBuilder has any contents.</returns> 2076 if (arguments.length !== 0) throw Error.parameterCount(); 2077 return (!this._parts.length || !this.toString()); 2078 }, 2079 2080 toString: function StringBuilder$toString(separator) { 2081 /// <summary locid="M:J#Sys.StringBuilder.toString">Creates a string from the contents of the StringBuilder.</summary> 2082 /// <param name="separator" type="String" optional="true" mayBeNull="true">The separator to insert between the elements of the StringBuilder.</param> 2083 /// <returns type="String">The string built from the StringBuilder.</returns> 2084 var e = Function._validateParams(arguments, [ 2085 {name: "separator", type: String, mayBeNull: true, optional: true} 2086 ]); 2087 if (e) throw e; 2088 separator = separator || ''; 2089 var parts = this._parts; 2090 if (this._len !== parts.length) { 2091 this._value = {}; 2092 this._len = parts.length; 2093 } 2094 var val = this._value; 2095 var ret = val[separator]; 2096 if (typeof(ret) === 'undefined') { 2097 if (separator !== '') { 2098 for (var i = 0; i < parts.length;) { 2099 var part = parts[i];
2100 if ((typeof(part) === 'undefined') || (part === '') || (part === null)) { 2101 parts.splice(i, 1); 2102 } 2103 else { 2104 i++; 2105 } 2106 } 2107 } 2108 val[separator] = ret = parts.join(separator); 2109 } 2110 return ret; 2111 } 2112} 2113$type.registerClass('Sys.StringBuilder'); 2114 2115var agent = navigator.userAgent, 2116 browser = Sys.Browser = { 2117 InternetExplorer: {}, 2118 Firefox: {}, 2119 Safari: {}, 2120 Opera: {}, 2121 agent: null, 2122 hasDebuggerStatement: false, 2123 name: navigator.appName, 2124 version: parseFloat(navigator.appVersion), 2125 documentMode: 0 }; 2126 2127if (agent.indexOf(' MSIE ') > -1) { 2128 browser.agent = browser.InternetExplorer; 2129 browser.version = parseFloat(agent.match(/MSIE (\d+\.\d+)/)[1]); 2130 if ((browser.version > 7) && (document.documentMode > 6)) { 2131 browser.documentMode = document.documentMode; 2132 } 2133 browser.hasDebuggerStatement = true; 2134} 2135else if (agent.indexOf(' Firefox/') > -1) { 2136 browser.agent = browser.Firefox; 2137 browser.version = parseFloat(agent.match(/ Firefox\/(\d+\.\d+)/)[1]); 2138 browser.name = 'Firefox'; 2139 browser.hasDebuggerStatement = true; 2140} 2141else if (agent.indexOf(' AppleWebKit/') > -1) { 2142 browser.agent = browser.Safari; 2143 browser.version = parseFloat(agent.match(/ AppleWebKit\/(\d+(\.\d+)?)/)[1]); 2144 browser.name = 'Safari'; 2145} 2146else if (agent.indexOf('Opera/') > -1) { 2147 browser.agent = browser.Opera; 2148} 2149 2150 2151$type = Sys.EventArgs = function EventArgs() { 2152 /// <summary locid="M:J#Sys.EventArgs.#ctor">EventArgs is the base class for classes containing event data.</summary> 2153 if (arguments.length !== 0) throw Error.parameterCount(); 2154} 2155$type.registerClass('Sys.EventArgs'); 2156 2157Sys.EventArgs.Empty = new Sys.EventArgs(); 2158$type = Sys.CancelEventArgs = function CancelEventArgs() { 2159 /// <summary locid="M:J#Sys.CancelEventArgs.#ctor">CancelEventArgs is the base class for classes containing event data, which can be used to cancel the event.</summary> 2160 if (arguments.length !== 0) throw Error.parameterCount(); 2161 Sys.CancelEventArgs.initializeBase(this); 2162 2163 this._cancel = false; 2164} 2165$type.prototype = { 2166 get_cancel: function CancelEventArgs$get_cancel() { 2167 /// <value type="Boolean" locid="P:J#Sys.CancelEventArgs.cancel"></value> 2168 if (arguments.length !== 0) throw Error.parameterCount(); 2169 return this._cancel; 2170 }, 2171 set_cancel: function CancelEventArgs$set_cancel(value) { 2172 var e = Function._validateParams(arguments, [{name: "value", type: Boolean}]); 2173 if (e) throw e; 2174 this._cancel = value; 2175 } 2176} 2177$type.registerClass('Sys.CancelEventArgs', Sys.EventArgs); 2178 2179 2180Type.registerNamespace('Sys.UI'); 2181 2182$type = Sys._Debug = function _Debug() { 2183 /// <summary locid="M:J#Sys.Debug.#ctor">Provides a set of methods that help debug your code.</summary> 2184 /// <field name="isDebug" type="Boolean" locid="F:J#Sys.Debug.isDebug"></field> 2185 if (arguments.length !== 0) throw Error.parameterCount(); 2186} 2187$type.prototype = { 2188 _appendConsole: function _Debug$_appendConsole(text) { 2189 if ((typeof(Debug) !== 'undefined') && Debug.writeln) { 2190 Debug.writeln(text); 2191 } 2192 if (window.console && window.console.log) { 2193 window.console.log(text); 2194 } 2195 if (window.opera) { 2196 window.opera.postError(text); 2197 } 2198 if (window.debugService) { 2199 window.debugService.trace(text); 2200 } 2201 }, 2202 2203 _getTrace: function() { 2204 var traceElement = Sys.get('#TraceConsole'); 2205 return (traceElement && (traceElement.tagName.toUpperCase() === 'TEXTAREA')) ? traceElement : null; 2206 }, 2207 2208 _appendTrace: function _Debug$_appendTrace(text) { 2209 var traceElement = this._getTrace(); 2210 if (traceElement) { 2211 traceElement.value += text + '\n'; 2212 } 2213 }, 2214 2215 assert: function _Debug$assert(condition, message, displayCaller) { 2216 /// <summary locid="M:J#Sys.Debug.assert">Checks for a condition, displays a message and prompts the user to break into the debugger if the condition is false.</summary> 2217 /// <param name="condition" type="Boolean">true to prevent a message being displayed; otherwise, false.</param> 2218 /// <param name="message" type="String" optional="true" mayBeNull="true">A message to display.</param> 2219 /// <param name="displayCaller" type="Boolean" optional="true" mayBeNull="true">True if the function calling assert should be displayed in the message.</param> 2220 var e = Function._validateParams(arguments, [ 2221 {name: "condition", type: Boolean}, 2222 {name: "message", type: String, mayBeNull: true, optional: true}, 2223 {name: "displayCaller", type: Boolean, mayBeNull: true, optional: true} 2224 ]); 2225 if (e) throw e; 2226 if (!condition) { 2227 message = (displayCaller && this.assert.caller) ? 2228 String.format(Sys.Res.assertFailedCaller, message, this.assert.caller) : 2229 String.format(Sys.Res.assertFailed, message); 2230 2231 if (confirm(String.format(Sys.Res.breakIntoDebugger, message))) { 2232 this.fail(message); 2233 } 2234 } 2235 }, 2236 2237 clearTrace: function _Debug$clearTrace() { 2238 /// <summary locid="M:J#Sys.Debug.clearTrace"></summary> 2239 if (arguments.length !== 0) throw Error.parameterCount(); 2240 var traceElement = this._getTrace(); 2241 if (traceElement) { 2242 traceElement.value = ''; 2243 } 2244 }, 2245 2246 fail: function _Debug$fail(message) { 2247 /// <summary locid="M:J#Sys.Debug.fail">Displays a message in the debugger's output window and breaks into the debugger.</summary> 2248 /// <param name="message" type="String" mayBeNull="true">A message to display.</param> 2249 var e = Function._validateParams(arguments, [ 2250 {name: "message", type: String, mayBeNull: true} 2251 ]); 2252 if (e) throw e; 2253 this._appendConsole(message); 2254 2255 if (Sys.Browser.hasDebuggerStatement) { 2256 window.eval('debugger'); 2257 } 2258 }, 2259 2260 trace: function _Debug$trace(text) { 2261 /// <summary locid="M:J#Sys.Debug.trace">Appends a text line to the debugger console and the TraceConsole textarea element if available.</summary> 2262 /// <param name="text">Text for trace.</param> 2263 var e = Function._validateParams(arguments, [ 2264 {name: "text"} 2265 ]); 2266 if (e) throw e; 2267 this._appendConsole(text); 2268 this._appendTrace(text); 2269 }, 2270 2271 traceDump: function _Debug$traceDump(object, name) { 2272 /// <summary locid="M:J#Sys.Debug.traceDump">Dumps an object to the debugger console and the TraceConsole textarea element if available.</summary> 2273 /// <param name="object" mayBeNull="true">Object for trace dump.</param> 2274 /// <param name="name" type="String" mayBeNull="true" optional="true">Object name.</param> 2275 var e = Function._validateParams(arguments, [ 2276 {name: "object", mayBeNull: true}, 2277 {name: "name", type: String, mayBeNull: true, optional: true} 2278 ]); 2279 if (e) throw e; 2280 this._traceDump(object, name, true); 2281 }, 2282 2283 _traceDump: function _Debug$_traceDump(object, name, recursive, indentationPadding, loopArray) { 2284 name = name || 'traceDump'; 2285 indentationPadding = indentationPadding || ''; 2286 var prefix = indentationPadding + name + ": "; 2287 if (object === null) { 2288 this.trace(prefix + 'null'); 2289 return; 2290 } 2291 switch(typeof(object)) { 2292 case 'undefined': 2293 this.trace(prefix + 'Undefined'); 2294 break; 2295 case 'number': case 'string': case 'boolean': 2296 this.trace(prefix + object); 2297 break; 2298 default: 2299 if (Date.isInstanceOfType(object) || RegExp.isInstanceOfType(object)) { 2300 this.trace(prefix + object.toString()); 2301 break; 2302 } 2303 if (!loopArray) { 2304 loopArray = []; 2305 } 2306 else if (Array.contains(loopArray, object)) { 2307 this.trace(prefix + '...'); 2308 return; 2309 } 2310 loopArray.push(object); 2311 2312 if ((object == window) || (object === document) || 2313 (window.HTMLElement && (object instanceof HTMLElement)) || 2314 (typeof(object.nodeName) === 'string')) { 2315 var tag = object.tagName || 'DomElement'; 2316 if (object.id) { 2317 tag += ' - ' + object.id; 2318 } 2319 this.trace(indentationPadding + name + ' {' + tag + '}'); 2320 } 2321 else { 2322 var typeName = Object.getTypeName(object); 2323 this.trace(indentationPadding + name + (typeof(typeName) === 'string' ? ' {' + typeName + '}' : '')); 2324 if ((indentationPadding === '') || recursive) { 2325 indentationPadding += " "; 2326 var i, length, properties, p, v; 2327 if (object instanceof Array) { 2328 length = object.length; 2329 for (i = 0; i < length; i++) { 2330 this._traceDump(object[i], '[' + i + ']', recursive, indentationPadding, loopArray);
2331 } 2332 } 2333 else { 2334 for (p in object) { 2335 v = object[p]; 2336 if (typeof(v) !== "function") { 2337 this._traceDump(v, p, recursive, indentationPadding, loopArray); 2338 } 2339 } 2340 } 2341 } 2342 } 2343 Array.remove(loopArray, object); 2344 } 2345 } 2346} 2347$type.registerClass('Sys._Debug'); 2348 2349$type = Sys.Debug = new Sys._Debug(); 2350$type.isDebug = true; 2351function Sys$Enum$parse(value, ignoreCase) { 2352 /// <summary locid="M:J#Sys.Enum.parse">Converts the string representation of the name or numeric value of one or more enumerated constants to an equivalent enumerated object.</summary> 2353 /// <param name="value" type="String">A string containing the name or value to convert.</param> 2354 /// <param name="ignoreCase" type="Boolean" optional="true" mayBeNull="true">If true, the parsing will be done case-insensitively. If omitted, the parsing is done case-sensitively.</param> 2355 /// <returns>An object of type enumType whose value is represented by value.</returns> 2356 var e = Function._validateParams(arguments, [ 2357 {name: "value", type: String}, 2358 {name: "ignoreCase", type: Boolean, mayBeNull: true, optional: true} 2359 ]); 2360 if (e) throw e; 2361 var values, parsed, val; 2362 if (ignoreCase) { 2363 values = this.__lowerCaseValues; 2364 if (!values) { 2365 this.__lowerCaseValues = values = {}; 2366 var prototype = this.prototype; 2367 for (var name in prototype) { 2368 values[name.toLowerCase()] = prototype[name]; 2369 } 2370 } 2371 } 2372 else { 2373 values = this.prototype; 2374 } 2375 function throwError(v) { 2376 if (typeof(parsed) !== 'number') throw Error.argument('value', String.format(Sys.Res.enumInvalidValue, v, this.__typeName)); 2377 } 2378 if (!this.__flags) { 2379 val = (ignoreCase ? value.toLowerCase() : value); 2380 parsed = values[val.trim()]; 2381 if (typeof(parsed) !== 'number') throwError.call(this, value); 2382 return parsed; 2383 } 2384 else { 2385 var parts = (ignoreCase ? value.toLowerCase() : value).split(','); 2386 var v = 0; 2387 2388 for (var i = parts.length - 1; i >= 0; i--) { 2389 var part = parts[i].trim(); 2390 parsed = values[part]; 2391 if (typeof(parsed) !== 'number') throwError.call(this, value.split(',')[i].trim()); 2392 v |= parsed; 2393 } 2394 return v; 2395 } 2396} 2397 2398function Sys$Enum$toString(value) { 2399 /// <summary locid="M:J#Sys.Enum.toString">Converts the value of an enum instance to its equivalent string representation.</summary> 2400 /// <param name="value" optional="true" mayBeNull="true">The value of the enum instance for which the string representation must be constructed.</param> 2401 /// <returns type="String">The string representation of "value".</returns> 2402 var e = Function._validateParams(arguments, [ 2403 {name: "value", mayBeNull: true, optional: true} 2404 ]); 2405 if (e) throw e; 2406 if ((typeof(value) === 'undefined') || (value === null)) return this.__string; 2407 if ((typeof(value) != 'number') || ((value % 1) !== 0)) throw Error.argumentType('value', Object.getType(value), this); 2408 var values = this.prototype; 2409 var i; 2410 if (!this.__flags || (value === 0)) { 2411 for (i in values) { 2412 if (values[i] === value) { 2413 return i; 2414 } 2415 } 2416 } 2417 else { 2418 var sorted = this.__sortedValues; 2419 if (!sorted) { 2420 sorted = []; 2421 for (i in values) { 2422 sorted.push({key: i, value: values[i]}); 2423 } 2424 sorted.sort(function(a, b) { 2425 return a.value - b.value; 2426 }); 2427 this.__sortedValues = sorted; 2428 } 2429 var parts = []; 2430 var v = value; 2431 for (i = sorted.length - 1; i >= 0; i--) { 2432 var kvp = sorted[i];
2433 var vali = kvp.value; 2434 if (vali === 0) continue; 2435 if ((vali & value) === vali) { 2436 parts.push(kvp.key); 2437 v -= vali; 2438 if (v === 0) break; 2439 } 2440 } 2441 if (parts.length && v === 0) return parts.reverse().join(', '); 2442 } 2443 throw Error.argumentOutOfRange('value', value, String.format(Sys.Res.enumInvalidValue, value, this.__typeName)); 2444} 2445 2446$type = Type; 2447 2448$type.prototype.registerEnum = function Type$registerEnum(name, flags) { 2449 /// <summary locid="M:J#Sys.UI.LineType.#ctor">Registers an enum type.</summary> 2450 /// <param name="name" type="String">The fully-qualified name of the enum.</param> 2451 /// <param name="flags" type="Boolean" optional="true" mayBeNull="true">True if the enum is a flags collection.</param> 2452 var e = Function._validateParams(arguments, [ 2453 {name: "name", type: String}, 2454 {name: "flags", type: Boolean, mayBeNull: true, optional: true} 2455 ]); 2456 if (e) throw e; 2457 if (!Type.__fullyQualifiedIdentifierRegExp.test(name)) throw Error.argument('name', Sys.Res.notATypeName); 2458 var parsedName; 2459 try { 2460 parsedName = eval(name); 2461 } 2462 catch(e) { 2463 throw Error.argument('name', Sys.Res.argumentTypeName); 2464 } 2465 if (parsedName !== this) throw Error.argument('name', Sys.Res.badTypeName); 2466 if (Sys.__registeredTypes[name]) throw Error.invalidOperation(String.format(Sys.Res.typeRegisteredTwice, name)); 2467 for (var j in this.prototype) { 2468 var val = this.prototype[j]; 2469 if (!Type.__identifierRegExp.test(j)) throw Error.invalidOperation(String.format(Sys.Res.enumInvalidValueName, j)); 2470 if (typeof(val) !== 'number' || (val % 1) !== 0) throw Error.invalidOperation(Sys.Res.enumValueNotInteger); 2471 if (typeof(this[j]) !== 'undefined') throw Error.invalidOperation(String.format(Sys.Res.enumReservedName, j)); 2472 } 2473 Sys.__upperCaseTypes[name.toUpperCase()] = this; 2474 2475 for (var i in this.prototype) { 2476 this[i] = this.prototype[i]; 2477 } 2478 this.__typeName = name; 2479 this.parse = Sys$Enum$parse; 2480 this.__string = this.toString(); 2481 this.toString = Sys$Enum$toString; 2482 this.__flags = flags; 2483 this.__enum = true; 2484 Sys.__registeredTypes[name] = true; 2485} 2486 2487$type.isEnum = function Type$isEnum(type) { 2488 /// <summary locid="M:J#Type.isEnum"></summary> 2489 /// <param name="type" mayBeNull="true">The type to test.</param> 2490 /// <returns type="Boolean">True if the type is an enum.</returns> 2491 var e = Function._validateParams(arguments, [ 2492 {name: "type", mayBeNull: true} 2493 ]); 2494 if (e) throw e; 2495 return !!(type && type.__enum); 2496} 2497 2498$type.isFlags = function Type$isFlags(type) { 2499 /// <summary locid="M:J#Type.isFlags"></summary> 2500 /// <param name="type" mayBeNull="true">The type to test.</param> 2501 /// <returns type="Boolean">True if the type is a set of flags.</returns> 2502 var e = Function._validateParams(arguments, [ 2503 {name: "type", mayBeNull: true} 2504 ]); 2505 if (e) throw e; 2506 return !!(type && type.__flags); 2507} 2508 2509$type = Sys.CollectionChange = function CollectionChange(action, newItems, newStartingIndex, oldItems, oldStartingIndex) { 2510 /// <summary locid="M:J#Sys.CollectionChange.#ctor">Describes a change in a collection.</summary> 2511 /// <param name="action" type="Sys.NotifyCollectionChangedAction"></param> 2512 /// <param name="newItems" optional="true" mayBeNull="true">The items that were added when action is add or replace.</param> 2513 /// <param name="newStartingIndex" type="Number" integer="true" optional="true" mayBeNull="true">The index where new items have been inserted.</param> 2514 /// <param name="oldItems" optional="true" mayBeNull="true">The items that were removed when action is remove or replace.</param> 2515 /// <param name="oldStartingIndex" type="Number" integer="true" optional="true" mayBeNull="true">The index where old items have been removed.</param> 2516 /// <field name="action" type="Sys.NotifyCollectionChangedAction" locid="F:J#Sys.CollectionChange.action"></field> 2517 /// <field name="newItems" type="Array" mayBeNull="true" elementMayBeNull="true" locid="F:J#Sys.CollectionChange.newItems">The items that were added when action is add.</field> 2518 /// <field name="newStartingIndex" type="Number" integer="true" locid="F:J#Sys.CollectionChange.newStartingIndex">The index where new items have been inserted.</field> 2519 /// <field name="oldItems" type="Array" mayBeNull="true" elementMayBeNull="true" locid="F:J#Sys.CollectionChange.oldItems">The items that were removed when action is remove.</field> 2520 /// <field name="oldStartingIndex" type="Number" integer="true" locid="F:J#Sys.CollectionChange.oldStartingIndex">The index where old items have been removed.</field> 2521 var e = Function._validateParams(arguments, [ 2522 {name: "action", type: Sys.NotifyCollectionChangedAction}, 2523 {name: "newItems", mayBeNull: true, optional: true}, 2524 {name: "newStartingIndex", type: Number, mayBeNull: true, integer: true, optional: true}, 2525 {name: "oldItems", mayBeNull: true, optional: true}, 2526 {name: "oldStartingIndex", type: Number, mayBeNull: true, integer: true, optional: true} 2527 ]); 2528 if (e) throw e; 2529 this.action = action; 2530 if (newItems) { 2531 if (!(newItems instanceof Array)) {
2532 newItems = [newItems]; 2533 } 2534 } 2535 this.newItems = newItems || null; 2536 if (typeof newStartingIndex !== "number") { 2537 newStartingIndex = -1; 2538 } 2539 this.newStartingIndex = newStartingIndex; 2540 if (oldItems) { 2541 if (!(oldItems instanceof Array)) { 2542 oldItems = [oldItems]; 2543 } 2544 } 2545 this.oldItems = oldItems || null; 2546 if (typeof oldStartingIndex !== "number") { 2547 oldStartingIndex = -1; 2548 } 2549 this.oldStartingIndex = oldStartingIndex; 2550} 2551$type.registerClass("Sys.CollectionChange"); 2552$type = Sys.NotifyCollectionChangedAction = function NotifyCollectionChangedAction() { 2553 /// <summary locid="M:J#Sys.NotifyCollectionChangedAction.#ctor">Describes how a collection has changed.</summary> 2554 /// <field name="add" type="Number" integer="true" static="true" locid="F:J#Sys.NotifyCollectionChangedAction.add"></field> 2555 /// <field name="remove" type="Number" integer="true" static="true" locid="F:J#Sys.NotifyCollectionChangedAction.remove"></field> 2556 /// <field name="reset" type="Number" integer="true" static="true" locid="F:J#Sys.NotifyCollectionChangedAction.reset"></field> 2557 if (arguments.length !== 0) throw Error.parameterCount(); 2558 throw Error.notImplemented(); 2559} 2560$type.prototype = { 2561 add: 0, 2562 remove: 1, 2563 reset: 2 2564} 2565$type.registerEnum('Sys.NotifyCollectionChangedAction'); 2566$type = Sys.NotifyCollectionChangedEventArgs = function NotifyCollectionChangedEventArgs(changes) { 2567 /// <summary locid="M:J#Sys.NotifyCollectionChangedEventArgs.#ctor">Describes how the collection was changed.</summary> 2568 /// <param name="changes" type="Array" elementType="Sys.CollectionChange">A list of changes that were performed on the collection since the last event.</param> 2569 var e = Function._validateParams(arguments, [ 2570 {name: "changes", type: Array, elementType: Sys.CollectionChange} 2571 ]); 2572 if (e) throw e; 2573 this._changes = changes; 2574 Sys.NotifyCollectionChangedEventArgs.initializeBase(this); 2575} 2576$type.prototype = { 2577 get_changes: function NotifyCollectionChangedEventArgs$get_changes() { 2578 /// <value type="Array" elementType="Sys.CollectionChange" locid="P:J#Sys.NotifyCollectionChangedEventArgs.changes"></value> 2579 if (arguments.length !== 0) throw Error.parameterCount(); 2580 return this._changes || []; 2581 } 2582} 2583$type.registerClass("Sys.NotifyCollectionChangedEventArgs", Sys.EventArgs); 2584 2585$type = Sys.Observer = function Observer() { 2586 throw Error.invalidOperation(); 2587} 2588$type.registerClass("Sys.Observer"); 2589 2590$type.makeObservable = function Observer$makeObservable(target) { 2591 /// <summary locid="M:J#Sys.Observer.makeObservable">Makes an object directly observable by adding observable methods to it.</summary> 2592 /// <param name="target" mayBeNull="false">The object, array, or DOM element to make observable.</param> 2593 /// <returns>The observable object.</returns> 2594 var e = Function._validateParams(arguments, [ 2595 {name: "target"} 2596 ]); 2597 if (e) throw e; 2598 var isArray = target instanceof Array, 2599 o = Sys.Observer; 2600 Sys.Observer._ensureObservable(target); 2601 if (target.setValue === o._observeMethods.setValue) return target; 2602 o._addMethods(target, o._observeMethods); 2603 if (isArray) { 2604 o._addMethods(target, o._arrayMethods); 2605 } 2606 return target; 2607} 2608 2609$type._ensureObservable = function Observer$_ensureObservable(target) { 2610 var type = typeof target; 2611 if ((type === "string") || (type === "number") || (type === "boolean") || (type === "date")) { 2612 throw Error.invalidOperation(String.format(Sys.Res.notObservable, type)); 2613 } 2614} 2615$type._addMethods = function Observer$_addMethods(target, methods) { 2616 for (var m in methods) { 2617 if (target[m] && (target[m] !== methods[m])) { 2618 throw Error.invalidOperation(String.format(Sys.Res.observableConflict, m)); 2619 } 2620 target[m] = methods[m]; 2621 } 2622} 2623$type._addEventHandler = function Observer$_addEventHandler(target, eventName, handler) { 2624 Sys.Observer._getContext(target, true).events._addHandler(eventName, handler); 2625} 2626$type.addEventHandler = function Observer$addEventHandler(target, eventName, handler) { 2627 /// <summary locid="M:J#Sys.Observer.addEventHandler">Adds an observable event handler to the target.</summary> 2628 /// <param name="target"></param> 2629 /// <param name="eventName" type="String"></param> 2630 /// <param name="handler" type="Function"></param> 2631 var e = Function._validateParams(arguments, [ 2632 {name: "target"}, 2633 {name: "eventName", type: String}, 2634 {name: "handler", type: Function} 2635 ]); 2636 if (e) throw e; 2637 Sys.Observer._ensureObservable(target); 2638 Sys.Observer._addEventHandler(target, eventName, handler); 2639} 2640$type._removeEventHandler = function Observer$_removeEventHandler(target, eventName, handler) { 2641 Sys.Observer._getContext(target, true).events._removeHandler(eventName, handler); 2642} 2643$type.removeEventHandler = function Observer$removeEventHandler(target, eventName, handler) { 2644 /// <summary locid="M:J#Sys.Observer.removeEventHandler">Removes an observable event handler from the target.</summary> 2645 /// <param name="target"></param> 2646 /// <param name="eventName" type="String"></param> 2647 /// <param name="handler" type="Function"></param> 2648 var e = Function._validateParams(arguments, [ 2649 {name: "target"}, 2650 {name: "eventName", type: String}, 2651 {name: "handler", type: Function} 2652 ]); 2653 if (e) throw e; 2654 Sys.Observer._ensureObservable(target); 2655 Sys.Observer._removeEventHandler(target, eventName, handler); 2656} 2657$type.clearEventHandlers = function Observer$clearEventHandlers(target, eventName) { 2658 /// <summary locid="M:J#Sys.Observer.clearEventHandlers">Removes all observable event handlers from the target.</summary> 2659 /// <param name="target"></param> 2660 /// <param name="eventName" type="String" mayBeNull="true" optional="true">If not given, handlers for all events are removed.</param> 2661 var e = Function._validateParams(arguments, [ 2662 {name: "target"}, 2663 {name: "eventName", type: String, mayBeNull: true, optional: true} 2664 ]); 2665 if (e) throw e; 2666 Sys.Observer._ensureObservable(target); 2667 Sys.Observer._getContext(target, true).events._removeHandlers(eventName); 2668} 2669$type.raiseEvent = function Observer$raiseEvent(target, eventName, eventArgs) { 2670 /// <summary locid="M:J#Sys.Observer.raiseEvent">Raises an observable event on the target.</summary> 2671 /// <param name="target"></param> 2672 /// <param name="eventName" type="String"></param> 2673 /// <param name="eventArgs" optional="true" mayBeNull="true"></param> 2674 var e = Function._validateParams(arguments, [ 2675 {name: "target"}, 2676 {name: "eventName", type: String}, 2677 {name: "eventArgs", mayBeNull: true, optional: true} 2678 ]); 2679 if (e) throw e; 2680 Sys.Observer._ensureObservable(target); 2681 var ctx = Sys.Observer._getContext(target); 2682 if (!ctx) return; 2683 var handler = ctx.events.getHandler(eventName); 2684 if (handler) { 2685 handler(target, eventArgs || Sys.EventArgs.Empty); 2686 } 2687} 2688$type.addPropertyChanged = function Observer$addPropertyChanged(target, handler) { 2689 /// <summary locid="M:J#Sys.Observer.addPropertyChanged">Adds a propertyChanged event handler to the target.</summary> 2690 /// <param name="target" mayBeNull="false">The object to observe.</param> 2691 /// <param name="handler" type="Function">The event handler.</param> 2692 var e = Function._validateParams(arguments, [ 2693 {name: "target"}, 2694 {name: "handler", type: Function} 2695 ]); 2696 if (e) throw e; 2697 Sys.Observer._ensureObservable(target); 2698 Sys.Observer._addEventHandler(target, "propertyChanged", handler); 2699} 2700$type.removePropertyChanged = function Observer$removePropertyChanged(target, handler) { 2701 /// <summary locid="M:J#Sys.Observer.removePropertyChanged">Removes a propertyChanged event handler from the target.</summary> 2702 /// <param name="target" mayBeNull="false">The object to observe.</param> 2703 /// <param name="handler" type="Function">The event handler.</param> 2704 var e = Function._validateParams(arguments, [ 2705 {name: "target"}, 2706 {name: "handler", type: Function} 2707 ]); 2708 if (e) throw e; 2709 Sys.Observer._ensureObservable(target); 2710 Sys.Observer._removeEventHandler(target, "propertyChanged", handler); 2711} 2712$type.beginUpdate = function Observer$beginUpdate(target) { 2713 /// <summary locid="M:J#Sys.Observer.beginUpdate"></summary> 2714 /// <param name="target" mayBeNull="false"></param> 2715 var e = Function._validateParams(arguments, [ 2716 {name: "target"} 2717 ]); 2718 if (e) throw e; 2719 Sys.Observer._ensureObservable(target); 2720 Sys.Observer._getContext(target, true).updating = true; 2721} 2722$type.endUpdate = function Observer$endUpdate(target) { 2723 /// <summary locid="M:J#Sys.Observer.endUpdate"></summary> 2724 /// <param name="target" mayBeNull="false"></param> 2725 var e = Function._validateParams(arguments, [ 2726 {name: "target"} 2727 ]); 2728 if (e) throw e; 2729 Sys.Observer._ensureObservable(target); 2730 var ctx = Sys.Observer._getContext(target); 2731 if (!ctx || !ctx.updating) return; 2732 ctx.updating = false; 2733 var dirty = ctx.dirty; 2734 ctx.dirty = false;
2735 if (dirty) { 2736 if (target instanceof Array) { 2737 var changes = ctx.changes; 2738 ctx.changes = null; 2739 Sys.Observer.raiseCollectionChanged(target, changes); 2740 } 2741 Sys.Observer.raisePropertyChanged(target, ""); 2742 } 2743} 2744$type.isUpdating = function Observer$isUpdating(target) { 2745 /// <summary locid="M:J#Sys.Observer.isUpdating"></summary> 2746 /// <param name="target" mayBeNull="false"></param> 2747 /// <returns type="Boolean"></returns> 2748 var e = Function._validateParams(arguments, [ 2749 {name: "target"} 2750 ]); 2751 if (e) throw e; 2752 Sys.Observer._ensureObservable(target); 2753 var ctx = Sys.Observer._getContext(target); 2754 return ctx ? ctx.updating : false; 2755} 2756$type._setValue = function Observer$_setValue(target, propertyName, value) { 2757 var getter, setter, mainTarget = target, path = propertyName.split('.'); 2758 for (var i = 0, l = (path.length - 1); i < l ; i++) { 2759 var name = path[i]; 2760 getter = target["get_" + name]; 2761 if (typeof (getter) === "function") { 2762 target = getter.call(target); 2763 } 2764 else { 2765 target = target[name]; 2766 } 2767 var type = typeof (target); 2768 if ((target === null) || (type === "undefined")) { 2769 throw Error.invalidOperation(String.format(Sys.Res.nullReferenceInPath, propertyName)); 2770 } 2771 } 2772 var currentValue, lastPath = path[l]; 2773 getter = target["get_" + lastPath]; 2774 if (typeof(getter) === 'function') { 2775 currentValue = getter.call(target); 2776 } 2777 else { 2778 currentValue = target[lastPath]; 2779 } 2780 callIf(target, "set_" + lastPath, value) || (target[lastPath] = value); 2781 if (currentValue !== value) { 2782 var ctx = Sys.Observer._getContext(mainTarget); 2783 if (ctx && ctx.updating) { 2784 ctx.dirty = true; 2785 return; 2786 }; 2787 Sys.Observer.raisePropertyChanged(mainTarget, path[0]); 2788 } 2789} 2790$type.setValue = function Observer$setValue(target, propertyName, value) { 2791 /// <summary locid="M:J#Sys.Observer.setValue">Sets a property or field on the target in an observable manner.</summary> 2792 /// <param name="target" mayBeNull="false">The object to set a property on.</param> 2793 /// <param name="propertyName" type="String">The name of the property to field to set.</param> 2794 /// <param name="value" mayBeNull="true">The value to set.</param> 2795 var e = Function._validateParams(arguments, [ 2796 {name: "target"}, 2797 {name: "propertyName", type: String}, 2798 {name: "value", mayBeNull: true} 2799 ]); 2800 if (e) throw e; 2801 Sys.Observer._ensureObservable(target); 2802 Sys.Observer._setValue(target, propertyName, value); 2803} 2804$type.raisePropertyChanged = function Observer$raisePropertyChanged(target, propertyName) { 2805 /// <summary locid="M:J#Sys.Observer.raisePropertyChanged">Raises a change notification event.</summary> 2806 /// <param name="target" mayBeNull="false">The object to raise the event on.</param> 2807 /// <param name="propertyName" type="String">The name of the property that changed.</param> 2808 Sys.Observer.raiseEvent(target, "propertyChanged", new Sys.PropertyChangedEventArgs(propertyName)); 2809} 2810 2811$type.addCollectionChanged = function Observer$addCollectionChanged(target, handler) { 2812 /// <summary locid="M:J#Sys.Observer.addCollectionChanged"></summary> 2813 /// <param name="target" type="Array" elementMayBeNull="true"></param> 2814 /// <param name="handler" type="Function"></param> 2815 var e = Function._validateParams(arguments, [ 2816 {name: "target", type: Array, elementMayBeNull: true}, 2817 {name: "handler", type: Function} 2818 ]); 2819 if (e) throw e; 2820 Sys.Observer._addEventHandler(target, "collectionChanged", handler); 2821} 2822$type.removeCollectionChanged = function Observer$removeCollectionChanged(target, handler) { 2823 /// <summary locid="M:J#Sys.Observer.removeCollectionChanged"></summary> 2824 /// <param name="target" type="Array" elementMayBeNull="true"></param> 2825 /// <param name="handler" type="Function"></param> 2826 var e = Function._validateParams(arguments, [ 2827 {name: "target", type: Array, elementMayBeNull: true}, 2828 {name: "handler", type: Function} 2829 ]); 2830 if (e) throw e; 2831 Sys.Observer._removeEventHandler(target, "collectionChanged", handler); 2832} 2833$type._collectionChange = function Observer$_collectionChange(target, change) { 2834 var ctx = this._getContext(target); 2835 if (ctx && ctx.updating) { 2836 ctx.dirty = true; 2837 var changes = ctx.changes; 2838 if (!changes) { 2839 ctx.changes = changes = [change]; 2840 } 2841 else { 2842 changes.push(change); 2843 } 2844 } 2845 else { 2846 this.raiseCollectionChanged(target, [change]); 2847 this.raisePropertyChanged(target, 'length'); 2848 } 2849} 2850$type.add = function Observer$add(target, item) { 2851 /// <summary locid="M:J#Sys.Observer.add">Adds an item to the collection in an observable manner.</summary> 2852 /// <param name="target" type="Array" elementMayBeNull="true">The array to add to.</param> 2853 /// <param name="item" mayBeNull="true">The item to add.</param> 2854 var e = Function._validateParams(arguments, [ 2855 {name: "target", type: Array, elementMayBeNull: true}, 2856 {name: "item", mayBeNull: true} 2857 ]); 2858 if (e) throw e; 2859 var change = new Sys.CollectionChange(Sys.NotifyCollectionChangedAction.add, [item], target.length); 2860 Array.add(target, item); 2861 Sys.Observer._collectionChange(target, change); 2862} 2863$type.addRange = function Observer$addRange(target, items) { 2864 /// <summary locid="M:J#Sys.Observer.addRange">Adds items to the collection in an observable manner.</summary> 2865 /// <param name="target" type="Array" elementMayBeNull="true">The array to add to.</param> 2866 /// <param name="items" type="Array" elementMayBeNull="true">The array of items to add.</param> 2867 var e = Function._validateParams(arguments, [ 2868 {name: "target", type: Array, elementMayBeNull: true}, 2869 {name: "items", type: Array, elementMayBeNull: true} 2870 ]); 2871 if (e) throw e; 2872 var change = new Sys.CollectionChange(Sys.NotifyCollectionChangedAction.add, items, target.length); 2873 Array.addRange(target, items); 2874 Sys.Observer._collectionChange(target, change); 2875} 2876$type.clear = function Observer$clear(target) { 2877 /// <summary locid="M:J#Sys.Observer.clear">Clears the array of its elements in an observable manner.</summary> 2878 /// <param name="target" type="Array" elementMayBeNull="true">The array to clear.</param> 2879 var e = Function._validateParams(arguments, [ 2880 {name: "target", type: Array, elementMayBeNull: true} 2881 ]); 2882 if (e) throw e; 2883 var oldItems = Array.clone(target); 2884 Array.clear(target); 2885 Sys.Observer._collectionChange(target, new Sys.CollectionChange(Sys.NotifyCollectionChangedAction.reset, null, -1, oldItems, 0)); 2886} 2887$type.insert = function Observer$insert(target, index, item) { 2888 /// <summary locid="M:J#Sys.Observer.insert">Inserts an item at the specified index in an observable manner.</summary> 2889 /// <param name="target" type="Array" elementMayBeNull="true">The array to insert into.</param> 2890 /// <param name="index" type="Number" integer="true">The index where the item will be inserted.</param> 2891 /// <param name="item" mayBeNull="true">The item to insert.</param> 2892 var e = Function._validateParams(arguments, [ 2893 {name: "target", type: Array, elementMayBeNull: true}, 2894 {name: "index", type: Number, integer: true}, 2895 {name: "item", mayBeNull: true} 2896 ]); 2897 if (e) throw e; 2898 Array.insert(target, index, item); 2899 Sys.Observer._collectionChange(target, new Sys.CollectionChange(Sys.NotifyCollectionChangedAction.add, [item], index)); 2900} 2901$type.remove = function Observer$remove(target, item) { 2902 /// <summary locid="M:J#Sys.Observer.remove">Removes the first occurence of an item from the array in an observable manner.</summary> 2903 /// <param name="target" type="Array" elementMayBeNull="true">The array to remove from.</param> 2904 /// <param name="item" mayBeNull="true">The item to remove.</param> 2905 /// <returns type="Boolean">True if the item was found.</returns> 2906 var e = Function._validateParams(arguments, [ 2907 {name: "target", type: Array, elementMayBeNull: true}, 2908 {name: "item", mayBeNull: true} 2909 ]); 2910 if (e) throw e; 2911 var index = Array.indexOf(target, item); 2912 if (index !== -1) { 2913 Array.remove(target, item); 2914 Sys.Observer._collectionChange(target, new Sys.CollectionChange(Sys.NotifyCollectionChangedAction.remove, null, -1, [item], index)); 2915 return true; 2916 } 2917 return false; 2918} 2919$type.removeAt = function Observer$removeAt(target, index) { 2920 /// <summary locid="M:J#Sys.Observer.removeAt">Removes the item at the specified index from the array in an observable manner.</summary> 2921 /// <param name="target" type="Array" elementMayBeNull="true">The array to remove from.</param> 2922 /// <param name="index" type="Number" integer="true">The index of the item to remove.</param> 2923 var e = Function._validateParams(arguments, [ 2924 {name: "target", type: Array, elementMayBeNull: true}, 2925 {name: "index", type: Number, integer: true} 2926 ]); 2927 if (e) throw e; 2928 if ((index > -1) && (index < target.length)) { 2929 var item = target[index]; 2930 Array.removeAt(target, index); 2931 Sys.Observer._collectionChange(target, new Sys.CollectionChange(Sys.NotifyCollectionChangedAction.remove, null, -1, [item], index)); 2932 } 2933} 2934$type.raiseCollectionChanged = function Observer$raiseCollectionChanged(target, changes) { 2935 /// <summary locid="M:J#Sys.Observer.raiseCollectionChanged">Raises the collectionChanged event.</summary> 2936 /// <param name="target">The collection to raise the event on.</param> 2937 /// <param name="changes" type="Array" elementType="Sys.CollectionChange">A list of changes that were performed on the collection since the last event.</param> 2938 Sys.Observer.raiseEvent(target, "collectionChanged", new Sys.NotifyCollectionChangedEventArgs(changes)); 2939} 2940 2941$type._observeMethods = { 2942 add_propertyChanged: function(handler) { 2943 Sys.Observer._addEventHandler(this, "propertyChanged", handler); 2944 }, 2945 remove_propertyChanged: function(handler) { 2946 Sys.Observer._removeEventHandler(this, "propertyChanged", handler); 2947 }, 2948 addEventHandler: function(eventName, handler) { 2949 /// <summary locid="M:J#Sys.Observer.raiseCollectionChanged">Adds an observable event handler.</summary> 2950 /// <param name="eventName" type="String"></param> 2951 /// <param name="handler" type="Function"></param> 2952 var e = Function._validateParams(arguments, [ 2953 {name: "eventName", type: String}, 2954 {name: "handler", type: Function} 2955 ]); 2956 if (e) throw e; 2957 Sys.Observer._addEventHandler(this, eventName, handler); 2958 }, 2959 removeEventHandler: function(eventName, handler) { 2960 /// <summary locid="M:J#Sys.Observer.raiseCollectionChanged">Removes an observable event handler.</summary> 2961 /// <param name="eventName" type="String"></param> 2962 /// <param name="handler" type="Function"></param> 2963 var e = Function._validateParams(arguments, [ 2964 {name: "eventName", type: String}, 2965 {name: "handler", type: Function} 2966 ]); 2967 if (e) throw e; 2968 Sys.Observer._removeEventHandler(this, eventName, handler); 2969 }, 2970 clearEventHandlers: function(eventName) { 2971 /// <summary locid="M:J#Sys.Observer.raiseCollectionChanged">Removes all observable event handlers from the target.</summary> 2972 /// <param name="target"></param> 2973 /// <param name="eventName" type="String" mayBeNull="true" optional="true">If not given, handlers for all events are removed.</param> 2974 var e = Function._validateParams(arguments, [ 2975 {name: "target"}, 2976 {name: "eventName", type: String, mayBeNull: true, optional: true} 2977 ]); 2978 if (e) throw e; 2979 Sys.Observer._getContext(this, true).events._removeHandlers(eventName); 2980 }, 2981 get_isUpdating: function() { 2982 /// <summary locid="M:J#Sys.Observer.raiseCollectionChanged"></summary> 2983 /// <returns type="Boolean"></returns> 2984 return Sys.Observer.isUpdating(this); 2985 }, 2986 beginUpdate: function() { 2987 /// <summary locid="M:J#Sys.Observer.raiseCollectionChanged"></summary> 2988 Sys.Observer.beginUpdate(this); 2989 }, 2990 endUpdate: function() { 2991 /// <summary locid="M:J#Sys.Observer.raiseCollectionChanged"></summary> 2992 Sys.Observer.endUpdate(this); 2993 }, 2994 setValue: function(name, value) { 2995 /// <summary locid="M:J#Sys.Observer.raiseCollectionChanged">Sets a property or field on the target in an observable manner.</summary> 2996 /// <param name="name" type="String">The name of the property to field to set.</param> 2997 /// <param name="value" mayBeNull="true">The value to set.</param> 2998 var e = Function._validateParams(arguments, [ 2999 {name: "name", type: String}, 3000 {name: "value", mayBeNull: true} 3001 ]); 3002 if (e) throw e; 3003 Sys.Observer._setValue(this, name, value); 3004 }, 3005 raiseEvent: function(eventName, eventArgs) { 3006 /// <summary locid="M:J#Sys.Observer.raiseCollectionChanged">Raises an observable event.</summary> 3007 /// <param name="eventName" type="String"></param> 3008 /// <param name="eventArgs" optional="true" mayBeNull="true"></param> 3009 Sys.Observer.raiseEvent(this, eventName, eventArgs||null); 3010 }, 3011 raisePropertyChanged: function(name) { 3012 /// <summary locid="M:J#Sys.Observer.raiseCollectionChanged">Raises a change notification event.</summary> 3013 /// <param name="name" type="String">The name of the property that changed.</param> 3014 Sys.Observer.raiseEvent(this, "propertyChanged", new Sys.PropertyChangedEventArgs(name)); 3015 } 3016} 3017$type._arrayMethods = { 3018 add_collectionChanged: function(handler) { 3019 Sys.Observer._addEventHandler(this, "collectionChanged", handler); 3020 }, 3021 remove_collectionChanged: function(handler) { 3022 Sys.Observer._removeEventHandler(this, "collectionChanged", handler); 3023 }, 3024 add: function(item) { 3025 /// <summary locid="M:J#Sys.Observer.raiseCollectionChanged">Adds an item to the collection in an observable manner.</summary> 3026 /// <param name="item" mayBeNull="true">The item to add.</param> 3027 Sys.Observer.add(this, item); 3028 }, 3029 addRange: function(items) { 3030 /// <summary locid="M:J#Sys.Observer.raiseCollectionChanged">Adds items to the collection in an observable manner.</summary> 3031 /// <param name="items" type="Array" elementMayBeNull="true">The array of items to add.</param> 3032 Sys.Observer.addRange(this, items); 3033 }, 3034 clear: function() { 3035 /// <summary locid="M:J#Sys.Observer.raiseCollectionChanged">Clears the array of its elements in an observable manner.</summary> 3036 Sys.Observer.clear(this); 3037 }, 3038 insert: function(index, item) { 3039 /// <summary locid="M:J#Sys.Observer.raiseCollectionChanged">Inserts an item at the specified index in an observable manner.</summary> 3040 /// <param name="index" type="Number" integer="true">The index where the item will be inserted.</param> 3041 /// <param name="item" mayBeNull="true">The item to insert.</param> 3042 Sys.Observer.insert(this, index, item); 3043 }, 3044 remove: function(item) { 3045 /// <summary locid="M:J#Sys.Observer.raiseCollectionChanged">Removes the first occurence of an item from the array in an observable manner.</summary> 3046 /// <param name="item" mayBeNull="true">The item to remove.</param> 3047 /// <returns type="Boolean">True if the item was found.</returns> 3048 return Sys.Observer.remove(this, item); 3049 }, 3050 removeAt: function(index) { 3051 /// <summary locid="M:J#Sys.Observer.raiseCollectionChanged">Removes the item at the specified index from the array in an observable manner.</summary> 3052 /// <param name="index" type="Number" integer="true">The index of the item to
3052remove.</param> 3053 Sys.Observer.removeAt(this, index); 3054 }, 3055 raiseCollectionChanged: function(changes) { 3056 /// <summary locid="M:J#Sys.Observer.raiseCollectionChanged">Raises the collectionChanged event.</summary> 3057 /// <param name="changes" type="Array" elementType="Sys.CollectionChange">A list of changes that were performed on the collection since the last event.</param> 3058 Sys.Observer.raiseEvent(this, "collectionChanged", new Sys.NotifyCollectionChangedEventArgs(changes)); 3059 } 3060} 3061$type._getContext = function Observer$_getContext(obj, create) { 3062 var ctx = obj._observerContext; 3063 if (ctx) return ctx(); 3064 if (create) { 3065 return (obj._observerContext = this._createContext())(); 3066 } 3067 return null; 3068} 3069$type._createContext = function Observer$_createContext() { 3070 var ctx = { 3071 events: new Sys.EventHandlerList() 3072 }; 3073 return function() { 3074 return ctx; 3075 } 3076} 3077 3078 3079function outOfRange(value, low, high) { 3080 return (value < low) || (value > high); 3081} 3082 3083function expandYear(dtf, year) { 3084 var now = new Date(), 3085 era = getEra(now); 3086 if (year < 100) { 3087 var curr = getEraYear(now, dtf, era); 3088 year += curr - (curr % 100); 3089 if (year > dtf.Calendar.TwoDigitYearMax) { 3090 year -= 100; 3091 } 3092 } 3093 return year; 3094} 3095 3096function getEra(date, eras) { 3097 if (!eras) return 0; 3098 var start, ticks = date.getTime(); 3099 for (var i = 0, l = eras.length; i < l; i += 4) { 3100 start = eras[i+2]; 3101 if ((start === null) || (ticks >= start)) { 3102 return i; 3103 } 3104 } 3105 return 0; 3106} 3107 3108function getEraYear(date, dtf, era, sortable) { 3109 var year = date.getFullYear(); 3110 if (!sortable && dtf.eras) { 3111 year -= dtf.eras[era + 3]; 3112 } 3113 return year; 3114} 3115 3116Sys._appendPreOrPostMatch = function _appendPreOrPostMatch(preMatch, strings) { 3117 var quoteCount = 0; 3118 var escaped = false; 3119 for (var i = 0, il = preMatch.length; i < il; i++) { 3120 var c = preMatch.charAt(i); 3121 switch (c) { 3122 case '\'': 3123 if (escaped) strings.push("'"); 3124 else quoteCount++; 3125 escaped = false; 3126 break; 3127 case '\\': 3128 if (escaped) strings.push("\\"); 3129 escaped = !escaped; 3130 break; 3131 default: 3132 strings.push(c); 3133 escaped = false; 3134 break; 3135 } 3136 } 3137 return quoteCount; 3138} 3139 3140$type = Date; 3141$type._expandFormat = function Date$_expandFormat(dtf, format) { 3142 format = format || "F"; 3143 var len = format.length; 3144 if (len === 1) { 3145 switch (format) { 3146 case "d": 3147 return dtf["ShortDatePattern"]; 3148 case "D": 3149 return dtf["LongDatePattern"]; 3150 case "t": 3151 return dtf["ShortTimePattern"]; 3152 case "T": 3153 return dtf["LongTimePattern"]; 3154 case "f": 3155 return dtf["LongDatePattern"] + " " + dtf["ShortTimePattern"]; 3156 case "F": 3157 return dtf["FullDateTimePattern"]; 3158 case "M": case "m": 3159 return dtf["MonthDayPattern"]; 3160 case "s": 3161 return dtf["SortableDateTimePattern"]; 3162 case "Y": case "y": 3163 return dtf["YearMonthPattern"]; 3164 default: 3165 throw Error.format(Sys.Res.formatInvalidString); 3166 } 3167 } 3168 else if ((len === 2) && (format.charAt(0) === "%")) { 3169 format = format.charAt(1); 3170 } 3171 return format; 3172} 3173 3174$type._getParseRegExp = function Date$_getParseRegExp(dtf, format) { 3175 var re = dtf._parseRegExp; 3176 if (!re) { 3177 dtf._parseRegExp = re = {}; 3178 } 3179 else { 3180 var reFormat = re[format]; 3181 if (reFormat) { 3182 return reFormat; 3183 } 3184 } 3185 3186 var expFormat = Date._expandFormat(dtf, format); 3187 expFormat = expFormat.replace(/([\^\$\.\*\+\?\|\[\]\(\)\{\}])/g, "\\\\$1"); 3188 3189 var regexp = ["^"]; 3190 var groups = []; 3191 var index = 0; 3192 var quoteCount = 0; 3193 var tokenRegExp = Date._getTokenRegExp(); 3194 var match; 3195 3196 while ((match = tokenRegExp.exec(expFormat)) !== null) { 3197 var preMatch = expFormat.slice(index, match.index); 3198 index = tokenRegExp.lastIndex; 3199 3200 quoteCount += Sys._appendPreOrPostMatch(preMatch, regexp); 3201 if (quoteCount % 2) { 3202 regexp.push(match[0]); 3203 continue; 3204 } 3205 3206 var m = match[0], 3207 len = m.length, 3208 add; 3209 switch (m) { 3210 case 'dddd': case 'ddd': 3211 case 'MMMM': case 'MMM': 3212 case 'gg': case 'g': 3213 add = "(\\D+)"; 3214 break; 3215 case 'tt': case 't': 3216 add = "(\\D*)"; 3217 break; 3218 case 'yyyy': 3219 case 'fff': 3220 case 'ff': 3221 case 'f': 3222 add = "(\\d{" + len + "})"; 3223 break; 3224 case 'dd': case 'd': 3225 case 'MM': case 'M': 3226 case 'yy': case 'y': 3227 case 'HH': case 'H': 3228 case 'hh': case 'h': 3229 case 'mm': case 'm': 3230 case 'ss': case 's': 3231 add = "(\\d\\d?)"; 3232 break; 3233 case 'zzz': 3234 add = "([+-]?\\d\\d?:\\d{2})"; 3235 break; 3236 case 'zz': case 'z': 3237 add = "([+-]?\\d\\d?)"; 3238 break; 3239 case '/': 3240 add = "(\\" + dtf.DateSeparator + ")"; 3241 break; 3242 } 3243 if (add) { 3244 regexp.push(add); 3245 } 3246 groups.push(match[0]); 3247 } 3248 Sys._appendPreOrPostMatch(expFormat.slice(index), regexp); 3249 regexp.push("$"); 3250 var regexpStr = regexp.join('').replace(/\s+/g, "\\s+"); 3251 var parseRegExp = {'regExp': regexpStr, 'groups': groups}; 3252 re[format] = parseRegExp; 3253 return parseRegExp; 3254} 3255 3256$type._getTokenRegExp = function Date$_getTokenRegExp() { 3257 return /\/|dddd|ddd|dd|d|MMMM|MMM|MM|M|yyyy|yy|y|hh|h|HH|H|mm|m|ss|s|tt|t|fff|ff|f|zzz|zz|z|gg|g/g; 3258} 3259 3260$type.parseLocale = function Date$parseLocale(value, formats) { 3261 /// <summary locid="M:J#Date.parseLocale">Creates a date from a locale-specific string representation.</summary> 3262 /// <param name="value" type="String">A locale-specific string that can parse to a date.</param> 3263 /// <param name="formats" parameterArray="true" optional="true" mayBeNull="true">Custom formats to match.</param> 3264 /// <returns type="Date"></returns> 3265 var e = Function._validateParams(arguments, [ 3266 {name: "value", type: String}, 3267 {name: "formats", mayBeNull: true, optional: true, parameterArray: true} 3268 ]); 3269 if (e) throw e; 3270 return Date._parse(value, Sys.CultureInfo.CurrentCulture, arguments); 3271} 3272 3273$type.parseInvariant = function Date$parseInvariant(value, formats) { 3274 /// <summary locid="M:J#Date.parseInvariant">Creates a date from its string representation.</summary> 3275 /// <param name="value" type="String">A string that can parse to a date.</param> 3276 /// <param name="formats" parameterArray="true" optional="true" mayBeNull="true">Custom formats to match.</param> 3277 /// <returns type="Date"></returns> 3278 var e = Function._validateParams(arguments, [ 3279 {name: "value", type: String}, 3280 {name: "formats", mayBeNull: true, optional: true, parameterArray: true} 3281 ]); 3282 if (e) throw e; 3283 return Date._parse(value, Sys.CultureInfo.InvariantCulture, arguments); 3284} 3285 3286$type._parse = function Date$_parse(value, cultureInfo, args) { 3287 var i, l, date, format, formats, custom = false; 3288 for (i = 1, l = args.length; i < l; i++) { 3289 format = args[i];
3290 if (format) { 3291 custom = true; 3292 date = Date._parseExact(value, format, cultureInfo); 3293 if (date) return date; 3294 } 3295 } 3296 if (! custom) { 3297 formats = cultureInfo._getDateTimeFormats(); 3298 for (i = 0, l = formats.length; i < l; i++) { 3299 date = Date._parseExact(value, formats[i], cultureInfo); 3300 if (date) return date; 3301 } 3302 } 3303 return null; 3304} 3305 3306$type._parseExact = function Date$_parseExact(value, format, cultureInfo) { 3307 value = value.trim(); 3308 var dtf = cultureInfo.dateTimeFormat, 3309 parseInfo = this._getParseRegExp(dtf, format), 3310 match = new RegExp(parseInfo.regExp).exec(value); 3311 if (match === null) return null; 3312 3313 var groups = parseInfo.groups, 3314 era = null, year = null, month = null, date = null, weekDay = null, 3315 hour = 0, hourOffset, min = 0, sec = 0, msec = 0, tzMinOffset = null, 3316 pmHour = false; 3317 3318 for (var j = 0, jl = groups.length; j < jl; j++) { 3319 var matchGroup = match[j+1]; 3320 if (matchGroup) { 3321 var current = groups[j], 3322 clength = current.length, 3323 matchInt = parseInt(matchGroup, 10); 3324 switch (current) { 3325 case 'dd': case 'd': 3326 date = matchInt; 3327 if (outOfRange(date, 1, 31)) return null; 3328 break; 3329 case 'MMM': 3330 case 'MMMM': 3331 month = cultureInfo._getMonthIndex(matchGroup, clength === 3); 3332 if (outOfRange(month, 0, 11)) return null; 3333 break; 3334 case 'M': case 'MM': 3335 month = matchInt - 1; 3336 if (outOfRange(month, 0, 11)) return null; 3337 break; 3338 case 'y': case 'yy': 3339 case 'yyyy': 3340 year = clength < 4 ? expandYear(dtf,matchInt) : matchInt; 3341 if (outOfRange(year, 0, 9999)) return null; 3342 break; 3343 case 'h': case 'hh': 3344 hour = matchInt; 3345 if (hour === 12) hour = 0; 3346 if (outOfRange(hour, 0, 11)) return null; 3347 break; 3348 case 'H': case 'HH': 3349 hour = matchInt; 3350 if (outOfRange(hour, 0, 23)) return null; 3351 break; 3352 case 'm': case 'mm': 3353 min = matchInt; 3354 if (outOfRange(min, 0, 59)) return null; 3355 break; 3356 case 's': case 'ss': 3357 sec = matchInt; 3358 if (outOfRange(sec, 0, 59)) return null; 3359 break; 3360 case 'tt': case 't': 3361 var upperToken = matchGroup.toUpperCase(); 3362 pmHour = (upperToken === dtf.PMDesignator.toUpperCase()); 3363 if (!pmHour && (upperToken !== dtf.AMDesignator.toUpperCase())) return null; 3364 break; 3365 case 'f': 3366 case 'ff': 3367 case 'fff': 3368 msec = matchInt * Math.pow(10, 3-clength); 3369 if (outOfRange(msec, 0, 999)) return null; 3370 break; 3371 case 'ddd': 3372 case 'dddd': 3373 weekDay = cultureInfo._getDayIndex(matchGroup, clength === 3); 3374 if (outOfRange(weekDay, 0, 6)) return null; 3375 break; 3376 case 'zzz': 3377 var offsets = matchGroup.split(/:/); 3378 if (offsets.length !== 2) return null; 3379 hourOffset = parseInt(offsets[0], 10); 3380 if (outOfRange(hourOffset, -12, 13)) return null; 3381 var minOffset = parseInt(offsets[1], 10); 3382 if (outOfRange(minOffset, 0, 59)) return null; 3383 tzMinOffset = (hourOffset * 60) + (matchGroup.startsWith('-')? -minOffset : minOffset); 3384 break; 3385 case 'z': case 'zz': 3386 hourOffset = matchInt; 3387 if (outOfRange(hourOffset, -12, 13)) return null; 3388 tzMinOffset = hourOffset * 60; 3389 break; 3390 case 'g': case 'gg': 3391 var eraName = matchGroup; 3392 if (!eraName || !dtf.eras) return null; 3393 eraName = eraName.toLowerCase().trim(); 3394 for (var i = 0, l = dtf.eras.length; i < l; i += 4) { 3395 if (eraName === dtf.eras[i + 1].toLowerCase()) { 3396 era = i; 3397 break; 3398 } 3399 } 3400 if (era === null) return null; 3401 break; 3402 } 3403 } 3404 } 3405 var result = new Date(), defaultYear, convert = dtf.Calendar.convert; 3406 defaultYear = convert ? convert.fromGregorian(result)[0] : result.getFullYear(); 3407 if (year === null) { 3408 year = defaultYear; 3409 } 3410 else if (dtf.eras) { 3411 year += dtf.eras[(era || 0) + 3]; 3412 } 3413 if (month === null) {
3414 month = 0; 3415 } 3416 if (date === null) { 3417 date = 1; 3418 } 3419 if (convert) { 3420 result = convert.toGregorian(year, month, date); 3421 if (result === null) return null; 3422 } 3423 else { 3424 result.setFullYear(year, month, date); 3425 if (result.getDate() !== date) return null; 3426 if ((weekDay !== null) && (result.getDay() !== weekDay)) { 3427 return null; 3428 } 3429 } 3430 if (pmHour && (hour < 12)) { 3431 hour += 12; 3432 } 3433 result.setHours(hour, min, sec, msec); 3434 if (tzMinOffset !== null) { 3435 var adjustedMin = result.getMinutes() - (tzMinOffset + result.getTimezoneOffset()); 3436 result.setHours(result.getHours() + parseInt(adjustedMin/60, 10), adjustedMin%60); 3437 } 3438 return result; 3439} 3440 3441$prototype = $type.prototype; 3442$prototype.format = function Date$format(format) { 3443 /// <summary locid="M:J#Date.format">Format a date using the invariant culture.</summary> 3444 /// <param name="format" type="String">Format string.</param> 3445 /// <returns type="String">Formatted date.</returns> 3446 var e = Function._validateParams(arguments, [ 3447 {name: "format", type: String} 3448 ]); 3449 if (e) throw e; 3450 return this._toFormattedString(format, Sys.CultureInfo.InvariantCulture); 3451} 3452 3453$prototype.localeFormat = function Date$localeFormat(format) { 3454 /// <summary locid="M:J#Date.localeFormat">Format a date using the current culture.</summary> 3455 /// <param name="format" type="String">Format string.</param> 3456 /// <returns type="String">Formatted date.</returns> 3457 var e = Function._validateParams(arguments, [ 3458 {name: "format", type: String} 3459 ]); 3460 if (e) throw e; 3461 return this._toFormattedString(format, Sys.CultureInfo.CurrentCulture); 3462} 3463 3464$prototype._toFormattedString = function Date$_toFormattedString(format, cultureInfo) { 3465 var dtf = cultureInfo.dateTimeFormat, 3466 convert = dtf.Calendar.convert; 3467 if (!format || !format.length || (format === 'i')) { 3468 var ret; 3469 if (cultureInfo && cultureInfo.name.length) { 3470 if (convert) { 3471 ret = this._toFormattedString(dtf.FullDateTimePattern, cultureInfo); 3472 } 3473 else { 3474 var eraDate = new Date(this.getTime()); 3475 var era = getEra(this, dtf.eras); 3476 eraDate.setFullYear(getEraYear(this, dtf, era)); 3477 ret = eraDate.toLocaleString(); 3478 } 3479 } 3480 else { 3481 ret = this.toString(); 3482 } 3483 return ret; 3484 } 3485 3486 var eras = dtf.eras, 3487 sortable = (format === "s"); 3488 format = Date._expandFormat(dtf, format); 3489 3490 ret = []; 3491 var hour; 3492 3493 var zeros = ['0','00','000']; 3494 function padZeros(num, c) { 3495 var s = num+''; 3496 return ((c > 1) && (s.length < c)) ? (zeros[c-2]+s).substr(-c) : s; 3497 } 3498 3499 var foundDay, checkedDay, dayPartRegExp = /([^d]|^)(d|dd)([^d]|$)/g; 3500 function hasDay() { 3501 if (foundDay || checkedDay) { 3502 return foundDay; 3503 } 3504 foundDay = dayPartRegExp.test(format); 3505 checkedDay = true; 3506 return foundDay; 3507 } 3508 3509 var quoteCount = 0, 3510 tokenRegExp = Date._getTokenRegExp(), 3511 converted; 3512 if (!sortable && convert) { 3513 converted = convert.fromGregorian(this); 3514 } 3515 for (;;) { 3516 3517 var index = tokenRegExp.lastIndex; 3518 3519 var ar = tokenRegExp.exec(format); 3520 3521 var preMatch = format.slice(index, ar ? ar.index : format.length); 3522 quoteCount += Sys._appendPreOrPostMatch(preMatch, ret); 3523 3524 if (!ar) break; 3525 3526 if (quoteCount % 2) { 3527 ret.push(ar[0]); 3528 continue; 3529 } 3530 3531 function getPart(date, part) { 3532 if (converted) { 3533 return converted[part]; 3534 } 3535 switch (part) { 3536 case 0: return date.getFullYear(); 3537 case 1: return date.getMonth(); 3538 case 2: return date.getDate(); 3539 } 3540 } 3541 3542 var current = ar[0], 3543 clength = current.length; 3544 3545 switch (current) { 3546 case "ddd": 3547 case "dddd": 3548 names = (clength === 3) ? dtf.AbbreviatedDayNames : dtf.DayNames;
3549 ret.push(names[this.getDay()]); 3550 break; 3551 case "d": 3552 case "dd": 3553 foundDay = true; 3554 ret.push(padZeros(getPart(this, 2), clength)); 3555 break; 3556 case "MMM": 3557 case "MMMM": 3558 var namePrefix = (clength === 3 ? "Abbreviated" : ""), 3559 genitiveNames = dtf[namePrefix + "MonthGenitiveNames"], 3560 names = dtf[namePrefix + "MonthNames"], 3561 part = getPart(this, 1); 3562 ret.push((genitiveNames && hasDay()) 3563 ? genitiveNames[part] 3564 : names[part]); 3565 break; 3566 case "M": 3567 case "MM": 3568 ret.push(padZeros(getPart(this, 1) + 1, clength)); 3569 break; 3570 case "y": 3571 case "yy": 3572 case "yyyy": 3573 part = converted ? converted[0] : getEraYear(this, dtf, getEra(this, eras), sortable); 3574 if (clength < 4) { 3575 part = part % 100; 3576 } 3577 ret.push(padZeros(part, clength)); 3578 break; 3579 case "h": 3580 case "hh": 3581 hour = this.getHours() % 12; 3582 if (hour === 0) hour = 12; 3583 ret.push(padZeros(hour, clength)); 3584 break; 3585 case "H": 3586 case "HH": 3587 ret.push(padZeros(this.getHours(), clength)); 3588 break; 3589 case "m": 3590 case "mm": 3591 ret.push(padZeros(this.getMinutes(), clength)); 3592 break; 3593 case "s": 3594 case "ss": 3595 ret.push(padZeros(this.getSeconds(), clength)); 3596 break; 3597 case "t": 3598 case "tt": 3599 part = (this.getHours() < 12) ? dtf.AMDesignator : dtf.PMDesignator; 3600 ret.push(clength === 1 ? part.charAt(0) : part); 3601 break; 3602 case "f": 3603 case "ff": 3604 case "fff": 3605 ret.push(padZeros(this.getMilliseconds(), 3).substr(0, clength)); 3606 break; 3607 case "z": 3608 case "zz": 3609 hour = this.getTimezoneOffset() / 60; 3610 ret.push(((hour <= 0) ? '+' : '-') + padZeros(Math.floor(Math.abs(hour)), clength)); 3611 break; 3612 case "zzz": 3613 hour = this.getTimezoneOffset() / 60; 3614 ret.push(((hour <= 0) ? '+' : '-') + padZeros(Math.floor(Math.abs(hour)), 2) + 3615 ":" + padZeros(Math.abs(this.getTimezoneOffset() % 60), 2)); 3616 break; 3617 case "g": 3618 case "gg": 3619 if (dtf.eras) { 3620 ret.push(dtf.eras[getEra(this, eras) + 1]); 3621 } 3622 break; 3623 case "/": 3624 ret.push(dtf.DateSeparator); 3625 break; 3626 } 3627 } 3628 return ret.join(''); 3629} 3630String.localeFormat = function String$localeFormat(format, args) { 3631 /// <summary locid="M:J#String.localeFormat">Replaces the format items in a specified String with the text equivalents of the values of corresponding object instances. The current culture will be used to format dates and numbers.</summary> 3632 /// <param name="format" type="String">A format string.</param> 3633 /// <param name="args" parameterArray="true" mayBeNull="true">The objects to format.</param> 3634 /// <returns type="String">A copy of format in which the format items have been replaced by the string equivalent of the corresponding instances of object arguments.</returns> 3635 var e = Function._validateParams(arguments, [ 3636 {name: "format", type: String}, 3637 {name: "args", mayBeNull: true, parameterArray: true} 3638 ]); 3639 if (e) throw e; 3640 return String._toFormattedString(true, arguments); 3641} 3642var formattingPatterns = { 3643 P: ["Percent", ["-n %", "-n%", "-%n"], ["n %", "n%", "%n" ], 100], 3644 N: ["Number",["(n)","-n","- n","n-","n -"], null, 1], 3645 C: ["Currency",["($n)","-$n","$-n","$n-","(n$)","-n$","n-$","n$-","-n $","-$ n","n $-","$ n-","$ -n","n- $","($ n)","(n $)"],["$n","n$","$ n","n $"], 1] 3646}; 3647 3648Sys._toFormattedString = function _toFormattedString(format, cultureInfo) { 3649 if (!format || !format.length || (format === 'i')) { 3650 return (cultureInfo && cultureInfo.name.length) ?
3651 this.toLocaleString() : 3652 this.toString(); 3653 } 3654 3655 function zeroPad(str, count, left) { 3656 for (var l=str.length; l < count; l++) { 3657 str = (left ? ('0' + str) : (str + '0')); 3658 } 3659 return str; 3660 } 3661 3662 function expandNumber(number, precision, groupSizes, sep, decimalChar) { 3663 var curSize = groupSizes[0]; 3664 var curGroupIndex = 1; 3665 3666 3667 3668 var factor = Math.pow(10, precision); 3669 var rounded = (Math.round(number * factor) / factor); 3670 if (!isFinite(rounded)) { 3671 rounded = number; 3672 } 3673 number = rounded; 3674 3675 var numberString = number+''; 3676 var right = ""; 3677 var exponent; 3678 3679 3680 var split = numberString.split(/e/i); 3681 numberString = split[0]; 3682 exponent = (split.length > 1 ? parseInt(split[1]) : 0); 3683 split = numberString.split('.'); 3684 numberString = split[0]; 3685 right = split.length > 1 ? split[1] : ""; 3686 3687 var l; 3688 if (exponent > 0) { 3689 right = zeroPad(right, exponent, false); 3690 numberString += right.slice(0, exponent); 3691 right = right.substr(exponent); 3692 } 3693 else if (exponent < 0) { 3694 exponent = -exponent; 3695 numberString = zeroPad(numberString, exponent+1, true); 3696 right = numberString.slice(-exponent, numberString.length) + right; 3697 numberString = numberString.slice(0, -exponent); 3698 } 3699 3700 if (precision > 0) { 3701 right = decimalChar + 3702 ((right.length > precision) ? right.slice(0, precision) : zeroPad(right, precision, false)); 3703 } 3704 else { 3705 right = ""; 3706 } 3707 3708 var stringIndex = numberString.length-1; 3709 var ret = ""; 3710 while (stringIndex >= 0) { 3711 if (curSize === 0 || curSize > stringIndex) { 3712 return numberString.slice(0, stringIndex + 1) + 3713 (ret.length ? (sep + ret + right) : right); 3714 } 3715 3716 ret = numberString.slice(stringIndex - curSize + 1, stringIndex + 1) + 3717 (ret.length ? (sep+ret) : ""); 3718 3719 stringIndex -= curSize; 3720 3721 if (curGroupIndex < groupSizes.length) { 3722 curSize = groupSizes[curGroupIndex]; 3723 curGroupIndex++; 3724 } 3725 } 3726 return numberString.slice(0, stringIndex + 1) + sep + ret + right; 3727 } 3728 var nf = cultureInfo.numberFormat; 3729 3730 var number = Math.abs(this); 3731 3732 format = format || "D"; 3733 3734 var precision = -1; 3735 if (format.length > 1) precision = parseInt(format.slice(1), 10); 3736 3737 var pattern, 3738 current = format.charAt(0).toUpperCase(); 3739 switch (current) { 3740 case "D": 3741 pattern = 'n'; 3742 3743 if (precision !== -1) { 3744 number = zeroPad(""+number, precision, true); 3745 } 3746 3747 if (this < 0) number = -number; 3748 break; 3749 case "C": 3750 case "N": 3751 case "P": 3752 current = formattingPatterns[current]; 3753 var name = current[0]; 3754 pattern = (this < 0) ? current[1][nf[name+"NegativePattern"]] : (current[2] ? current[2][nf[name+"PositivePattern"]] : "n"); 3755 if (precision === -1) precision = nf[name+"DecimalDigits"]; 3756 number = expandNumber(Math.abs(this)*current[3], precision, nf[name+"GroupSizes"], nf[name+"GroupSeparator"], nf[name+"DecimalSeparator"]); 3757 break; 3758 default: 3759 throw Error.format(Sys.Res.formatBadFormatSpecifier); 3760 } 3761 3762 var regex = /n|\$|-|%/g; 3763 3764 var ret = ""; 3765 3766 for (;;) { 3767 3768 var index = regex.lastIndex; 3769 3770 var ar = regex.exec(pattern); 3771 3772 ret += pattern.slice(index, ar ? ar.index : pattern.length); 3773 3774 if (!ar) 3775 break; 3776 3777 switch (ar[0]) { 3778 case "n": 3779 ret += number; 3780 break; 3781 case "$": 3782 ret += nf.CurrencySymbol; 3783 break; 3784 case "-": 3785 if (/[1-9]/.test(number)) { 3786 ret += nf.NegativeSign; 3787 } 3788 break; 3789 case "%": 3790 ret += nf.PercentSymbol; 3791 break; 3792 } 3793 } 3794 3795 return ret; 3796} 3797 3798$type = Number; 3799$type.parseLocale = function Number$parseLocale(value) { 3800 /// <summary locid="M:J#Number.parseLocale">Creates a number from its locale string representation.</summary> 3801 /// <param name="value" type="String">A string that can parse to a number.</param> 3802 /// <returns type="Number"></returns> 3803 var e = Function._validateParams(arguments, [ 3804 {name: "value", type: String} 3805 ], false); 3806 if (e) throw e; 3807 return Number._parse(value, Sys.CultureInfo.CurrentCulture); 3808} 3809$type.parseInvariant = function Number$parseInvariant(value) { 3810 /// <summary locid="M:J#Number.parseInvariant">Creates a number from its string representation.</summary> 3811 /// <param name="value" type="String">A string that can parse to a number.</param> 3812 /// <returns type="Number"></returns> 3813 var e = Function._validateParams(arguments, [ 3814 {name: "value", type: String} 3815 ], false); 3816 if (e) throw e; 3817 return Number._parse(value, Sys.CultureInfo.InvariantCulture); 3818} 3819$type._parse = function Number$_parse(value, cultureInfo) { 3820 value = value.trim(); 3821 3822 if (value.match(/^[+-]?infinity$/i)) { 3823 return parseFloat(value); 3824 } 3825 if (value.match(/^0x[a-f0-9]+$/i)) { 3826 return parseInt(value); 3827 } 3828 3829 var numFormat = cultureInfo.numberFormat; 3830 var signInfo = Number._parseNumberNegativePattern(value, numFormat, numFormat.NumberNegativePattern); 3831 var sign = signInfo[0]; 3832 var num = signInfo[1]; 3833 3834 if ((sign === '') && (numFormat.NumberNegativePattern !== 1)) { 3835 signInfo = Number._parseNumberNegativePattern(value, numFormat, 1); 3836 sign = signInfo[0]; 3837 num = signInfo[1]; 3838 } 3839 if (sign === '') sign = '+'; 3840 3841 var exponent; 3842 var intAndFraction; 3843 var exponentPos = num.indexOf('e');
3844 if (exponentPos < 0) exponentPos = num.indexOf('E'); 3845 if (exponentPos < 0) { 3846 intAndFraction = num; 3847 exponent = null; 3848 } 3849 else { 3850 intAndFraction = num.substr(0, exponentPos); 3851 exponent = num.substr(exponentPos + 1); 3852 } 3853 3854 var integer; 3855 var fraction; 3856 var decSep = numFormat.NumberDecimalSeparator 3857 var decimalPos = intAndFraction.indexOf(decSep); 3858 if (decimalPos < 0) { 3859 integer = intAndFraction; 3860 fraction = null; 3861 } 3862 else { 3863 integer = intAndFraction.substr(0, decimalPos); 3864 fraction = intAndFraction.substr(decimalPos + decSep.length); 3865 } 3866 3867 var numGroupSep = numFormat.NumberGroupSeparator 3868 integer = integer.split(numGroupSep).join(''); 3869 var altNumGroupSeparator = numGroupSep.replace(/\u00A0/g, " "); 3870 if (numGroupSep !== altNumGroupSeparator) { 3871 integer = integer.split(altNumGroupSeparator).join(''); 3872 } 3873 3874 var p = sign + integer; 3875 if (fraction !== null) { 3876 p += '.' + fraction; 3877 } 3878 if (exponent !== null) { 3879 var expSignInfo = Number._parseNumberNegativePattern(exponent, numFormat, 1); 3880 if (expSignInfo[0] === '') { 3881 expSignInfo[0] = '+'; 3882 } 3883 p += 'e' + expSignInfo[0] + expSignInfo[1]; 3884 } 3885 3886 if (p.match(/^[+-]?\d*\.?\d*(e[+-]?\d+)?$/)) { 3887 return parseFloat(p); 3888 } 3889 return Number.NaN; 3890} 3891$type._parseNumberNegativePattern = function Number$_parseNumberNegativePattern(value, numFormat, numberNegativePattern) { 3892 var neg = numFormat.NegativeSign; 3893 var pos = numFormat.PositiveSign; 3894 switch (numberNegativePattern) { 3895 case 4: 3896 neg = ' ' + neg; 3897 pos = ' ' + pos; 3898 case 3: 3899 if (value.endsWith(neg)) { 3900 return ['-', value.substr(0, value.length - neg.length)]; 3901 } 3902 else if (value.endsWith(pos)) { 3903 return ['+', value.substr(0, value.length - pos.length)]; 3904 } 3905 break; 3906 case 2: 3907 neg += ' '; 3908 pos += ' '; 3909 case 1: 3910 if (value.startsWith(neg)) { 3911 return ['-', value.substr(neg.length)]; 3912 } 3913 else if (value.startsWith(pos)) { 3914 return ['+', value.substr(pos.length)]; 3915 } 3916 break; 3917 case 0: 3918 if (value.startsWith('(') && value.endsWith(')')) { 3919 return ['-', value.substr(1, value.length - 2)]; 3920 } 3921 break; 3922 } 3923 return ['', value]; 3924} 3925 3926$prototype = $type.prototype; 3927$prototype.format = function Number$format(format) { 3928 /// <summary locid="M:J#Number.format">Format a number using the invariant culture.</summary> 3929 /// <param name="format" type="String">Format string.</param> 3930 /// <returns type="String">Formatted number.</returns> 3931 var e = Function._validateParams(arguments, [ 3932 {name: "format", type: String} 3933 ]); 3934 if (e) throw e; 3935 return Sys._toFormattedString.call(this, format, Sys.CultureInfo.InvariantCulture); 3936} 3937$prototype.localeFormat = function Number$localeFormat(format) { 3938 /// <summary locid="M:J#Number.localeFormat">Format a number using the current culture.</summary> 3939 /// <param name="format" type="String">Format string.</param> 3940 /// <returns type="String">Formatted number.</returns> 3941 var e = Function._validateParams(arguments, [ 3942 {name: "format", type: String} 3943 ]); 3944 if (e) throw e; 3945 return Sys._toFormattedString.call(this, format, Sys.CultureInfo.CurrentCulture); 3946} 3947function toUpper(value) { 3948 return value.split("\u00A0").join(' ').toUpperCase(); 3949} 3950function toUpperArray(arr) { 3951 var result = []; 3952 foreach(arr, function(value, i) { 3953 result[i] = toUpper(value); 3954 }); 3955 return result; 3956} 3957 3958function clone(obj) { 3959 var objNew = {}; 3960 forIn(obj, function(value, field) { 3961 objNew[field] = (value instanceof Array) ? (value.length === 1 ? [value] : Array.apply(null, value)) : 3962 ((typeof(value) === "object") ? clone(value) : value); 3963 });
3964 return objNew; 3965} 3966 3967$type = Sys.CultureInfo = function CultureInfo(name, numberFormat, dateTimeFormat) { 3968 /// <summary locid="M:J#Sys.CultureInfo.#ctor"></summary> 3969 /// <param name="name" type="String">CultureInfo name.</param> 3970 /// <param name="numberFormat" type="Object">CultureInfo number format information.</param> 3971 /// <param name="dateTimeFormat" type="Object">CultureInfo date time format information.</param> 3972 var e = Function._validateParams(arguments, [ 3973 {name: "name", type: String}, 3974 {name: "numberFormat", type: Object}, 3975 {name: "dateTimeFormat", type: Object} 3976 ]); 3977 if (e) throw e; 3978 this.name = name; 3979 this.numberFormat = numberFormat; 3980 this.dateTimeFormat = dateTimeFormat; 3981} 3982$type.prototype = { 3983 _getDateTimeFormats: function CultureInfo$_getDateTimeFormats() { 3984 var formats = this._dateTimeFormats; 3985 if (!formats) { 3986 var dtf = this.dateTimeFormat; 3987 this._dateTimeFormats = formats = 3988 [ dtf["MonthDayPattern"], 3989 dtf["YearMonthPattern"], 3990 dtf["ShortDatePattern"], 3991 dtf["ShortTimePattern"], 3992 dtf["LongDatePattern"], 3993 dtf["LongTimePattern"], 3994 dtf["FullDateTimePattern"], 3995 dtf["RFC1123Pattern"], 3996 dtf["SortableDateTimePattern"], 3997 dtf["UniversalSortableDateTimePattern"] ]; 3998 } 3999 return formats; 4000 }, 4001 _getMonthIndex: function CultureInfo$_getMonthIndex(value, abbr) { 4002 var name = abbr ? "_upperAbbrMonths" : "_upperMonths", 4003 genitiveName = name + "Genitive", 4004 upperMonths = this[name]; 4005 if (!upperMonths) { 4006 var prefix = (abbr ? "Abbreviated" : ""); 4007 this[name] = toUpperArray(this.dateTimeFormat[prefix+"MonthNames"]); 4008 this[genitiveName] = toUpperArray(this.dateTimeFormat[prefix+"MonthGenitiveNames"]); 4009 } 4010 value = toUpper(value); 4011 var i = indexOf(this[name], value); 4012 if (i < 0) { 4013 i = indexOf(this[genitiveName], value); 4014 } 4015 return i; 4016 }, 4017 _getDayIndex: function CultureInfo$_getDayIndex(value, abbr) { 4018 var name = abbr ? "_upperAbbrDays" : "_upperDays", 4019 upperDays = this[name]; 4020 if (!upperDays) { 4021 this[name] = toUpperArray(this.dateTimeFormat[(abbr ? "Abbreviated" : "")+"DayNames"]); 4022 } 4023 return indexOf(this[name], toUpper(value)); 4024 } 4025} 4026$type.registerClass('Sys.CultureInfo'); 4027 4028$type._parse = function(value) { 4029 var dtf = value.dateTimeFormat; 4030 if (dtf && !dtf.eras) { 4031 dtf.eras = value.eras; 4032 } 4033 return new Sys.CultureInfo(value.name, value.numberFormat, dtf); 4034} 4035$type._setup = function() { 4036 var cultureInfo = window.__cultureInfo, 4037 monthNames = ["January","February","March","April","May","June","July","August","September","October","November","December",""], 4038 shortMonthNames = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec",""], 4039 invariant = {"name":"","numberFormat":{"CurrencyDecimalDigits":2,"CurrencyDecimalSeparator":".","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},"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/d
4039d/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":shortMonthNames,"MonthNames":monthNames,"NativeCalendarName":"Gregorian Calendar","AbbreviatedMonthGenitiveNames":Array.clone(shortMonthNames),"MonthGenitiveNames":Array.clone(monthNames)},"eras":[1,"A.D.",null,0]}; 4040 this.InvariantCulture = this._parse(invariant); 4041 switch(typeof(cultureInfo)) { 4042 case "string": 4043 cultureInfo = window.eval("(" + cultureInfo + ")"); 4044 case "object": 4045 this.CurrentCulture = this._parse(cultureInfo); 4046 delete __cultureInfo; 4047 break; 4048 default: 4049 cultureInfo = clone(invariant); 4050 cultureInfo.name = "en-US"; 4051 cultureInfo.numberFormat.CurrencySymbol = "$"; 4052 var dtf = cultureInfo.dateTimeFormat; 4053 dtf.FullDatePattern = "dddd, MMMM dd, yyyy h:mm:ss tt"; 4054 dtf.LongDatePattern = "dddd, MMMM dd, yyyy"; 4055 dtf.LongTimePattern = "h:mm:ss tt"; 4056 dtf.ShortDatePattern = "M/d/yyyy"; 4057 dtf.ShortTimePattern = "h:mm tt"; 4058 dtf.YearMonthPattern = "MMMM, yyyy"; 4059 this.CurrentCulture = this._parse(cultureInfo); 4060 break; 4061 } 4062} 4063 4064$type._setup(); 4065 4066 4067 4068 4069 4070Type.registerNamespace('Sys.Serialization'); 4071 4072$type = Sys.Serialization.JavaScriptSerializer = function Serialization$JavaScriptSerializer() { 4073 /// <summary locid="M:J#Sys.Serialization.JavaScriptSerializer.#ctor">Provides serialization from JavaScript object to JavaScript object notation.</summary> 4074 if (arguments.length !== 0) throw Error.parameterCount(); 4075} 4076$type.registerClass('Sys.Serialization.JavaScriptSerializer'); 4077 4078$type._esc = { 4079 charsRegExs: { '"': /\"/g, '\\': /\\/g }, /*"*/ 4080 chars: ['\\', '"'], 4081 dateRegEx: /(^|[^\\])\"\\\/Date\((-?[0-9]+)(?:[a-zA-Z]|(?:\+|-)[0-9]{4})?\)\\\/\"/g, /* " */ 4082 escapeChars: {'\\':'\\\\', '"':'\\"', "\b":"\\b", "\t":"\\t", "\n":"\\n", "\f":"\\f", "\r":"\\r"}, 4083 escapeRegExG: /[\"\\\x00-\x1F]/g, 4084 escapeRegEx: /[\"\\\x00-\x1F]/i, 4085 jsonRegEx: /[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/g, 4086 jsonStringRegEx: /\"(\\.|[^\"\\])*\"/g /*"*/ 4087}; 4088$type._init = function() { 4089 var esc = this._esc, 4090 toEsc = esc.chars, 4091 toEscRE = esc.charsRegExs, 4092 escChars = esc.escapeChars; 4093 for (var i = 0; i < 32; i++) { 4094 var c = String.fromCharCode(i); 4095 toEsc[i+2] = c; 4096 toEscRE[c] = new RegExp(c, 'g'); 4097 escChars[c] = escChars[c] || ("\\u" + ("000" + i.toString(16)).slice(-4)); 4098 } 4099 this._load = true; 4100} 4101$type._serializeNumberWithBuilder = function(object, stringBuilder) { 4102 if (!isFinite(object)) { 4103 throw Error.invalidOperation(Sys.Res.cannotSerializeNonFiniteNumbers); 4104 } 4105 stringBuilder.append(String(object)); 4106} 4107$type._serializeStringWithBuilder = function(string, stringBuilder) { 4108 stringBuilder.append('"'); 4109 var esc = this._esc; 4110 if (esc.escapeRegEx.test(string)) { 4111 if (!this._load) { 4112 this._init(); 4113 } 4114 if (string.length < 128) { 4115 string = string.replace(esc.escapeRegExG, 4116 function(x) { return esc.escapeChars[x]; }); 4117 } 4118 else { 4119 for (var i = 0; i < 34; i++) { 4120 var c = esc.chars[i]; 4121 if (string.indexOf(c) !== -1) { 4122 var escChar = esc.escapeChars[c]; 4123 string = (isBrowser("Opera") || isBrowser("Firefox")) ? 4124 string.split(c).join(escChar) : 4125 string.replace(esc.charsRegExs[c], escChar); 4126 } 4127 } 4128 } 4129 } 4130 stringBuilder.append(string).append('"'); 4131} 4132$type._serializeWithBuilder = function(object, stringBuilder, sort, prevObjects) { 4133 var i; 4134 switch (typeof object) { 4135 case 'object': 4136 if (object) { 4137 if (prevObjects){ 4138 if (Sys._indexOf(prevObjects, object) !== -1) {
4139 throw Error.invalidOperation(Sys.Res.cannotSerializeObjectWithCycle); 4140 } 4141 } 4142 else { 4143 prevObjects = []; 4144 } 4145 try { 4146 prevObjects.push(object); 4147 4148 if (Number.isInstanceOfType(object)) { 4149 this._serializeNumberWithBuilder(object, stringBuilder); 4150 } 4151 else if (Boolean.isInstanceOfType(object)) { 4152 stringBuilder.append(object); 4153 } 4154 else if (String.isInstanceOfType(object)) { 4155 this._serializeStringWithBuilder(object, stringBuilder); 4156 } 4157 4158 else if (object instanceof Array) { 4159 stringBuilder.append('['); 4160 4161 for (i = 0; i < object.length; ++i) { 4162 if (i) { 4163 stringBuilder.append(','); 4164 } 4165 this._serializeWithBuilder(object[i], stringBuilder, false, prevObjects); 4166 } 4167 stringBuilder.append(']'); 4168 } 4169 else { 4170 if (Date.isInstanceOfType(object)) { 4171 stringBuilder.append('"\\/Date('). 4172 append(object.getTime()). 4173 append(')\\/"'); 4174 break; 4175 } 4176 4177 var properties = [], 4178 propertyCount = 0; 4179 for (var name in object) { 4180 if (name.charAt(0) !== '$') { 4181 if (name === '__type' && propertyCount) { 4182 properties[propertyCount++] = properties[0]; 4183 properties[0] = name; 4184 } 4185 else { 4186 properties[propertyCount++] = name; 4187 } 4188 } 4189 } 4190 if (sort) properties.sort(); 4191 4192 stringBuilder.append('{'); 4193 4194 var needComma; 4195 for (i=0; i < propertyCount; i++) { 4196 var prop = properties[i], value = object[prop], 4197 type = typeof(value); 4198 if (type !== 'undefined' && type !== 'function') { 4199 if (needComma) { 4200 stringBuilder.append(','); 4201 } 4202 this._serializeWithBuilder(prop, stringBuilder, sort, prevObjects); 4203 stringBuilder.append(':'); 4204 this._serializeWithBuilder(value, stringBuilder, sort, prevObjects); 4205 needComma = true; 4206 } 4207 } 4208 stringBuilder.append('}'); 4209 } 4210 } 4211 finally { 4212 Array.removeAt(prevObjects, prevObjects.length - 1); 4213 } 4214 } 4215 else { 4216 stringBuilder.append('null'); 4217 } 4218 break; 4219 4220 case 'number': 4221 this._serializeNumberWithBuilder(object, stringBuilder); 4222 break; 4223 4224 case 'string': 4225 this._serializeStringWithBuilder(object, stringBuilder); 4226 break; 4227 4228 case 'boolean': 4229 stringBuilder.append(object); 4230 break; 4231 4232 default: 4233 stringBuilder.append('null'); 4234 break; 4235 } 4236} 4237 4238$type.serialize = function JavaScriptSerializer$serialize(object) { 4239 /// <summary locid="M:J#Sys.Serialization.JavaScriptSerializer.serialize">Generates a JSON string from an object.</summary> 4240 /// <param name="object" mayBeNull="true">The object to serialize.</param> 4241 /// <returns type="String">The JSON string representation of the object.</returns> 4242 var e = Function._validateParams(arguments, [ 4243 {name: "object", mayBeNull: true} 4244 ]); 4245 if (e) throw e; 4246 var stringBuilder = new Sys.StringBuilder(); 4247 Sys.Serialization.JavaScriptSerializer._serializeWithBuilder(object, stringBuilder, false); 4248 return stringBuilder.toString(); 4249} 4250 4251$type.deserialize = function JavaScriptSerializer$deserialize(data, secure) { 4252 /// <summary locid="M:J#Sys.Serialization.JavaScriptSerializer.deserialize">Deserializes a JSON string.</summary> 4253 /// <param name="data" type="String">The JSON string to eval.</param> 4254 /// <param name="secure" type="Boolean" optional="true" mayBeNull="true">True if the method should perform JSON conformance checks before evaluating. False by default.</param> 4255 /// <returns>The results of eval applied to data.</returns> 4256 var e = Function._validateParams(arguments, [ 4257 {name: "data", type: String}, 4258 {name: "secure", type: Boolean, mayBeNull: true, optional: true} 4259 ]); 4260 if (e) throw e; 4261 if (!data.length) throw Error.argument('data', Sys.Res.cannotDeserializeEmptyString); 4262 var er, esc = Sys.Serialization.JavaScriptSerializer._esc; 4263 try { 4264 var exp = data.replace(esc.dateRegEx, "$1new Date($2)"); 4265 4266 if (secure && esc.jsonRegEx.test(exp.replace(esc.jsonStringRegEx, ''))) throw null; 4267 4268 return window.eval('(' + exp + ')'); 4269 } 4270 catch (er) { 4271 throw Error.argument('data', Sys.Res.cannotDeserializeInvalidJson); 4272 } 4273} 4274 4275 4276Type.registerNamespace('Sys.UI'); 4277 4278$type = Sys.EventHandlerList = function EventHandlerList() { 4279 /// <summary locid="M:J#Sys.EventHandlerList.#ctor">The EventHandlerList class contains a dictionary of multicast events.</summary> 4280 if (arguments.length !== 0) throw Error.parameterCount(); 4281 this._list = {}; 4282} 4283 4284$type.prototype = { 4285 _addHandler: function EventHandlerList$_addHandler(id, handler) { 4286 Array.add(this._getEvent(id, true), handler); 4287 }, 4288 addHandler: function EventHandlerList$addHandler(id, handler) { 4289 /// <summary locid="M:J#Sys.EventHandlerList.addHandler">The addHandler method adds a handler to the event identified by id.</summary> 4290 /// <param name="id" type="String">The identifier for the event.</param> 4291 /// <param name="handler" type="Function">The handler to add to the event.</param> 4292 var e = Function._validateParams(arguments, [ 4293 {name: "id", type: String}, 4294 {name: "handler", type: Function} 4295 ]); 4296 if (e) throw e; 4297 this._addHandler(id, handler); 4298 }, 4299 _removeHandler: function EventHandlerList$_removeHandler(id, handler) { 4300 var evt = this._getEvent(id); 4301 if (!evt) return; 4302 Array.remove(evt, handler); 4303 }, 4304 _removeHandlers: function EventHandlerList$_removeHandlers(id) { 4305 if (!id) { 4306 this._list = {}; 4307 } 4308 else { 4309 var evt = this._getEvent(id); 4310 if (!evt) return; 4311 evt.length = 0; 4312 } 4313 }, 4314 removeHandler: function EventHandlerList$removeHandler(id, handler) { 4315 /// <summary locid="M:J#Sys.EventHandlerList.removeHandler">The removeHandler method removes a handler to the event identified by id.</summary> 4316 /// <param name="id" type="String">The identifier for the event.</param> 4317 /// <param name="handler" type="Function">The handler to remove from the event.</param> 4318 var e = Function._validateParams(arguments, [ 4319 {name: "id", type: String}, 4320 {name: "handler", type: Function} 4321 ]); 4322 if (e) throw e; 4323 this._removeHandler(id, handler); 4324 }, 4325 getHandler: function EventHandlerList$getHandler(id) { 4326 /// <summary locid="M:J#Sys.EventHandlerList.getHandler">The getHandler method returns a single function that will call all handlers sequentially for the specified event.</summary> 4327 /// <param name="id" type="String">The identifier for the event.</param> 4328 /// <returns type="Function">A function that will call each handler sequentially.</returns> 4329 var e = Function._validateParams(arguments, [ 4330 {name: "id", type: String} 4331 ]); 4332 if (e) throw e; 4333 var evt = this._getEvent(id); 4334 if (!evt || !evt.length) return null; 4335 evt = Array.clone(evt); 4336 return function(source, args) { 4337 for (var i = 0, l = evt.length; i < l; i++) { 4338 evt[i](source, args); 4339 } 4340 }; 4341 }, 4342 _getEvent: function EventHandlerList$_getEvent(id, create) { 4343 var e = this._list[id]; 4344 if (!e) { 4345 if (!create) return null; 4346 this._list[id] = e = []; 4347 } 4348 return e; 4349 } 4350} 4351$type.registerClass('Sys.EventHandlerList'); 4352$type = Sys.CommandEventArgs = function CommandEventArgs(commandName, commandArgument, commandSource, commandEvent) { 4353 /// <summary locid="M:J#Sys.CommandEventArgs.#ctor"></summary> 4354 /// <param name="commandName" type="String">The command name.</param> 4355 /// <param name="commandArgument" mayBeNull="true">The command arguments.</param> 4356 /// <param name="commandSource" mayBeNull="true">The command source.</param> 4357 /// <param name="commandEvent" type="Sys.UI.DomEvent" mayBeNull="true" optional="true">The DOM event that caused the command, if any.</param> 4358 var e = Function._validateParams(arguments, [ 4359 {name: "commandName", type: String}, 4360 {name: "commandArgument", mayBeNull: true}, 4361 {name: "commandSource", mayBeNull: true}, 4362 {name: "commandEvent", type: Sys.UI.DomEvent, mayBeNull: true, optional: true } 4363 ]); 4364 if (e) throw e; 4365 Sys.CommandEventArgs.initializeBase(this); 4366 this._commandName = commandName; 4367 this._commandArgument = commandArgument; 4368 this._commandSource = commandSource; 4369 this._commandEvent = commandEvent; 4370} 4371$type.prototype = { 4372 get_commandName: function CommandEventArgs$get_commandName() { 4373 /// <value type="String" locid="P:J#Sys.CommandEventArgs.commandName">The command name.</value> 4374 if (arguments.length !== 0) throw Error.parameterCount(); 4375 return this._commandName || null; 4376 }, 4377 get_commandArgument: function CommandEventArgs$get_commandArgument() { 4378 /// <value mayBeNull="true" locid="P:J#Sys.CommandEventArgs.commandArgument">The command arguments.</value> 4379 if (arguments.length !== 0) throw Error.parameterCount(); 4380 return this._commandArgument; 4381 }, 4382 get_commandSource: function CommandEventArgs$get_commandSource() { 4383 /// <value mayBeNull="true" locid="P:J#Sys.CommandEventArgs.commandSource">The command source.</value> 4384 if (arguments.length !== 0) throw Error.parameterCount(); 4385 return this._commandSource || null; 4386 }, 4387 get_commandEvent: function CommandEventArgs$get_commandEvent() { 4388 /// <value mayBeNull="true" type="Sys.UI.DomEvent" locid="P:J#Sys.CommandEventArgs.commandEvent">The DOM event that caused the command, if any.</value> 4389 if (arguments.length !== 0) throw Error.parameterCount(); 4390 return this._commandEvent || null; 4391 } 4392} 4393$type.registerClass("Sys.CommandEventArgs", Sys.CancelEventArgs); 4394$type = Sys.INotifyPropertyChange = function INotifyPropertyChange() { 4395 /// <summary locid="M:J#Sys.INotifyPropertyChange.#ctor">Implement this interface to become a provider of property change notifications.</summary> 4396 if (arguments.length !== 0) throw Error.parameterCount(); 4397 throw Error.notImplemented(); 4398} 4399$type.prototype = { 4400 add_propertyChanged: function INotifyPropertyChange$add_propertyChanged(handler) { 4401 /// <summary locid="E:J#Sys.INotifyPropertyChange.propertyChanged"></summary> 4402 var e = Function._validateParams(arguments, [{name: "handler", type: Function}]); 4403 if (e) throw e; 4404 throw Error.notImplemented(); 4405 }, 4406 remove_propertyChanged: function INotifyPropertyChange$remove_propertyChanged(handler) { 4407 var e = Function._validateParams(arguments, [{name: "handler", type: Function}]); 4408 if (e) throw e; 4409 throw Error.notImplemented(); 4410 } 4411} 4412$type.registerInterface('Sys.INotifyPropertyChange'); 4413$type = Sys.PropertyChangedEventArgs = function PropertyChangedEventArgs(propertyName) { 4414 /// <summary locid="M:J#Sys.PropertyChangedEventArgs.#ctor">Describes property changes.</summary> 4415 /// <param name="propertyName" type="String">The name of the property that changed.</param> 4416 var e = Function._validateParams(arguments, [ 4417 {name: "propertyName", type: String} 4418 ]); 4419 if (e) throw e; 4420 Sys.PropertyChangedEventArgs.initializeBase(this); 4421 this._propertyName = propertyName; 4422} 4423 $type.prototype = { 4424 get_propertyName: function PropertyChangedEventArgs$get_propertyName() { 4425 /// <value type="String" locid="P:J#Sys.PropertyChangedEventArgs.propertyName">The name of the property that changed.</value> 4426 if (arguments.length !== 0) throw Error.parameterCount(); 4427 return this._propertyName; 4428 } 4429} 4430$type.registerClass('Sys.PropertyChangedEventArgs', Sys.EventArgs); 4431$type = Sys.INotifyDisposing = function INotifyDisposing() { 4432 /// <summary locid="M:J#Sys.INotifyDisposing.#ctor">Implement this interface if the class exposes an event to notify when it's disposing.</summary> 4433 if (arguments.length !== 0) throw Error.parameterCount(); 4434 throw Error.notImplemented(); 4435} 4436$type.prototype = { 4437 add_disposing: function INotifyDisposing$add_disposing(handler) { 4438 /// <summary locid="E:J#Sys.INotifyDisposing.disposing"></summary> 4439 var e = Function._validateParams(arguments, [{name: "handler", type: Function}]); 4440 if (e) throw e; 4441 throw Error.notImplemented(); 4442 }, 4443 remove_disposing: function INotifyDisposing$remove_disposing(handler) { 4444 var e = Function._validateParams(arguments, [{name: "handler", type: Function}]); 4445 if (e) throw e; 4446 throw Error.notImplemented(); 4447 } 4448} 4449$type.registerInterface("Sys.INotifyDisposing"); 4450$type = Sys.Component = function Component() { 4451 /// <summary locid="M:J#Sys.Component.#ctor">Base class for Control, Behavior and any object that wants its lifetime to be managed.</summary> 4452 if (arguments.length !== 0) throw Error.parameterCount(); 4453 if (Sys.Application) Sys.Application.registerDisposableObject(this); 4454} 4455$type.prototype = { 4456 _idSet: false, 4457 get_events: function Component$get_events() { 4458 /// <value type="Sys.EventHandlerList" locid="P:J#Sys.Component.events">The collection of event handlers for this behavior. This property should only be used by derived behaviors and should not be publicly called by other code.</value> 4459 if (arguments.length !== 0) throw Error.parameterCount(); 4460 return Sys.Observer._getContext(this, true).events; 4461 }, 4462 get_id: function Component$get_id() { 4463 /// <value type="String" locid="P:J#Sys.Component.id"></value> 4464 if (arguments.length !== 0) throw Error.parameterCount(); 4465 return this._id || null; 4466 }, 4467 set_id: function Component$set_id(value) { 4468 var e = Function._validateParams(arguments, [{name: "value", type: String}]); 4469 if (e) throw e;
4470 if (this._idSet) throw Error.invalidOperation(Sys.Res.componentCantSetIdTwice); 4471 this._idSet = true; 4472 var oldId = this.get_id(); 4473 if (oldId && Sys.Application.findComponent(oldId)) throw Error.invalidOperation(Sys.Res.componentCantSetIdAfterAddedToApp); 4474 this._id = value; 4475 }, 4476 get_isInitialized: function Component$get_isInitialized() { 4477 /// <value type="Boolean" locid="P:J#Sys.Component.isInitialized"></value> 4478 if (arguments.length !== 0) throw Error.parameterCount(); 4479 return !!this._initialized; 4480 }, 4481 get_isUpdating: function Component$get_isUpdating() { 4482 /// <value type="Boolean" locid="P:J#Sys.Component.isUpdating"></value> 4483 if (arguments.length !== 0) throw Error.parameterCount(); 4484 return !!this._updating; 4485 }, 4486 add_disposing: function Component$add_disposing(handler) { 4487 /// <summary locid="E:J#Sys.Component.disposing"></summary> 4488 var e = Function._validateParams(arguments, [{name: "handler", type: Function}]); 4489 if (e) throw e; 4490 this._addHandler("disposing", handler); 4491 }, 4492 remove_disposing: function Component$remove_disposing(handler) { 4493 var e = Function._validateParams(arguments, [{name: "handler", type: Function}]); 4494 if (e) throw e; 4495 this._removeHandler("disposing", handler); 4496 }, 4497 add_propertyChanged: function Component$add_propertyChanged(handler) { 4498 /// <summary locid="E:J#Sys.Component.propertyChanged"></summary> 4499 var e = Function._validateParams(arguments, [{name: "handler", type: Function}]); 4500 if (e) throw e; 4501 this._addHandler("propertyChanged", handler); 4502 }, 4503 remove_propertyChanged: function Component$remove_propertyChanged(handler) { 4504 var e = Function._validateParams(arguments, [{name: "handler", type: Function}]); 4505 if (e) throw e; 4506 this._removeHandler("propertyChanged", handler); 4507 }, 4508 _addHandler: function Component$_addHandler(eventName, handler) { 4509 Sys.Observer.addEventHandler(this, eventName, handler); 4510 }, 4511 _removeHandler: function Component$_removeHandler(eventName, handler) { 4512 Sys.Observer.removeEventHandler(this, eventName, handler); 4513 }, 4514 beginUpdate: function Component$beginUpdate() { 4515 this._updating = true; 4516 }, 4517 dispose: function Component$dispose() { 4518 Sys.Observer.raiseEvent(this, "disposing") 4519 Sys.Observer.clearEventHandlers(this); 4520 Sys.Application.unregisterDisposableObject(this); 4521 Sys.Application.removeComponent(this); 4522 }, 4523 endUpdate: function Component$endUpdate() { 4524 this._updating = false; 4525 if (!this._initialized) this.initialize(); 4526 this.updated(); 4527 }, 4528 initialize: function Component$initialize() { 4529 this._initialized = true; 4530 }, 4531 raisePropertyChanged: function Component$raisePropertyChanged(propertyName) { 4532 /// <summary locid="M:J#Sys.Component.raisePropertyChanged">Raises a change notification event.</summary> 4533 /// <param name="propertyName" type="String">The name of the property that changed.</param> 4534 var e = Function._validateParams(arguments, [ 4535 {name: "propertyName", type: String} 4536 ]); 4537 if (e) throw e; 4538 Sys.Observer.raisePropertyChanged(this, propertyName); 4539 }, 4540 updated: function Component$updated() { 4541 } 4542} 4543$type.registerClass('Sys.Component', null, Sys.IDisposable, Sys.INotifyPropertyChange, Sys.INotifyDisposing); 4544 4545$type._setProperties = function Component$_setProperties(target, properties) { 4546 /// <summary locid="M:J#Sys.Component._setProperties">Recursively sets properties on an object.</summary> 4547 /// <param name="target">The object on which to set the property values.</param> 4548 /// <param name="properties">A JSON object containing the property values.</param> 4549 var e = Function._validateParams(arguments, [ 4550 {name: "target"}, 4551 {name: "properties"} 4552 ]); 4553 if (e) throw e; 4554 var current; 4555 var targetType = Object.getType(target); 4556 var isObject = (targetType === Object) || (targetType === Sys.UI.DomElement); 4557 var isComponent = Sys.Component.isInstanceOfType(target) && !target.get_isUpdating(); 4558 if (isComponent) target.beginUpdate(); 4559 for (var name in properties) { 4560 var val = properties[name]; 4561 var getter = isObject ? null : target["get_" + name]; 4562 if (isObject || typeof(getter) !== 'function') { 4563 var targetVal = target[name]; 4564 if (!val || (typeof(val) !== 'object') || (isObject && !targetVal)) { 4565 target[name] = val; 4566 } 4567 else { 4568 this._setProperties(targetVal, val); 4569 } 4570 } 4571 else { 4572 var setter = target["set_" + name]; 4573 if (typeof(setter) === 'function') { 4574 setter.apply(target, [val]); 4575 } 4576 else if (val instanceof Array) { 4577 current = getter.apply(target); 4578 if (!(current instanceof Array)) throw new Error.invali
4578dOperation(String.format(Sys.Res.propertyNotAnArray, name)); 4579 for (var i = 0, j = current.length, l= val.length; i < l; i++, j++) { 4580 current[j] = val[i]; 4581 } 4582 } 4583 else if ((typeof(val) === 'object') && (Object.getType(val) === Object)) { 4584 current = getter.apply(target); 4585 if ((typeof(current) === 'undefined') || (current === null)) throw new Error.invalidOperation(String.format(Sys.Res.propertyNullOrUndefined, name)); 4586 this._setProperties(current, val); 4587 } 4588 else { 4589 throw new Error.invalidOperation(String.format(Sys.Res.propertyNotWritable, name)); 4590 } 4591 } 4592 } 4593 if (isComponent) target.endUpdate(); 4594} 4595 4596$type._setReferences = function Component$_setReferences(component, references) { 4597 var reference, refs = {}; 4598 forIn(references, function(id, name) { 4599 refs[name] = reference = $find(id); 4600 if (!reference) throw Error.invalidOperation(String.format(Sys.Res.referenceNotFound, id)); 4601 }); 4602 Sys._set(component, refs); 4603} 4604 4605$create = $type.create = function Component$create(type, properties, events, references, element) { 4606 /// <summary locid="M:J#Sys.Component.create">Instantiates a component of the specified type, attaches it to the specified element if it's a Control or Behavior, sets the properties as described by the specified JSON object, then calls initialize.</summary> 4607 /// <param name="type" type="Type">The type of the component to create.</param> 4608 /// <param name="properties" optional="true" mayBeNull="true">A JSON object that describes the properties and their values.</param> 4609 /// <param name="events" optional="true" mayBeNull="true">A JSON object that describes the events and their handlers.</param> 4610 /// <param name="references" optional="true" mayBeNull="true">A JSON object that describes the properties that are references to other components. The contents of this object c
4610onsists of name/id pairs. If in a two-pass creation, the setting of these properties will be delayed until the second pass.</param> 4611 /// <param name="element" domElement="true" optional="true" mayBeNull="true">The DOM element the component must be attached to.</param> 4612 /// <returns type="Object">The component instance.</returns> 4613 var e = Function._validateParams(arguments, [ 4614 {name: "type", type: Type}, 4615 {name: "properties", mayBeNull: true, optional: true}, 4616 {name: "events", mayBeNull: true, optional: true}, 4617 {name: "references", mayBeNull: true, optional: true}, 4618 {name: "element", mayBeNull: true, domElement: true, optional: true} 4619 ]); 4620 if (e) throw e; 4621 if (type.inheritsFrom(Sys.UI.Behavior) || type.inheritsFrom(Sys.UI.Control)) { 4622 if (!element) throw Error.argument('element', Sys.Res.createNoDom); 4623 } 4624 else if (element) throw Error.argument('element', Sys.Res.createComponentOnDom); 4625 var component = (element ? new type(element): new type()); 4626 callIf(component, "beginUpdate"); 4627 if (properties) { 4628 Sys.Component._setProperties(component, properties); 4629 } 4630 if (events) { 4631 for (var name in events) {
4632 if (!(component["add_" + name] instanceof Function)) throw new Error.invalidOperation(String.format(Sys.Res.undefinedEvent, name)); 4633 if (!(events[name] instanceof Function)) throw new Error.invalidOperation(Sys.Res.eventHandlerNotFunction); 4634 component["add_" + name](events[name]); 4635 } 4636 } 4637 Sys.Component._register(component, references); 4638 return component; 4639} 4640$type._register = function Component$_register(component, references, dontUpdate) { 4641 var ret; 4642 if (Sys.Component.isInstanceOfType(component)) { 4643 ret = true; 4644 var app = Sys.Application; 4645 if (component.get_id()) { 4646 app.addComponent(component); 4647 } 4648 if (app.get_isCreatingComponents()) { 4649 app._createdComponents.push(component); 4650 if (references) { 4651 app._addComponentToSecondPass(component, references); 4652 } 4653 else if (!dontUpdate) { 4654 component.endUpdate(); 4655 } 4656 } 4657 else { 4658 if (references) { 4659 Sys.Component._setReferences(component, references); 4660 } 4661 if (!dontUpdate) { 4662 component.endUpdate(); 4663 } 4664 } 4665 } 4666 return ret; 4667} 4668 4669Sys._getComponent = function _getComponent(found, selector, context) { 4670 var component = Sys.Application.findComponent(selector); 4671 if (component) { 4672 found.push(component); 4673 } 4674} 4675 4676Sys._2Pass = function _2Pass(callback) { 4677 var app = Sys.Application, 4678 useTwoPass = !app.get_isCreatingComponents(); 4679 if (useTwoPass) app.beginCreateComponents(); 4680 foreach(callback, function(c) { c() }); 4681 if (useTwoPass) app.endCreateComponents(); 4682} 4683$type = Sys.UI.MouseButton = function MouseButton() { 4684 /// <summary locid="M:J#Sys.UI.MouseButton.#ctor">Describes mouse buttons. The values are those from the DOM standard, which are different from the IE values.</summary> 4685 /// <field name="leftButton" type="Number" integer="true" static="true" locid="F:J#Sys.UI.MouseButton.leftButton"></field> 4686 /// <field name="middleButton" type="Number" integer="true" static="true" locid="F:J#Sys.UI.MouseButton.middleButton"></field> 4687 /// <field name="rightButton" type="Number" integer="true" static="true" locid="F:J#Sys.UI.MouseButton.rightButton"></field> 4688 if (arguments.length !== 0) throw Error.parameterCount(); 4689 throw Error.notImplemented(); 4690} 4691$type.prototype = { 4692 leftButton: 0, 4693 middleButton: 1, 4694 rightButton: 2 4695} 4696$type.registerEnum("Sys.UI.MouseButton"); 4697$type = Sys.UI.Key = function Key() { 4698 /// <summary locid="M:J#Sys.UI.Key.#ctor">Describes key codes.</summary> 4699 /// <field name="backspace" type="Number" integer="true" static="true" locid="F:J#Sys.UI.Key.backspace"></field> 4700 /// <field name="tab" type="Number" integer="true" static="true" locid="F:J#Sys.UI.Key.tab"></field> 4701 /// <field name="enter" type="Number" integer="true" static="true" locid="F:J#Sys.UI.Key.enter"></field> 4702 /// <field name="esc" type="Number" integer="true" static="true" locid="F:J#Sys.UI.Key.esc"></field> 4703 /// <field name="space" type="Number" integer="true" static="true" locid="F:J#Sys.UI.Key.space"></field> 4704 /// <field name="pageUp" type="Number" integer="true" static="true" locid="F:J#Sys.UI.Key.pageUp"></field> 4705 /// <field name="pageDown" type="Number" integer="true" static="true" locid="F:J#Sys.UI.Key.pageDown"></field> 4706 /// <field name="end" type="Number" integer="true" static="true" locid="F:J#Sys.UI.Key.end"></field> 4707 /// <field name="home" type="Number" integer="true" static="true" locid="F:J#Sys.UI.Key.home"></field> 4708 /// <field name="left" type="Number" integer="true" static="true" locid="F:J#Sys.UI.Key.left"></field> 4709 /// <field name="up" type="Number" integer="true" static="true" locid="F:J#Sys.UI.Key.up"></field> 4710 /// <field name="right" type="Number" integer="true" static="true" locid="F:J#Sys.UI.Key.right"></field> 4711 /// <field name="down" type="Number" integer="true" static="true" locid="F:J#Sys.UI.Key.down"></field> 4712 /// <field name="del" type="Number" integer="true" static="true" locid="F:J#Sys.UI.Key.del"></field> 4713 if (arguments.length !== 0) throw Error.parameterCount(); 4714 throw Error.notImplemented(); 4715} 4716$type.prototype = { 4717 backspace: 8, 4718 tab: 9, 4719 enter: 13, 4720 esc: 27, 4721 space: 32, 4722 pageUp: 33, 4723 pageDown: 34, 4724 end: 35, 4725 home: 36, 4726 left: 37, 4727 up: 38, 4728 right: 39, 4729 down: 40, 4730 del: 127 4731} 4732$type.registerEnum("Sys.UI.Key"); 4733$type = Sys.UI.Point = function Point(x, y) { 4734 /// <summary locid="M:J#Sys.UI.Point.#ctor"></summary> 4735 /// <param name="x" type="Number" integer="true"></param> 4736 /// <param name="y" type="Number" integer="true"></param> 4737 /// <field name="x" type="Number" integer="true" locid="F:J#Sys.UI.Point.x"></field> 4738 /// <field name="y" type="Number" integer="true" locid="F:J#Sys.UI.Point.y"></field> 4739 var e = Function._validateParams(arguments, [ 4740 {name: "x", type: Number, integer: true}, 4741 {name: "y", type: Number, integer: true} 4742 ]); 4743 if (e) throw e; 4744 this.x = x; 4745 this.y = y; 4746} 4747$type.registerClass('Sys.UI.Point'); 4748$type = Sys.UI.Bounds = function Bounds(x, y, width, height) { 4749 /// <summary locid="M:J#Sys.UI.Bounds.#ctor"></summary> 4750 /// <param name="x" type="Number" integer="true"></param> 4751 /// <param name="y" type="Number" integer="true"></param> 4752 /// <param name="width" type="Number" integer="true"></param> 4753 /// <param name="height" type="Number" integer="true"></param> 4754 /// <field name="x" type="Number" integer="true" locid="F:J#Sys.UI.Bounds.x"></field> 4755 /// <field name="y" type="Number" integer="true" locid="F:J#Sys.UI.Bounds.y"></field> 4756 /// <field name="width" type="Number" integer="true" locid="F:J#Sys.UI.Bounds.width"></field> 4757 /// <field name="height" type="Number" integer="true" locid="F:J#Sys.UI.Bounds.height"></field> 4758 var e = Function._validateParams(arguments, [ 4759 {name: "x", type: Number, integer: true}, 4760 {name: "y", type: Number, integer: true},
4761 {name: "width", type: Number, integer: true}, 4762 {name: "height", type: Number, integer: true} 4763 ]); 4764 if (e) throw e; 4765 this.x = x; 4766 this.y = y; 4767 this.height = height; 4768 this.width = width; 4769} 4770$type.registerClass('Sys.UI.Bounds'); 4771$type = Sys.UI.DomEvent = function DomEvent(eventObject) { 4772 /// <summary locid="M:J#Sys.UI.DomEvent.#ctor">A cross-browser object that represents event properties.</summary> 4773 /// <param name="eventObject">The browser-specific event object (window.event for IE).</param> 4774 /// <field name="altKey" type="Boolean" locid="F:J#Sys.UI.DomEvent.altKey"></field> 4775 /// <field name="button" type="Sys.UI.MouseButton" locid="F:J#Sys.UI.DomEvent.button"></field> 4776 /// <field name="charCode" type="Number" integer="true" locid="F:J#Sys.UI.DomEvent.charCode">The character code for the pressed key.</field> 4777 /// <field name="clientX" type="Number" integer="true" locid="F:J#Sys.UI.DomEvent.clientX"></field> 4778 /// <field name="clientY" type="Number" integer="true" locid="F:J#Sys.UI.DomEvent.clientY"></field> 4779 /// <field name="ctrlKey" type="Boolean" locid="F:J#Sys.UI.DomEvent.ctrlKey"></field> 4780 /// <field name="keyCode" type="Number" integer="true" locid="F:J#Sys.UI.DomEvent.keyCode">The key code for the pressed key.</field> 4781 /// <field name="offsetX" type="Number" integer="true" locid="F:J#Sys.UI.DomEvent.offsetX"></field> 4782 /// <field name="offsetY" type="Number" integer="true" locid="F:J#Sys.UI.DomEvent.offsetY"></field> 4783 /// <field name="screenX" type="Number" integer="true" locid="F:J#Sys.UI.DomEvent.screenX"></field> 4784 /// <field name="screenY" type="Number" integer="true" locid="F:J#Sys.UI.DomEvent.screenY"></field> 4785 /// <field name="shiftKey" type="Boolean" locid="F:J#Sys.UI.DomEvent.shiftKey"></field> 4786 /// <field name="target" locid="F:J#Sys.UI.DomEvent.target"></field> 4787 /// <field name="type" type="String" locid="F:J#Sys.UI.DomEvent.type"></field> 4788 var e = Function._validateParams(arguments, [ 4789 {name: "eventObject"} 4790 ]); 4791 if (e) throw e; 4792 var ev = eventObject; 4793 var etype = this.type = ev.type.toLowerCase(); 4794 this.rawEvent = ev; 4795 this.altKey = ev.altKey; 4796 if (typeof(ev.button) !== 'undefined') { 4797 this.button = (typeof(ev.which) !== 'undefined') ? ev.button : 4798 (ev.button === 4) ? Sys.UI.MouseButton.middleButton : 4799 (ev.button === 2) ? Sys.UI.MouseButton.rightButton : 4800 Sys.UI.MouseButton.leftButton; 4801 } 4802 if (etype === 'keypress') { 4803 this.charCode = ev.charCode || ev.keyCode; 4804 } 4805 else if (ev.keyCode && (ev.keyCode === 46)) { 4806 this.keyCode = 127; 4807 } 4808 else { 4809 this.keyCode = ev.keyCode; 4810 } 4811 this.clientX = ev.clientX; 4812 this.clientY = ev.clientY; 4813 this.ctrlKey = ev.ctrlKey; 4814 this.target = ev.target || ev.srcElement; 4815 if (!etype.startsWith('key')) { 4816 if ((typeof(ev.offsetX) !== 'undefined') && (typeof(ev.offsetY) !== 'undefined')) { 4817 this.offsetX = ev.offsetX; 4818 this.offsetY = ev.offsetY; 4819 } 4820 else if (this.target && (this.target.nodeType !== 3) && (typeof(ev.clientX) === 'number')) { 4821 var loc = Sys.UI.DomElement.getLocation(this.target); 4822 var w = Sys.UI.DomElement._getWindow(this.target); 4823 this.offsetX = (w.pageXOffset || 0) + ev.clientX - loc.x; 4824 this.offsetY = (w.pageYOffset || 0) + ev.clientY - loc.y; 4825 } 4826 } 4827 this.screenX = ev.screenX; 4828 this.screenY = ev.screenY; 4829 this.shiftKey = ev.shiftKey; 4830} 4831$type.prototype = { 4832 preventDefault: function DomEvent$preventDefault() { 4833 /// <summary locid="M:J#Sys.UI.DomEvent.preventDefault">Prevents the default event action from happening. For example, a textbox keydown event, if suppressed, will prevent the character from being appended to the textbox.</summary> 4834 if (arguments.length !== 0) throw Error.parameterCount(); 4835 var raw = this.rawEvent; 4836 if (raw.preventDefault) { 4837 raw.preventDefault(); 4838 } 4839 else if (window.event) { 4840 raw.returnValue = false; 4841 } 4842 }, 4843 stopPropagation: function DomEvent$stopPropagation() { 4844 /// <summary locid="M:J#Sys.UI.DomEvent.stopPropagation">Prevents the event from being propagated to parent elements.</summary> 4845 if (arguments.length !== 0) throw Error.parameterCount(); 4846 var raw = this.rawEvent; 4847 if (raw.stopPropagation) { 4848 raw.stopPropagation(); 4849 } 4850 else if (window.event) { 4851 raw.cancelBubble = true; 4852 } 4853 } 4854} 4855$type.registerClass('Sys.UI.DomEvent'); 4856 4857$addHandler = $type.addHandler = function DomEvent$addHandler(elements, eventName, handler, autoRemove) { 4858 /// <summary locid="M:J#Sys.UI.DomEvent.addHandler">A cross-browser way to add a DOM event handler to an element.</summary> 4859 /// <param name="elements">The element or text node, or array of elements or text nodes, that exposes the event. You may also pass a DOM selector or array of DOM selectors.</param> 4860 /// <param name="eventName" type="String">The name of the event. Do not include the 'on' prefix, for example, 'click' instead of 'onclick'.</param> 4861 /// <param name="handler" type="Function">The event handler to add.</param> 4862 /// <param name="autoRemove" type="Boolean" optional="true" mayBeNull="true">Whether the handler should be removed automatically when the element is disposed of, such as when an UpdatePanel refreshes, or Sys.Application.disposeElement is called.</param> 4863 var e = Function._validateParams(arguments, [ 4864 {name: "elements"}, 4865 {name: "eventName", type: String}, 4866 {name: "handler", type: Function}, 4867 {name: "autoRemove", type: Boolean, mayBeNull: true, optional: true} 4868 ]); 4869 if (e) throw e;
4870 if (eventName === "error") throw Error.invalidOperation(Sys.Res.addHandlerCantBeUsedForError); 4871 Sys.query(elements).each(function() { 4872 var nodeType = this.nodeType; 4873 if (nodeType === 3 || nodeType === 2 || nodeType === 8) return; 4874 Sys.UI.DomEvent._ensureDomNode(this); 4875 if (!this._events) { 4876 this._events = {}; 4877 } 4878 var eventCache = this._events[eventName]; 4879 if (!eventCache) { 4880 this._events[eventName] = eventCache = []; 4881 } 4882 var element = this, 4883 browserHandler; 4884 if (this.addEventListener) { 4885 browserHandler = function(e) { 4886 return handler.call(element, new Sys.UI.DomEvent(e)); 4887 } 4888 this.addEventListener(eventName, browserHandler, false); 4889 } 4890 else if (this.attachEvent) { 4891 browserHandler = function() { 4892 var ex, ev = {}; 4893 try {ev = Sys.UI.DomElement._getWindow(element).event} catch(ex) {} 4894 return handler.call(element, new Sys.UI.DomEvent(ev)); 4895 } 4896 this.attachEvent('on' + eventName, browserHandler); 4897 } 4898 eventCache.push({handler: handler, browserHandler: browserHandler, autoRemove: autoRemove }); 4899 if (autoRemove) { 4900 Sys.UI.DomElement._onDispose(this, Sys.UI.DomEvent._disposeHandlers); 4901 } 4902 }); 4903} 4904 4905Sys.registerPlugin({ 4906 name: "addHandler", 4907 dom: true, 4908 returnType: "Sys.ElementSet", 4909 description: "A cross-browser way to add a DOM event handler to an element.", 4910 parameters: [ 4911 {name: "eventName", type: "String", description: "The name of the event. Do not include the 'on' prefix, for example, 'click' instead of 'onclick'."}, 4912 {name: "handler", type: "Function", description: "The event handler to add."}, 4913 {name: "autoRemove", type: "Boolean", description: "Whether the handler should be removed automatically when the element is disposed of, such as when an UpdatePanel refreshes, or Sys.Application.disposeElement is called."} 4914 ], 4915 plugin: function (eventName, handler, autoRemove) { 4916 Sys.UI.DomEvent.addHandler(this.get(), eventName, handler, autoRemove); 4917 return this; 4918 } 4919}); 4920 4921$addHandlers = $type.addHandlers = function DomEvent$addHandlers(elements, events, handlerOwner, autoRemove) { 4922 /// <summary locid="M:J#Sys.UI.DomEvent.addHandlers">Adds a list of event handlers to an element. If a handlerOwner is specified, delegates are created with each of the handlers.</summary> 4923 /// <param name="elements">The element or text node, or array of element or text nodes, that exposes the event. You may also pass a DOM selector or array of DOM selectors.</param> 4924 /// <param name="events" type="Object">A dictionary of event handlers.</param> 4925 /// <param name="handlerOwner" optional="true" mayBeNull="true">The owner of the event handlers that will be the this pointer for the delegates that will be created from the handlers.</param> 4926 /// <param name="autoRemove" type="Boolean" optional="true" mayBeNull="true">Whether the handler should be removed automatically when the element is disposed of, such as when an UpdatePanel refreshes, or when Sys.Application.disposeElement is called.</param> 4927 var e = Function._validateParams(arguments, [ 4928 {name: "elements"}, 4929 {name: "events", type: Object}, 4930 {name: "handlerOwner", mayBeNull: true, optional: true}, 4931 {name: "autoRemove", type: Boolean, mayBeNull: true, optional: true} 4932 ]); 4933 if (e) throw e; 4934 Sys.query(elements).each(function() { 4935 var nodeType = this.nodeType; 4936 if (nodeType === 3 || nodeType === 2 || nodeType === 8) return; 4937 Sys.UI.DomEvent._ensureDomNode(this); 4938 for (var name in events) { 4939 var handler = events[name]; 4940 if (typeof(handler) !== 'function') throw Error.invalidOperation(Sys.Res.cantAddNonFunctionhandler); 4941 if (handlerOwner) { 4942 handler = Function.createDelegate(handlerOwner, handler); 4943 } 4944 $addHandler(this, name, handler, autoRemove || false); 4945 } 4946 });
4947} 4948 4949Sys.registerPlugin({ 4950 name: "addHandlers", 4951 dom: true, 4952 returnType: "Sys.ElementSet", 4953 description: "Adds a list of event handlers to an element. If a handlerOwner is specified, delegates are created with each of the handlers.", 4954 parameters: [ 4955 {name: "events", type: "Object", description: "A dictionary of event handlers."}, 4956 {name: "handlerOwner", description: "The owner of the event handlers that will be the this pointer for the delegates that will be created from the handlers."}, 4957 {name: "autoRemove", type: "Boolean", description: "Whether the handler should be removed automatically when the element is disposed of, such as when an UpdatePanel refreshes, or Sys.Application.disposeElement is called."} 4958 ], 4959 plugin: function (events, handlerOwner, autoRemove) { 4960 Sys.UI.DomEvent.addHandlers(this.get(), events, handlerOwner, autoRemove); 4961 return this; 4962 } 4963}); 4964 4965$clearHandlers = $type.clearHandlers = function DomEvent$clearHandlers(elements) { 4966 /// <summary locid="M:J#Sys.UI.DomEvent.clearHandlers">Clears all the event handlers that were added to the element or array of elements.</summary> 4967 /// <param name="elements">The element or text node, or an array of elements or text nodes. You may also pass a DOM selector or array of DOM selectors.</param> 4968 var e = Function._validateParams(arguments, [ 4969 {name: "elements"} 4970 ]); 4971 if (e) throw e; 4972 Sys.query(elements).each(function() { 4973 var nodeType = this.nodeType; 4974 if (nodeType === 3 || nodeType === 2 || nodeType === 8) return; 4975 Sys.UI.DomEvent._ensureDomNode(this); 4976 Sys.UI.DomEvent._clearHandlers(this, false); 4977 }); 4978} 4979 4980Sys.registerPlugin({ 4981 name: "clearHandlers", 4982 dom: true, 4983 returnType: "Sys.ElementSet", 4984 description: "Clears all the event handlers that were added to the element or array of elements.", 4985 plugin: function() { 4986 Sys.UI.DomEvent.clearHandlers(this.get()); 4987 return this; 4988 } 4989}); 4990 4991$type._clearHandlers = function DomEvent$_clearHandlers(elements, autoRemoving) { 4992 Sys.query(elements).each(function() { 4993 var nodeType = this.nodeType; 4994 if (nodeType === 3 || nodeType === 2 || nodeType === 8) return; 4995 Sys.UI.DomEvent._ensureDomNode(this); 4996 var cache = this._events; 4997 if (cache) { 4998 for (var name in cache) { 4999 var handlers = cache[name]; 5000 for (var i = handlers.length - 1; i >= 0; i--) { 5001 var entry = handlers[i]; 5002 if (!autoRemoving || entry.autoRemove) { 5003 $removeHandler(this, name, entry.handler); 5004 } 5005 } 5006 } 5007 } 5008 }); 5009} 5010 5011$type._disposeHandlers = function DomEvent$_disposeHandlers() { 5012 Sys.UI.DomEvent._clearHandlers(this, true); 5013} 5014 5015$removeHandler = $type.removeHandler = function DomEvent$removeHandler(elements, eventName, handler) { 5016 /// <summary locid="M:J#Sys.UI.DomEvent.removeHandler">A cross-browser way to remove a DOM event handler from an element.</summary> 5017 /// <param name="elements">The element or text node, or array of elements or text nodes, that exposes the event. You may also pass a DOM selector or array of DOM selectors.</param> 5018 /// <param name="eventName" type="String">The name of the event. Do not include the 'on' prefix, for example, 'click' instead of 'onclick'.</param> 5019 /// <param name="handler" type="Function">The event handler to remove.</param> 5020 var e = Function._validateParams(arguments, [ 5021 {name: "elements"}, 5022 {name: "eventName", type: String}, 5023 {name: "handler", type: Function} 5024 ]); 5025 if (e) throw e; 5026 Sys.UI.DomEvent._removeHandler(elements, eventName, handler); 5027} 5028$type._removeHandler = function DomEvent$_removeHandler(elements, eventName, handler) { 5029 Sys.query(elements).each(function() { 5030 var nodeType = this.nodeType; 5031 if (nodeType === 3 || nodeType === 2 || nodeType === 8) return;
5032 Sys.UI.DomEvent._ensureDomNode(this); 5033 var browserHandler = null; 5034 if ((typeof(this._events) !== 'object') || !this._events) throw Error.invalidOperation(Sys.Res.eventHandlerInvalid); 5035 var cache = this._events[eventName]; 5036 if (!(cache instanceof Array)) throw Error.invalidOperation(Sys.Res.eventHandlerInvalid); 5037 for (var i = 0, l = cache.length; i < l; i++) { 5038 if (cache[i].handler === handler) { 5039 browserHandler = cache[i].browserHandler; 5040 break; 5041 } 5042 } 5043 if (typeof(browserHandler) !== 'function') throw Error.invalidOperation(Sys.Res.eventHandlerInvalid); 5044 if (this.removeEventListener) { 5045 this.removeEventListener(eventName, browserHandler, false); 5046 } 5047 else if (this.detachEvent) { 5048 this.detachEvent('on' + eventName, browserHandler); 5049 } 5050 cache.splice(i, 1); 5051 }); 5052} 5053 5054Sys.registerPlugin({ 5055 name: "removeHandler", 5056 dom: true, 5057 returnType: "Sys.ElementSet", 5058 description: "A cross-browser way to remove a DOM event handler from an element.", 5059 parameters: [ 5060 {name: "eventName", type: "String", description: "The name of the event. Do not include the 'on' prefix, for example, 'click' instead of 'onclick'."}, 5061 {name: "handler", type: "Function", description: "The event handler to remove."} 5062 ], 5063 plugin: function (eventName, handler) { 5064 Sys.UI.DomEvent.removeHandler(this.get(), eventName, handler); 5065 return this; 5066 } 5067}); 5068 5069 5070$type._ensureDomNode = function DomEvent$_ensureDomNode(element) { 5071 if (element && element.tagName && (element.tagName.toUpperCase() === "SCRIPT")) return; 5072 5073 var doc = element ? (element.ownerDocument || element.document || element) : null; 5074 if (!element || 5075 ((typeof(element.document) !== 'object') && (element != doc) && (typeof(element.nodeType) !== 'number'))) { 5076 throw Error.argument("element", Sys.Res.argumentDomNode); 5077 } 5078} 5079$type = Sys.UI.DomElement = function DomElement() { 5080 /// <summary locid="M:J#Sys.UI.DomElement.#ctor">This static class provides helpers to work with DOM elements.</summary> 5081 if (arguments.length !== 0) throw Error.parameterCount(); 5082 throw Error.notImplemented(); 5083} 5084$type.registerClass('Sys.UI.DomElement'); 5085 5086$type.addCssClass = function DomElement$addCssClass(element, className) { 5087 /// <summary locid="M:J#Sys.UI.DomElement.addCssClass">Adds a CSS class to an element if it doesn't already have it.</summary> 5088 /// <param name="element" domElement="true"></param> 5089 /// <param name="className" type="String">The name of the CSS class to add.</param> 5090 var e = Function._validateParams(arguments, [ 5091 {name: "element", domElement: true}, 5092 {name: "className", type: String} 5093 ]); 5094 if (e) throw e; 5095 if (!Sys.UI.DomElement.containsCssClass(element, className)) { 5096 if (element.className === '') { 5097 element.className = className; 5098 } 5099 else { 5100 element.className += ' ' + className; 5101 } 5102 } 5103} 5104 5105$type.containsCssClass = function DomElement$containsCssClass(element, className) { 5106 /// <summary locid="M:J#Sys.UI.DomElement.containsCssClass">Determines if an element has the specified CSS class.</summary> 5107 /// <param name="element" domElement="true"></param> 5108 /// <param name="className" type="String">The name of the CSS class to test.</param> 5109 /// <returns type="Boolean">True if the CSS class was found on the element.</returns> 5110 var e = Function._validateParams(arguments, [ 5111 {name: "element", domElement: true}, 5112 {name: "className", type: String} 5113 ]); 5114 if (e) throw e; 5115 return Array.contains(element.className.split(' '), className); 5116} 5117 5118$type.getBounds = function DomElement$getBounds(element) { 5119 /// <summary locid="M:J#Sys.UI.DomElement.getBounds">Gets the coordinates, width and height of an element.</summary> 5120 /// <param name="element" domElement="true"></param> 5121 /// <returns type="Sys.UI.Bounds">A Bounds object with four fields, x, y, width and height, which contain the pixel coordinates, width and height of the element.</returns> 5122 var e = Function._validateParams(arguments, [ 5123 {name: "element", domElement: true} 5124 ]); 5125 if (e) throw e; 5126 var offset = Sys.UI.DomElement.getLocation(element); 5127 5128 return new Sys.UI.Bounds(offset.x, offset.y, element.offsetWidth || 0, element.offsetHeight || 0
5128); 5129} 5130 5131$get = $type.getElementById = function DomElement$getElementById(id, element) { 5132 /// <summary locid="M:J#Sys.UI.DomElement.getElementById">Finds an element by id.</summary> 5133 /// <param name="id" type="String">The id of the element to find.</param> 5134 /// <param name="element" domElement="true" optional="true" mayBeNull="true"></param> 5135 /// <returns domElement="true" mayBeNull="true">The element, or null if it was not found.</returns> 5136 var e = Function._validateParams(arguments, [ 5137 {name: "id", type: String}, 5138 {name: "element", mayBeNull: true, domElement: true, optional: true} 5139 ]); 5140 if (e) throw e; 5141 return Sys.get("#" + id, element || null); 5142} 5143 5144if (document.documentElement.getBoundingClientRect) { 5145 $type.getLocation = function DomElement$getLocation(element) { 5146 /// <summary locid="M:J#Sys.UI.DomElement.getLocation">Gets the coordinates of a DOM element.</summary> 5147 /// <param name="element" domElement="true"></param> 5148 /// <returns type="Sys.UI.Point">A Point object with two fields, x and y, which contain the pixel coordinates of the element.</returns> 5149 var e = Function._validateParams(arguments, [ 5150 {name: "element", domElement: true} 5151 ]); 5152 if (e) throw e; 5153 5154 if (element.self || element.nodeType === 9 || 5155 (element === document.documentElement) || 5156 (element.parentNode === element.ownerDocument.documentElement)) { 5157 return new Sys.UI.Point(0, 0); 5158 } 5159 5160 var clientRect = element.getBoundingClientRect(); 5161 if (!clientRect) { 5162 return new Sys.UI.Point(0,0); 5163 } 5164 var ex, ownerDoc = element.ownerDocument, documentElement = ownerDoc.documentElement, 5165 offsetX = Math.round(clientRect.left) + (documentElement.scrollLeft || (ownerDoc.body ? ownerDoc.body.scrollLeft : 0)), 5166 offsetY = Math.round(clientRect.top) + (documentElement.scrollTop || (ownerDoc.body ? ownerDoc.body.scrollTop : 0)); 5167 if (isBrowser("InternetExplorer")) { 5168 try { 5169 var f = element.ownerDocument.parentWindow.frameElement || null; 5170 if (f) { 5171 f = f.frameBorder; 5172 var offset = (f === "0" || f === "no") ? 2 : 0; 5173 offsetX += offset; 5174 offsetY += offset; 5175 } 5176 } 5177 catch(ex) { 5178 } 5179 if (Sys.Browser.version === 7 && !document.documentMode) { 5180 var body = document.body, 5181 rect = body.getBoundingClientRect(), 5182 zoom = (rect.right-rect.left) / body.clientWidth; 5183 zoom = Math.round(zoom * 100); 5184 zoom = (zoom - zoom % 5) / 100; 5185 if (!isNaN(zoom) && (zoom !== 1)) { 5186 offsetX = Math.round(offsetX / zoom); 5187 offsetY = Math.round(offsetY / zoom); 5188 } 5189 } 5190 if ((document.documentMode || 0) < 8) { 5191 offsetX -= documentElement.clientLeft; 5192 offsetY -= documentElement.clientTop; 5193 } 5194 } 5195 return new Sys.UI.Point(offsetX, offsetY); 5196 } 5197} 5198else if (isBrowser("Safari")) { 5199 $type.getLocation = function DomElement$getLocation_Safari(element) { 5200 /// <summary locid="M:J#Sys.UI.DomElement.getLocation">Gets the coordinates of a DOM element.</summary> 5201 /// <param name="element" domElement="true"></param> 5202 /// <returns type="Sys.UI.Point">A Point object with two fields, x and y, which contain the pixel coordinates of the element.</returns> 5203 var e = Function._validateParams(arguments, [ 5204 {name: "element", domElement: true} 5205 ]); 5206 if (e) throw e; 5207 if ((element.window && (element.window === element)) || element.nodeType === 9) return new Sys.UI.Point(0,0); 5208 5209 var offsetX = 0, offsetY = 0, 5210 parent, 5211 previous = null, 5212 previousStyle = null, 5213 currentStyle; 5214 for (parent = element; parent; previous = parent, previousStyle = currentStyle, parent = parent.offsetParent) { 5215 currentStyle = Sys.UI.DomElement._getCurrentStyle(parent); 5216 var tagName = parent.tagName ? parent.tagName.toUpperCase() : null; 5217 5218 if ((parent.offsetLeft || parent.offsetTop) && 5219 ((tagName !== "BODY") || (!previousStyle || previousStyle.position !== "absolute"))) { 5220 offsetX += parent.offsetLeft; 5221 offsetY += parent.offsetTop; 5222 } 5223 5224 if (previous && Sys.Browser.version >= 3) { 5225 offsetX += parseInt(currentStyle.borderLeftWidth);
5226 offsetY += parseInt(currentStyle.borderTopWidth); 5227 } 5228 } 5229 5230 currentStyle = Sys.UI.DomElement._getCurrentStyle(element); 5231 var elementPosition = currentStyle ? currentStyle.position : null; 5232 if (elementPosition !== "absolute") { 5233 for (parent = element.parentNode; parent; parent = parent.parentNode) { 5234 tagName = parent.tagName ? parent.tagName.toUpperCase() : null; 5235 5236 if ((tagName !== "BODY") && (tagName !== "HTML") && (parent.scrollLeft || parent.scrollTop)) { 5237 offsetX -= (parent.scrollLeft || 0); 5238 offsetY -= (parent.scrollTop || 0); 5239 } 5240 currentStyle = Sys.UI.DomElement._getCurrentStyle(parent); 5241 var parentPosition = currentStyle ? currentStyle.position : null; 5242 5243 if (parentPosition && (parentPosition === "absolute")) break; 5244 } 5245 } 5246 return new Sys.UI.Point(offsetX, offsetY); 5247 } 5248} 5249else { 5250 $type.getLocation = function DomElement$getLocation_Generic(element) { 5251 /// <summary locid="M:J#Sys.UI.DomElement.getLocation">Gets the coordinates of a DOM element.</summary> 5252 /// <param name="element" domElement="true"></param> 5253 /// <returns type="Sys.UI.Point">A Point object with two fields, x and y, which contain the pixel coordinates of the element.</returns> 5254 var e = Function._validateParams(arguments, [ 5255 {name: "element", domElement: true} 5256 ]); 5257 if (e) throw e; 5258 if ((element.window && (element.window === element)) || element.nodeType === 9) return new Sys.UI.Point(0,0); 5259 5260 var offsetX = 0, offsetY = 0, 5261 parent, 5262 previous = null, 5263 previousStyle = null, 5264 currentStyle = null; 5265 for (parent = element; parent; previous = parent, previousStyle = currentStyle, parent = parent.offsetParent) { 5266 var tagName = parent.tagName ? parent.tagName.toUpperCase() : null; 5267 currentStyle = Sys.UI.DomElement._getCurrentStyle(parent); 5268 5269 if ((parent.offsetLeft || parent.offsetTop) && 5270 !((tagName === "BODY") && 5271 (!previousStyle || previousStyle.position !== "absolute"))) { 5272 5273 offsetX += parent.offsetLeft; 5274 offsetY += parent.offsetTop; 5275 } 5276 5277 if (previous !== null && currentStyle) { 5278 if ((tagName !== "TABLE") && (tagName !== "TD") && (tagName !== "HTML")) { 5279 offsetX += parseInt(currentStyle.borderLeftWidth) || 0; 5280 offsetY += parseInt(currentStyle.borderTopWidth) || 0; 5281 } 5282 if (tagName === "TABLE" && 5283 (currentStyle.position === "relative" || currentStyle.position === "absolute")) { 5284 offsetX += parseInt(currentStyle.marginLeft) || 0; 5285 offsetY += parseInt(currentStyle.marginTop) || 0; 5286 } 5287 } 5288 } 5289 5290 currentStyle = Sys.UI.DomElement._getCurrentStyle(element); 5291 var elementPosition = currentStyle ? currentStyle.position : null; 5292 if (elementPosition !== "absolute") { 5293 for (parent = element.parentNode; parent; parent = parent.parentNode) { 5294 tagName = parent.tagName ? parent.tagName.toUpperCase() : null; 5295 5296 if ((tagName !== "BODY") && (tagName !== "HTML") && (parent.scrollLeft || parent.scrollTop)) { 5297 5298 offsetX -= (parent.scrollLeft || 0); 5299 offsetY -= (parent.scrollTop || 0); 5300 5301 currentStyle = Sys.UI.DomElement._getCurrentStyle(parent); 5302 if (currentStyle) { 5303 offsetX += parseInt(currentStyle.borderLeftWidth) || 0; 5304 offsetY += parseInt(currentStyle.borderTopWidth) || 0; 5305 } 5306 } 5307 } 5308 } 5309 return new Sys.UI.Point(offsetX, offsetY); 5310 } 5311} 5312 5313$type.isDomElement = function DomElement$isDomElement(obj) { 5314 /// <summary locid="M:J#Sys.UI.DomElement.isDomElement">Determines if the given argument is a DOM element.</summary> 5315 /// <param name="obj"></param> 5316 /// <returns type="Boolean">True if the object is a DOM element, otherwise false.</returns> 5317 var e = Function._validateParams(arguments, [ 5318 {name: "obj"} 5319 ]); 5320 if (e) throw e; 5321 return Sys._isDomElement(obj); 5322} 5323 5324$type.removeCssClass = function DomElement$removeCssClass(element, className) { 5325 /// <summary locid="M:J#Sys.UI.DomElement.removeCssClass">Removes a CSS class from an element.</summary> 5326 /// <param name="element" domElement="true"></param> 5327 /// <param name="className" type="String">The name of the CSS class to remove.</param> 5328 var e = Function._validateParams(arguments, [ 5329 {name: "element", domElement: true}, 5330 {name: "className", type: String} 5331 ]); 5332 if (e) throw e; 5333 var currentClassName = ' ' + element.className + ' '; 5334 var index = currentClassName.indexOf(' ' + className + ' '); 5335 if (index >= 0) { 5336 element.className = (currentClassName.substr(0, index) + ' ' + 5337 currentClassName.substring(index + className.length + 1, currentClassName.length)).trim(); 5338 } 5339} 5340 5341$type.resolveElement = function DomElement$resolveElement(elementOrElementId, containerElement) { 5342 /// <summary locid="M:J#Sys.UI.DomElement.resolveElement">Returns the element with the specified Id in the specified container, or the element if it is already an element.</summary> 5343 /// <param name="elementOrElementId" mayBeNull="true"></param> 5344 /// <param name="containerElement" domElement="true" optional="true" mayBeNull="true"></param> 5345 /// <returns domElement="true"></returns> 5346 var e = Function._validateParams(arguments, [ 5347 {name: "elementOrElementId", mayBeNull: true}, 5348 {name: "containerElement", mayBeNull: true, domElement: true, optional: true} 5349 ]); 5350 if (e) throw e; 5351 var el = elementOrElementId; 5352 if (!el) return null; 5353 if (typeof(el) === "string") { 5354 el = Sys.get("#" + el, containerElement); 5355 if (!el) { 5356 throw Error.argument("elementOrElementId", String.format(Sys.Res.elementNotFound, elementOrElementId)); 5357 } 5358 } 5359 else if(!Sys.UI.DomElement.isDomElement(el)) { 5360 throw Error.argument("elementOrElementId", Sys.Res.expectedElementOrId); 5361 } 5362 return el; 5363} 5364 5365$type.raiseBubbleEvent = function DomElement$raiseBubbleEvent(source, args) { 5366 /// <summary locid="M:J#Sys.UI.DomElement.raiseBubbleEvent">Raises a bubble event.</summary> 5367 /// <param name="source" domElement="true">The DOM element that triggers the event.</param> 5368 /// <param name="args" type="Sys.EventArgs">The event arguments.</param> 5369 var e = Function._validateParams(arguments, [ 5370 {name: "source", domElement: true}, 5371 {name: "args", type: Sys.EventArgs} 5372 ]); 5373 if (e) throw e; 5374 var target = source; 5375 while (target) { 5376 var control = target.control; 5377 if (control && control.onBubbleEvent && control.raiseBubbleEvent) { 5378 if (!control.onBubbleEvent(source, args)) { 5379 control._raiseBubbleEvent(source, args); 5380 } 5381 return; 5382 } 5383 target = target.parentNode; 5384 } 5385} 5386 5387$type._ensureGet = function DomElement$_ensureGet(selector, context, arg) { 5388 var ret = Sys.get(selector, context); 5389 if (!ret && typeof(selector) === "string") {
5390 throw Error.invalidOperation(String.format(Sys.Res.selectorNotFound, selector)); 5391 } 5392 else if (ret && !this.isDomElement(ret)) { 5393 throw Error.invalidOperation(String.format(Sys.Res.expectedDomElementOrSelector, arg)); 5394 } 5395 return ret; 5396} 5397 5398$type.setLocation = function DomElement$setLocation(element, x, y) { 5399 /// <summary locid="M:J#Sys.UI.DomElement.setLocation">Sets the position of an element.</summary> 5400 /// <param name="element" domElement="true"></param> 5401 /// <param name="x" type="Number" integer="true"></param> 5402 /// <param name="y" type="Number" integer="true"></param> 5403 var e = Function._validateParams(arguments, [ 5404 {name: "element", domElement: true}, 5405 {name: "x", type: Number, integer: true}, 5406 {name: "y", type: Number, integer: true} 5407 ]); 5408 if (e) throw e; 5409 var style = element.style; 5410 style.position = 'absolute'; 5411 style.left = x + "px"; 5412 style.top = y + "px"; 5413} 5414 5415$type.toggleCssClass = function DomElement$toggleCssClass(element, className) { 5416 /// <summary locid="M:J#Sys.UI.DomElement.toggleCssClass">Toggles a CSS class on and off o an element.</summary> 5417 /// <param name="element" domElement="true"></param> 5418 /// <param name="className" type="String">The name of the CSS class to toggle.</param> 5419 var e = Function._validateParams(arguments, [ 5420 {name: "element", domElement: true}, 5421 {name: "className", type: String} 5422 ]); 5423 if (e) throw e; 5424 if (Sys.UI.DomElement.containsCssClass(element, className)) { 5425 Sys.UI.DomElement.removeCssClass(element, className); 5426 } 5427 else { 5428 Sys.UI.DomElement.addCssClass(element, className); 5429 } 5430} 5431 5432$type.getVisibilityMode = function DomElement$getVisibilityMode(element) { 5433 /// <summary locid="M:J#Sys.UI.DomElement.getVisibilityMode"></summary> 5434 /// <param name="element" domElement="true"></param> 5435 /// <returns type="Sys.UI.VisibilityMode"></returns> 5436 var e = Function._validateParams(arguments, [ 5437 {name: "element", domElement: true} 5438 ]); 5439 if (e) throw e; 5440 return (element._visibilityMode === Sys.UI.VisibilityMode.hide) ? 5441 Sys.UI.VisibilityMode.hide : 5442 Sys.UI.VisibilityMode.collapse; 5443} 5444$type.setVisibilityMode = function DomElement$setVisibilityMode(element, value) { 5445 /// <summary locid="M:J#Sys.UI.DomElement.setVisibilityMode"></summary> 5446 /// <param name="element" domElement="true"></param> 5447 /// <param name="value" type="Sys.UI.VisibilityMode"></param> 5448 var e = Function._validateParams(arguments, [ 5449 {name: "element", domElement: true}, 5450 {name: "value", type: Sys.UI.VisibilityMode} 5451 ]); 5452 if (e) throw e; 5453 Sys.UI.DomElement._ensureOldDisplayMode(element); 5454 if (element._visibilityMode !== value) { 5455 element._visibilityMode = value; 5456 if (Sys.UI.DomElement.getVisible(element) === false) { 5457 element.style.display = (value === Sys.UI.VisibilityMode.hide) ? element._oldDisplayMode : 'none'; 5458 } 5459 } 5460} 5461 5462$type.getVisible = function DomElement$getVisible(element) { 5463 /// <summary locid="M:J#Sys.UI.DomElement.getVisible"></summary> 5464 /// <param name="element" domElement="true"></param> 5465 /// <returns type="Boolean"></returns> 5466 var e = Function._validateParams(arguments, [ 5467 {name: "element", domElement: true} 5468 ]); 5469 if (e) throw e; 5470 var style = element.currentStyle || Sys.UI.DomElement._getCurrentStyle(element); 5471 return style ? (style.visibility !== 'hidden') && (style.display !== 'none') : true; 5472} 5473$type.setVisible = function DomElement$setVisible(element, value) { 5474 /// <summary locid="M:J#Sys.UI.DomElement.setVisible"></summary> 5475 /// <param name="element" domElement="true"></param> 5476 /// <param name="value" type="Boolean"></param> 5477 var e = Function._validateParams(arguments, [ 5478 {name: "element", domElement: true}, 5479 {name: "value", type: Boolean} 5480 ]); 5481 if (e) throw e; 5482 if (value !== Sys.UI.DomElement.getVisible(element)) { 5483 Sys.UI.DomElement._ensureOldDisplayMode(element); 5484 var style = element.style; 5485 style.visibility = value ? 'visible' : 'hidden'; 5486 style.display = (value || (element._visibilityMode === Sys.UI.VisibilityMode.hide)) ? element._oldDisplayMode : 'none'; 5487 } 5488} 5489 5490$type.setCommand = function DomElement$setCommand(commandSource, commandName, commandArgument, commandTarget) { 5491 /// <summary locid="M:J#Sys.UI.DomElement.setCommand">Causes a DOM element to raise a bubble event when clicked.</summary> 5492 /// <param name="commandSource">The DOM element, array of DOM elements, or DOM element selectors that causes the event when clicked.</param> 5493 /// <param name="commandName" type="String" mayBeNull="true">The name of the command to raise.</param> 5494 /// <param name="commandArgument" mayBeNull="true" optional="true">Optional command argument.</param> 5495 /// <param name="commandTarget" optional="true" mayBeNull="true">DOM element from which the command should start bubbling up.</param> 5496 var e = Function._validateParams(arguments, [ 5497 {name: "commandSource"}, 5498 {name: "commandName", type: String, mayBeNull: true}, 5499 {name: "commandArgument", mayBeNull: true, optional: true}, 5500 {name: "commandTarget", mayBeNull: true, optional: true} 5501 ]); 5502 if (e) throw e; 5503 Sys.UI.DomEvent.addHandler(commandSource, 'click', function(ev) { 5504 var source = commandTarget || this; 5505 Sys.UI.DomElement.raiseBubbleEvent(source, new Sys.CommandEventArgs(commandName, commandArgument, this, ev)); 5506 }, true /*autoRemove*/); 5507} 5508 5509Sys.registerPlugin({ 5510 name: "setCommand", 5511 dom: true, 5512 returnType: "Sys.ElementSet", 5513 description: "Causes a DOM element to raise a bubble event when clicked.", 5514 parameters: [ 5515 {name: "commandName", type:"String", description: "The name of the command to raise."}, 5516 {name: "commandArgument", description: "Optional command argument."}, 5517 {name: "commandTarget", description: "DOM element from which the command should start bubbling up."} 5518 ], 5519 plugin: function(commandName, commandArgument, commandTarget) { 5520 var e = Function._validateParams(arguments, [ 5521 {name: "commandName", type: String, mayBeNull: true}, 5522 {name: "commandArgument", mayBeNull: true, optional: true}, 5523 {name: "commandTarget", mayBeNull: true, optional: true} 5524 ]); 5525 if (e) throw e; 5526 return this.addHandler('click', function(ev) { 5527 var source = commandTarget || this; 5528 Sys.UI.DomElement.raiseBubbleEvent(source, new Sys.CommandEventArgs(commandName, commandArgument, this, ev)); 5529 }, true /*autoRemove*/); 5530 } 5531}); 5532 5533$type._ensureOldDisplayMode = function DomElement$_ensureOldDisplayMode(element) { 5534 if (!element._oldDisplayMode) { 5535 var style = element.currentStyle || this._getCurrentStyle(element); 5536 element._oldDisplayMode = style ? style.display : null; 5537 if (!element._oldDisplayMode || element._oldDisplayMode === 'none') { 5538 var tagName = element.tagName, 5539 mode = 'inline'; 5540 if (/^(DIV|P|ADDRESS|BLOCKQUOTE|BODY|COL|COLGROUP|DD|DL|DT|FIELDSET|FORM|H1|H2|H3|H4|H5|H6|HR|IFRAME|LEGEND|OL|PRE|TABLE|TD|TH|TR|UL)$/i.test(tagName)) { 5541 mode = 'block'; 5542 } 5543 else if (tagName.toUpperCase() === "LI") { 5544 mode = 'list-item'; 5545 } 5546 element._oldDisplayMode = mode; 5547 } 5548 } 5549} 5550 5551$type._getWindow = function DomElement$_getWindow(element) { 5552 var doc = element.ownerDocument || element.document || element; 5553 return doc.defaultView || doc.parentWindow; 5554} 5555 5556$type._getCurrentStyle = function DomElement$_getCurrentStyle(element) { 5557 if (element.nodeType === 3) return null; 5558 var w = this._getWindow(element); 5559 if (element.documentElement) element = element.documentElement; 5560 var computedStyle = (w && (element !== w) && w.getComputedStyle) ? 5561 w.getComputedStyle(element, null) : 5562 element.currentStyle || element.style; 5563 return computedStyle; 5564} 5565 5566$type._onDispose = function DomElement$_onDispose(element, fn) { 5567 var queue, d = element.dispose; 5568 if (d !== Sys.UI.DomElement._dispose) { 5569 element.dispose = Sys.UI.DomElement._dispose; 5570 element.__msajaxdispose = queue = []; 5571 if (typeof(d) === "function") { 5572 queue.push(d); 5573 } 5574 } 5575 else { 5576 queue = element.__msajaxdispose; 5577 } 5578 queue.push(fn); 5579} 5580 5581$type._dispose = function DomElement$_dispose() { 5582 var queue = this.__msajaxdispose; 5583 if (queue) { 5584 for (var i = 0, l = queue.length; i < l; i++) { 5585 queue[i].apply(this); 5586 } 5587 } 5588 if (this.control && typeof(this.control.dispose) === "function") { 5589 this.control.dispose(); 5590 } 5591 this.__msajaxdispose = null; 5592 this.dispose = null; 5593} 5594$type = Sys.IContainer = function IContainer() { 5595 throw Error.notImplemented(); 5596} 5597$type.prototype = { 5598 addComponent: function IContainer$addComponent(component) { 5599 /// <summary locid="M:J#Sys.IContainer.addComponent"></summary> 5600 /// <param name="component" type="Sys.Component"></param> 5601 var e = Function._validateParams(arguments, [ 5602 {name: "component", type: Sys.Component} 5603 ]); 5604 if (e) throw e; 5605 throw Error.notImplemented(); 5606 }, 5607 removeComponent: function IContainer$removeComponent(component) { 5608 /// <summary locid="M:J#Sys.IContainer.removeComponent"></summary> 5609 /// <param name="component" type="Sys.Component"></param> 5610 var e = Function._validateParams(arguments, [ 5611 {name: "component", type: Sys.Component} 5612 ]); 5613 if (e) throw e; 5614 throw Error.notImplemented(); 5615 }, 5616 findComponent: function IContainer$findComponent(id) { 5617 /// <summary locid="M:J#Sys.IContainer.findComponent"></summary> 5618 /// <param name="id" type="String"></param> 5619 /// <returns type="Sys.Component"></returns> 5620 var e = Function._validateParams(arguments, [ 5621 {name: "id", type: String} 5622 ]); 5623 if (e) throw e; 5624 throw Error.notImplemented(); 5625 }, 5626 getComponents: function IContainer$getComponents() { 5627 /// <summary locid="M:J#Sys.IContainer.getComponents"></summary> 5628 /// <returns type="Array" elementType="Sys.Component"></returns> 5629 if (arguments.length !== 0) throw Error.parameterCount(); 5630 throw Error.notImplemented(); 5631 } 5632} 5633$type.registerInterface("Sys.IContainer"); 5634 5635$type = Sys.ApplicationLoadEventArgs = function ApplicationLoadEventArgs(components, isPartialLoad) { 5636 /// <summary locid="M:J#Sys.ApplicationLoadEventArgs.#ctor"></summary> 5637 /// <param name="components" type="Array" elementType="Sys.Component">The list of components that were created since the last time the load event was raised.</param> 5638 /// <param name="isPartialLoad" type="Boolean">True if the page is partially loading.</param> 5639 var e = Function._validateParams(arguments, [ 5640 {name: "components", type: Array, elementType: Sys.Component}, 5641 {name: "isPartialLoad", type: Boolean} 5642 ]); 5643 if (e) throw e; 5644 Sys.ApplicationLoadEventArgs.initializeBase(this); 5645 this._components = components; 5646 this._isPartialLoad = isPartialLoad; 5647} 5648$type.prototype = { 5649 get_components: function ApplicationLoadEventArgs$get_components() { 5650 /// <value type="Array" elementType="Sys.Component" locid="P:J#Sys.ApplicationLoadEventArgs.components">The list of components that were created since the last time the load event was raised.</value> 5651 if (arguments.length !== 0) throw Error.parameterCount(); 5652 return this._components; 5653 }, 5654 get_isPartialLoad: function ApplicationLoadEventArgs$get_isPartialLoad() { 5655 /// <value type="Boolean" locid="P:J#Sys.ApplicationLoadEventArgs.isPartialLoad">True if the page is partially loading.</value> 5656 if (arguments.length !== 0) throw Error.parameterCount(); 5657 return this._isPartialLoad; 5658 } 5659} 5660$type.registerClass('Sys.ApplicationLoadEventArgs', Sys.EventArgs); 5661$type = Sys._Application = function _Application() { 5662 /// <summary locid="M:J#Sys.Application.#ctor"></summary> 5663 if (arguments.length !== 0) throw Error.parameterCount(); 5664 Sys._Application.initializeBase(this); 5665 5666 this._disposableObjects = []; 5667 this._components = {}; 5668 this._createdComponents = []; 5669 this._secondPassComponents = []; 5670 5671 this._unloadHandlerDelegate = Function.createDelegate(this, this._unloadHandler); 5672 Sys.UI.DomEvent.addHandler(window, "unload", this._unloadHandlerDelegate); 5673} 5674$type.prototype = { 5675 _deleteCount: 0, 5676 5677 get_isCreatingComponents: function _Application$get_isCreatingComponents() { 5678 /// <value type="Boolean" locid="P:J#Sys.Application.isCreatingComponents"></value> 5679 if (arguments.length !== 0) throw Error.parameterCount(); 5680 return !!this._creatingComponents; 5681 }, 5682 get_isDisposing: function _Application$get_isDisposing() { 5683 /// <value type="Boolean" locid="P:J#Sys.Application.isDisposing"></value> 5684 if (arguments.length !== 0) throw Error.parameterCount(); 5685 return !!this._disposing; 5686 }, 5687 add_init: function _Application$add_init(handler) { 5688 /// <summary locid="E:J#Sys.Application.init"></summary> 5689 var e = Function._validateParams(arguments, [{name: "handler", type: Function}]); 5690 if (e) throw e; 5691 if (this._initialized) { 5692 handler(this, Sys.EventArgs.Empty); 5693 } 5694 else { 5695 this._addHandler("init", handler); 5696 } 5697 }, 5698 remove_init: function _Application$remove_init(handler) { 5699 var e = Function._validateParams(arguments, [{name: "handler", type: Function}]); 5700 if (e) throw e; 5701 this._removeHandler("init", handler); 5702 }, 5703 add_load: function _Application$add_load(handler) { 5704 /// <summary locid="E:J#Sys.Application.load"></summary> 5705 var e = Function._validateParams(arguments, [{name: "handler", type: Function}]); 5706 if (e) throw e; 5707 this._addHandler("load", handler); 5708 }, 5709 remove_load: function _Application$remove_load(handler) { 5710 var e = Function._validateParams(arguments, [{name: "handler", type: Function}]); 5711 if (e) throw e; 5712 this._removeHandler("load", handler); 5713 }, 5714 add_unload: function _Application$add_unload(handler) { 5715 /// <summary locid="E:J#Sys.Application.unload"></summary> 5716 var e = Function._validateParams(arguments, [{name: "handler", type: Function}]); 5717 if (e) throw e; 5718 this._addHandler("unload", handler); 5719 }, 5720 remove_unload: function _Application$remove_unload(handler) { 5721 var e = Function._validateParams(arguments, [{name: "handler", type: Function}]); 5722 if (e) throw e; 5723 this._removeHandler("unload", handler); 5724 }, 5725 addComponent: function _Application$addComponent(component) { 5726 /// <summary locid="M:J#Sys.Application.addComponent">Adds a top-level component to the application.</summary> 5727 /// <param name="component" type="Sys.Component">The component to add.</param> 5728 var e = Function._validateParams(arguments, [ 5729 {name: "component", type: Sys.Component} 5730 ]); 5731 if (e) throw e; 5732 var id = component.get_id();
5733 if (!id) throw Error.invalidOperation(Sys.Res.cantAddWithoutId); 5734 if (typeof(this._components[id]) !== 'undefined') throw Error.invalidOperation(String.format(Sys.Res.appDuplicateComponent, id)); 5735 this._components[id] = component; 5736 }, 5737 beginCreateComponents: function _Application$beginCreateComponents() { 5738 /// <summary locid="M:J#Sys.Application.beginCreateComponents"></summary> 5739 if (arguments.length !== 0) throw Error.parameterCount(); 5740 this._creatingComponents = true; 5741 }, 5742 dispose: function _Application$dispose() { 5743 /// <summary locid="M:J#Sys.Application.dispose"></summary> 5744 if (arguments.length !== 0) throw Error.parameterCount(); 5745 if (!this._disposing) { 5746 this._disposing = true; 5747 if (this._timerCookie) { 5748 window.clearTimeout(this._timerCookie); 5749 delete this._timerCookie; 5750 } 5751 var endHandler = this._endRequestHandler; 5752 var beginHandler = this._beginRequestHandler; 5753 if (endHandler || beginHandler) { 5754 var prm = Sys.WebForms.PageRequestManager.getInstance(); 5755 if (endHandler) prm.remove_endRequest(endHandler); 5756 if (beginHandler) prm.remove_beginRequest(beginHandler); 5757 delete this._endRequestHandler; 5758 delete this._beginRequestHandler; 5759 } 5760 if (window.pageUnload) { 5761 window.pageUnload(this, Sys.EventArgs.Empty); 5762 } 5763 Sys.Observer.raiseEvent(this, "unload"); 5764 var disposableObjects = Array.clone(this._disposableObjects); 5765 for (var i = 0, l = disposableObjects.length; i < l; i++) { 5766 var object = disposableObjects[i]; 5767 if (typeof(object) !== "undefined") { 5768 object.dispose(); 5769 } 5770 } 5771 this._disposableObjects.length = 0; 5772 5773 Sys.UI.DomEvent.removeHandler(window, "unload", this._unloadHandlerDelegate); 5774 5775 if (Sys._ScriptLoader) { 5776 var sl = Sys._ScriptLoader.getInstance(); 5777 if (sl) { 5778 sl.dispose(); 5779 } 5780 } 5781 5782 Sys._Application.callBaseMethod(this, 'dispose'); 5783 } 5784 }, 5785 disposeElement: function _Application$disposeElement(element, childNodesOnly) { 5786 /// <summary locid="M:J#Sys._Application.disposeElement">Disposes of control and behavior resources associated with an element and its child nodes.</summary> 5787 /// <param name="element">The element to dispose.</param> 5788 /// <param name="childNodesOnly" type="Boolean">Whether to dispose of the element and its child nodes or only its child nodes.</param> 5789 var e = Function._validateParams(arguments, [ 5790 {name: "element"}, 5791 {name: "childNodesOnly", type: Boolean} 5792 ]); 5793 if (e) throw e; 5794 if (element.nodeType === 1) { 5795 var d, c, i, list, 5796 allElements = element.getElementsByTagName("*"), 5797 length = allElements.length, 5798 children = new Array(length); 5799 for (i = 0; i < length; i++) { 5800 children[i] = allElements[i]; 5801 } 5802 for (i = length - 1; i >= 0; i--) { 5803 var child = children[i]; 5804 d = child.dispose; 5805 if (d && typeof(d) === "function") { 5806 child.dispose(); 5807 } 5808 else { 5809 c = child.control; 5810 if (c && typeof(c.dispose) === "function") { 5811 c.dispose(); 5812 } 5813 } 5814 list = child._behaviors; 5815 if (list) { 5816 this._disposeComponents(list); 5817 } 5818 list = child._components; 5819 if (list) { 5820 this._disposeComponents(list); 5821 child._components = null; 5822 } 5823 } 5824 if (!childNodesOnly) { 5825 d = element.dispose; 5826 if (d && typeof(d) === "function") { 5827 element.dispose(); 5828 } 5829 else { 5830 c = element.control; 5831 if (c && typeof(c.dispose) === "function") { 5832 c.dispose(); 5833 } 5834 } 5835 list = element._behaviors; 5836 if (list) { 5837 this._disposeComponents(list); 5838 } 5839 list = element._components; 5840 if (list) { 5841 this._disposeComponents(list); 5842 element._components = null; 5843 } 5844 } 5845 } 5846 }, 5847 endCreateComponents: function _Application$endCreateComponents() { 5848 /// <summary locid="M:J#Sys.Application.endCreateComponents"></summary> 5849 if (arguments.length !== 0) throw Error.parameterCount(); 5850 var components = this._secondPassComponents; 5851 for (var i = 0, l = components.length; i < l; i++) { 5852 var entry = components[i], 5853 component = entry.component; 5854 Sys.Component._setReferences(component, entry.references); 5855 component.endUpdate(); 5856 } 5857 this._secondPassComponents = []; 5858 this._creatingComponents = false; 5859 }, 5860 findComponent: function _Application$findComponent(id, parent) { 5861 /// <summary locid="M:J#Sys.Application.findComponent">Finds top-level components that were added through addComponent if no parent is specified or children of the specified parent. If parent is a component</summary> 5862 /// <param name="id" type="String">The id of the component to find.</param> 5863 /// <param name="parent" optional="true" mayBeNull="true">The component or element that contains the component to find. If not specified or null, the search is made on Application.</param> 5864 /// <returns type="Sys.Component" mayBeNull="true">The component, or null if it wasn't found.</returns> 5865 var e = Function._validateParams(arguments, [ 5866 {name: "id", type: String}, 5867 {name: "parent", mayBeNull: true, optional: true} 5868 ]); 5869 if (e) throw e; 5870 return (parent ? 5871 ((Sys.IContainer.isInstanceOfType(parent)) ? 5872 parent.findComponent(id) : 5873 parent[id] || null) : 5874 Sys.Application._components[id] || null); 5875 }, 5876 getComponents: function _Application$getComponents() { 5877 /// <summary locid="M:J#Sys.Application.getComponents"></summary> 5878 /// <returns type="Array" elementType="Sys.Component"></returns> 5879 if (arguments.length !== 0) throw Error.parameterCount(); 5880 var res = []; 5881 var components = this._components; 5882 for (var name in components) { 5883 if (components.hasOwnProperty(name)) { 5884 res.push(components[name]); 5885 } 5886 } 5887 return res; 5888 }, 5889 initialize: function _Application$initialize() { 5890 /// <summary locid="M:J#Sys.Application.initialize"></summary> 5891 if (arguments.length !== 0) throw Error.parameterCount(); 5892 window.setTimeout(Function.createDelegate(this, this._doInitialize), 0); 5893 }, 5894 _doInitialize: function _Application$_doInitialize() { 5895 if(!this.get_isInitialized() && !this._disposing) { 5896 Sys._Application.callBaseMethod(this, 'initialize'); 5897 this._raiseInit(); 5898 if (this.get_stateString) { 5899 if (Sys.WebForms && Sys.WebForms.PageRequestManager) { 5900 var prm = Sys.WebForms.PageRequestManager.getInstance(); 5901 this._beginRequestHandler = Function.createDelegate(this, this._onPageRequestManagerBeginRequest); 5902 prm.add_beginRequest(this._beginRequestHandler); 5903 this._endRequestHandler = Function.createDelegate(this, this._onPageRequestManagerEndRequest); 5904 prm.add_endRequest(this._endRequestHandler); 5905 } 5906 var loadedEntry = this.get_stateString(); 5907 if (loadedEntry !== this._currentEntry) { 5908 this._navigate(loadedEntry); 5909 } 5910 else { 5911 this._ensureHistory(); 5912 } 5913 }
5914 this.raiseLoad(); 5915 } 5916 }, 5917 notifyScriptLoaded: function _Application$notifyScriptLoaded() { 5918 /// <summary locid="M:J#Sys.Application.notifyScriptLoaded">Called by referenced scripts to indicate that they have completed loading. [Obsolete]</summary> 5919 if (arguments.length !== 0) throw Error.parameterCount(); 5920 }, 5921 registerDisposableObject: function _Application$registerDisposableObject(object) { 5922 /// <summary locid="M:J#Sys.Application.registerDisposableObject">Registers a disposable object with the application.</summary> 5923 /// <param name="object" type="Sys.IDisposable">The object to register.</param> 5924 var e = Function._validateParams(arguments, [ 5925 {name: "object", type: Sys.IDisposable} 5926 ]); 5927 if (e) throw e; 5928 if (!this._disposing) { 5929 var objects = this._disposableObjects, 5930 i = objects.length; 5931 objects[i] = object; 5932 object.__msdisposeindex = i; 5933 } 5934 }, 5935 raiseLoad: function _Application$raiseLoad() { 5936 /// <summary locid="M:J#Sys.Application.raiseLoad"></summary> 5937 if (arguments.length !== 0) throw Error.parameterCount(); 5938 var args = new Sys.ApplicationLoadEventArgs(Array.clone(this._createdComponents), !!this._loaded); 5939 this._loaded = true; 5940 Sys.Observer.raiseEvent(this, "load", args); 5941 if (window.pageLoad) { 5942 window.pageLoad(this, args); 5943 } 5944 this._createdComponents = []; 5945 }, 5946 removeComponent: function _Application$removeComponent(component) { 5947 /// <summary locid="M:J#Sys.Application.removeComponent">Removes a top-level component from the application.</summary> 5948 /// <param name="component" type="Sys.Component">The component to remove.</param> 5949 var e = Function._validateParams(arguments, [ 5950 {name: "component", type: Sys.Component} 5951 ]); 5952 if (e) throw e; 5953 var id = component.get_id(); 5954 if (id) delete this._components[id]; 5955 }, 5956 unregisterDisposableObject: function _Application$unregisterDisposableObject(object) { 5957 /// <summary locid="M:J#Sys.Application.unregisterDisposableObject">Unregisters a disposable object from the application.</summary> 5958 /// <param name="object" type="Sys.IDisposable">The object to unregister.</param> 5959 var e = Function._validateParams(arguments, [ 5960 {name: "object", type: Sys.IDisposable} 5961 ]); 5962 if (e) throw e; 5963 if (!this._disposing) { 5964 var i = object.__msdisposeindex; 5965 if (typeof(i) === "number") { 5966 var disposableObjects = this._disposableObjects; 5967 delete disposableObjects[i]; 5968 delete object.__msdisposeindex; 5969 if (++this._deleteCount > 1000) { 5970 var newArray = []; 5971 for (var j = 0, l = disposableObjects.length; j < l; j++) { 5972 object = disposableObjects[j]; 5973 if (typeof(object) !== "undefined") { 5974 object.__msdisposeindex = newArray.length; 5975 newArray.push(object); 5976 } 5977 } 5978 this._disposableObjects = newArray; 5979 this._deleteCount = 0; 5980 } 5981 } 5982 } 5983 }, 5984 _addComponentToSecondPass: function _Application$_addComponentToSecondPass(component, references) { 5985 this._secondPassComponents.push({component: component, references: references}); 5986 }, 5987 _disposeComponents: function _Application$_disposeComponents(list) { 5988 if (list) { 5989 for (var i = list.length - 1; i >= 0; i--) { 5990 var item = list[i]; 5991 if (typeof(item.dispose) === "function") { 5992 item.dispose(); 5993 } 5994 } 5995 } 5996 }, 5997 _raiseInit: function _Application$_raiseInit() { 5998 this.beginCreateComponents(); 5999 Sys.Observer.raiseEvent(this, "init"); 6000 this.endCreateComponents(); 6001 }, 6002 _unloadHandler: function _Application$_unloadHandler(event) { 6003 this.dispose(); 6004 } 6005} 6006$type.registerClass('Sys._Application', Sys.Component, Sys.IContainer); 6007 6008Sys.Application = new Sys._Application(); 6009window.$find = Sys.Application.findComponent; 6010 6011Sys.onReady(function() { 6012 Sys.Application._doInitialize(); 6013}); 6014 6015 6016$type = Sys.UI.Behavior = function Behavior(element) { 6017 /// <summary locid="M:J#Sys.UI.Behavior.#ctor"></summary> 6018 /// <param name="element" domElement="true">The DOM element the behavior is associated with.</param> 6019 var e = Function._validateParams(arguments, [ 6020 {name: "element", domElement: true} 6021 ]); 6022 if (e) throw e; 6023 Sys.UI.Behavior.initializeBase(this); 6024 this._element = element; 6025 var behaviors = (element._behaviors = element._behaviors || []); 6026 behaviors.push(this); 6027} 6028$type.prototype = {
6029 get_element: function Behavior$get_element() { 6030 /// <value domElement="true" locid="P:J#Sys.UI.Behavior.element">The DOM element this behavior is associated with</value> 6031 if (arguments.length !== 0) throw Error.parameterCount(); 6032 return this._element; 6033 }, 6034 get_id: function Behavior$get_id() { 6035 /// <value type="String" locid="P:J#Sys.UI.Behavior.id"></value> 6036 if (arguments.length !== 0) throw Error.parameterCount(); 6037 var baseId = Sys.UI.Behavior.callBaseMethod(this, 'get_id'); 6038 if (baseId) return baseId; 6039 var element = this._element; 6040 if (!element || !element.id) return ''; 6041 return element.id + '$' + this.get_name(); 6042 }, 6043 get_name: function Behavior$get_name() { 6044 /// <value type="String" locid="P:J#Sys.UI.Behavior.name"></value> 6045 if (arguments.length !== 0) throw Error.parameterCount(); 6046 if (this._name) return this._name; 6047 var name = Object.getTypeName(this); 6048 var i = name.lastIndexOf('.'); 6049 if (i >= 0) name = name.substr(i + 1); 6050 if (!this._initialized) this._name = name; 6051 return name; 6052 }, 6053 set_name: function Behavior$set_name(value) { 6054 var e = Function._validateParams(arguments, [{name: "value", type: String}]); 6055 if (e) throw e; 6056 if ((value === '') || (value.charAt(0) === ' ') || (value.charAt(value.length - 1) === ' ')) 6057 throw Error.argument('value', Sys.Res.invalidId); 6058 if (typeof(this._element[value]) !== 'undefined') 6059 throw Error.invalidOperation(String.format(Sys.Res.behaviorDuplicateName, value)); 6060 if (this.get_isInitialized()) throw Error.invalidOperation(Sys.Res.cantSetNameAfterInit); 6061 this._name = value; 6062 }, 6063 initialize: function Behavior$initialize() { 6064 Sys.UI.Behavior.callBaseMethod(this, 'initialize'); 6065 var name = this.get_name(); 6066 if (name) this._element[name] = this; 6067 }, 6068 dispose: function Behavior$dispose() { 6069 Sys.UI.Behavior.callBaseMethod(this, 'dispose'); 6070 var e = this._element; 6071 if (e) { 6072 var name = this.get_name(); 6073 if (name) { 6074 e[name] = null; 6075 } 6076 var behaviors = e._behaviors; 6077 Array.remove(behaviors, this); 6078 if (!behaviors.length) { 6079 e._behaviors = null; 6080 } 6081 delete this._element; 6082 } 6083 } 6084} 6085$type.registerClass('Sys.UI.Behavior', Sys.Component); 6086 6087$type.getBehaviorByName = function Behavior$getBehaviorByName(element, name) { 6088 /// <summary locid="M:J#Sys.UI.Behavior.getBehaviorByName">Gets a behavior with the specified name from the dom element.</summary> 6089 /// <param name="element" domElement="true">The DOM element to inspect.</param> 6090 /// <param name="name" type="String">The name of the behavior to look for.</param> 6091 /// <returns type="Sys.UI.Behavior" mayBeNull="true">The behaviors or null if it was not found.</returns> 6092 var e = Function._validateParams(arguments, [ 6093 {name: "element", domElement: true}, 6094 {name: "name", type: String} 6095 ]); 6096 if (e) throw e; 6097 var b = element[name]; 6098 return (b && Sys.UI.Behavior.isInstanceOfType(b)) ? b : null; 6099} 6100 6101$type.getBehaviors = function Behavior$getBehaviors(element) { 6102 /// <summary locid="M:J#Sys.UI.Behavior.getBehaviors">Gets a collection containing the behaviors associated with an element.</summary> 6103 /// <param name="element" domElement="true">The DOM element.</param> 6104 /// <returns type="Array" elementType="Sys.UI.Behavior">An array containing the behaviors associated with the DOM element.</returns> 6105 var e = Function._validateParams(arguments, [ 6106 {name: "element", domElement: true} 6107 ]); 6108 if (e) throw e; 6109 var behaviors = element._behaviors; 6110 return behaviors ? Array.clone(behaviors) : []; 6111} 6112 6113Sys.UI.Behavior.getBehaviorsByType = function Behavior$getBehaviorsByType(element, type) { 6114 /// <summary locid="M:J#Sys.UI.Behavior.getBehaviorsByType">Gets an array of behaviors with the specified type from the dom element.</summary> 6115 /// <param name="element" domElement="true">The DOM element to inspect.</param> 6116 /// <param name="type" type="Type">The type of behavior to look for.</param> 6117 /// <returns type="Array" elementType="Sys.UI.Behavior">An array containing the behaviors of the specified type found on the element. The array is empty if no behavior of this type was found.</returns> 6118 var e = Function._validateParams(arguments, [ 6119 {name: "element", domElement: true}, 6120 {name: "type", type: Type} 6121 ]); 6122 if (e) throw e; 6123 var behaviors = element._behaviors; 6124 var results = []; 6125 if (behaviors) { 6126 for (var i = 0, l = behaviors.length; i < l; i++) { 6127 var behavior = behaviors[i]; 6128 if (type.isInstanceOfType(behavior)) { 6129 results.push(behavior); 6130 } 6131 } 6132 } 6133 return results; 6134} 6135$type = Sys.UI.VisibilityMode = function VisibilityMode() { 6136 /// <summary locid="M:J#Sys.UI.VisibilityMode.#ctor">Describes how a DOM element should disappear when its visible property is set to false.</summary> 6137 /// <field name="hide" type="Number" integer="true" static="true" locid="F:J#Sys.UI.VisibilityMode.hide">The element disappears but its space remains</field> 6138 /// <field name="collapse" type="Number" integer="true" static="true" locid="F:J#Sys.UI.VisibilityMode.collapse">The element disappears and the space it occupied is collapsed.</field> 6139 if (arguments.length !== 0) throw Error.parameterCount(); 6140 throw Error.notImplemented(); 6141} 6142$type.prototype = { 6143 hide: 0, 6144 collapse: 1 6145} 6146$type.registerEnum("Sys.UI.VisibilityMode"); 6147 6148$type = Sys.UI.Control = function Control(element) { 6149 /// <summary locid="M:J#Sys.UI.Control.#ctor"></summary> 6150 /// <param name="element" domElement="true">The DOM element the behavior is associated with.</param> 6151 var e = Function._validateParams(arguments, [ 6152 {name: "element", domElement: true} 6153 ]); 6154 if (e) throw e;
6155 if (element.control) throw Error.invalidOperation(Sys.Res.controlAlreadyDefined); 6156 Sys.UI.Control.initializeBase(this); 6157 6158 this._element = element; 6159 element.control = this; 6160 var role = this.get_role(); 6161 if (role) { 6162 element.setAttribute("role", role); 6163 } 6164} 6165$type.prototype = { 6166 _parent: null, 6167 _visibilityMode: Sys.UI.VisibilityMode.hide, 6168 6169 get_element: function Control$get_element() { 6170 /// <value domElement="true" locid="P:J#Sys.UI.Control.element">The DOM element this behavior is associated with</value> 6171 if (arguments.length !== 0) throw Error.parameterCount(); 6172 return this._element; 6173 }, 6174 get_id: function Control$get_id() { 6175 /// <value type="String" locid="P:J#Sys.UI.Control.id"></value> 6176 if (arguments.length !== 0) throw Error.parameterCount(); 6177 return this._id || (this._element ? this._element.id : ""); 6178 }, 6179 get_parent: function Control$get_parent() { 6180 /// <value type="Sys.UI.Control" locid="P:J#Sys.UI.Control.parent"></value> 6181 if (arguments.length !== 0) throw Error.parameterCount(); 6182 if (this._parent) return this._parent; 6183 if (!this._element) return null; 6184 6185 var parentElement = this._element.parentNode; 6186 while (parentElement) { 6187 if (parentElement.control) { 6188 return parentElement.control; 6189 } 6190 parentElement = parentElement.parentNode; 6191 } 6192 return null; 6193 }, 6194 set_parent: function Control$set_parent(value) { 6195 var e = Function._validateParams(arguments, [{name: "value", type: Sys.UI.Control}]); 6196 if (e) throw e; 6197 if (!this._element) throw Error.invalidOperation(Sys.Res.cantBeCalledAfterDispose); 6198 var parents = [this]; 6199 var current = value; 6200 while (current) { 6201 if (Array.contains(parents, current)) throw Error.invalidOperation(Sys.Res.circularParentChain); 6202 parents.push(current); 6203 current = current.get_parent(); 6204 } 6205 this._parent = value; 6206 }, 6207 get_role: function Control$get_role() { 6208 /// <value type="String" locid="P:J#Sys.UI.Control.role"></value> 6209 if (arguments.length !== 0) throw Error.parameterCount(); 6210 return null; 6211 }, 6212 get_visibilityMode: function Control$get_visibilityMode() { 6213 /// <value type="Sys.UI.VisibilityMode" locid="P:J#Sys.UI.Control.visibilityMode"></value> 6214 if (arguments.length !== 0) throw Error.parameterCount(); 6215 if (!this._element) throw Error.invalidOperation(Sys.Res.cantBeCalledAfterDispose); 6216 return Sys.UI.DomElement.getVisibilityMode(this._element); 6217 }, 6218 set_visibilityMode: function Control$set_visibilityMode(value) { 6219 var e = Function._validateParams(arguments, [{name: "value", type: Sys.UI.VisibilityMode}]); 6220 if (e) throw e; 6221 if (!this._element) throw Error.invalidOperation(Sys.Res.cantBeCalledAfterDispose); 6222 Sys.UI.DomElement.setVisibilityMode(this._element, value); 6223 }, 6224 get_visible: function Control$get_visible() { 6225 /// <value type="Boolean" locid="P:J#Sys.UI.Control.visible"></value> 6226 if (arguments.length !== 0) throw Error.parameterCount(); 6227 if (!this._element) throw Error.invalidOperation(Sys.Res.cantBeCalledAfterDispose); 6228 return Sys.UI.DomElement.getVisible(this._element); 6229 }, 6230 set_visible: function Control$set_visible(value) { 6231 var e = Function._validateParams(arguments, [{name: "value", type: Boolean}]); 6232 if (e) throw e; 6233 if (!this._element) throw Error.invalidOperation(Sys.Res.cantBeCalledAfterDispose); 6234 Sys.UI.DomElement.setVisible(this._element, value) 6235 }, 6236 addCssClass: function Control$addCssClass(className) { 6237 /// <summary locid="M:J#Sys.UI.Control.addCssClass">Adds a CSS class to the control if it doesn't already have it.</summary> 6238 /// <param name="className" type="String">The name of the CSS class to add.</param> 6239 var e = Function._validateParams(arguments, [ 6240 {name: "className", type: String} 6241 ]); 6242 if (e) throw e;
6243 if (!this._element) throw Error.invalidOperation(Sys.Res.cantBeCalledAfterDispose); 6244 Sys.UI.DomElement.addCssClass(this._element, className); 6245 }, 6246 dispose: function Control$dispose() { 6247 Sys.UI.Control.callBaseMethod(this, 'dispose'); 6248 if (this._element) { 6249 this._element.control = null; 6250 delete this._element; 6251 } 6252 if (this._parent) delete this._parent; 6253 }, 6254 onBubbleEvent: function Control$onBubbleEvent(source, args) { 6255 /// <summary locid="M:J#Sys.UI.Control.onBubbleEvent"></summary> 6256 /// <param name="source">The object that triggered the event.</param> 6257 /// <param name="args" type="Sys.EventArgs">The event arguments.</param> 6258 /// <returns type="Boolean">False, because the event was not handled and should bubble up further. Derived classes should override that and return true whenever they handle the event to prevent it from bubbling up.</returns> 6259 var e = Function._validateParams(arguments, [ 6260 {name: "source"}, 6261 {name: "args", type: Sys.EventArgs} 6262 ]); 6263 if (e) throw e; 6264 return false; 6265 }, 6266 raiseBubbleEvent: function Control$raiseBubbleEvent(source, args) { 6267 /// <summary locid="M:J#Sys.UI.Control.raiseBubbleEvent"></summary> 6268 /// <param name="source">The object that triggered the event.</param> 6269 /// <param name="args" type="Sys.EventArgs">The event arguments.</param> 6270 var e = Function._validateParams(arguments, [ 6271 {name: "source"}, 6272 {name: "args", type: Sys.EventArgs} 6273 ]); 6274 if (e) throw e; 6275 this._raiseBubbleEvent(source, args); 6276 }, 6277 _raiseBubbleEvent: function Control$_raiseBubbleEvent(source, args) { 6278 var currentTarget = this.get_parent(); 6279 while (currentTarget) { 6280 if (currentTarget.onBubbleEvent(source, args)) { 6281 return; 6282 } 6283 currentTarget = currentTarget.get_parent(); 6284 } 6285 }, 6286 removeCssClass: function Control$removeCssClass(className) { 6287 /// <summary locid="M:J#Sys.UI.Control.removeCssClass">Removes a CSS class from the control.</summary> 6288 /// <param name="className" type="String">The name of the CSS class to remove.</param> 6289 var e = Function._validateParams(arguments, [ 6290 {name: "className", type: String} 6291 ]); 6292 if (e) throw e; 6293 if (!this._element) throw Error.invalidOperation(Sys.Res.cantBeCalledAfterDispose); 6294 Sys.UI.DomElement.removeCssClass(this._element, className); 6295 }, 6296 toggleCssClass: function Control$toggleCssClass(className) { 6297 /// <summary locid="M:J#Sys.UI.Control.toggleCssClass">Toggles a CSS class on and off on the control.</summary> 6298 /// <param name="className" type="String">The name of the CSS class to toggle.</param> 6299 var e = Function._validateParams(arguments, [ 6300 {name: "className", type: String} 6301 ]); 6302 if (e) throw e; 6303 if (!this._element) throw Error.invalidOperation(Sys.Res.cantBeCalledAfterDispose); 6304 Sys.UI.DomElement.toggleCssClass(this._element, className); 6305 } 6306} 6307$type.registerClass('Sys.UI.Control', Sys.Component); 6308 6309 6310 6311$type = Sys.HistoryEventArgs = function HistoryEventArgs(state) { 6312 /// <summary locid="M:J#Sys.HistoryEventArgs.#ctor"></summary> 6313 /// <param name="state" type="Object"></param> 6314 var e = Function._validateParams(arguments, [ 6315 {name: "state", type: Object} 6316 ]); 6317 if (e) throw e; 6318 Sys.HistoryEventArgs.initializeBase(this); 6319 this._state = state; 6320} 6321$type.prototype = { 6322 get_state: function HistoryEventArgs$get_state() { 6323 /// <value type="Object" locid="P:J#Sys.HistoryEventArgs.state"></value> 6324 if (arguments.length !== 0) throw Error.parameterCount(); 6325 return this._state; 6326 } 6327} 6328$type.registerClass('Sys.HistoryEventArgs', Sys.EventArgs); 6329$type = Sys.Application; 6330$type._currentEntry = ''; 6331$type._initialState = null; 6332$type._state = {}; 6333 6334$prototype = Sys._Application.prototype; 6335$prototype.get_stateString = function _Application$get_stateString() { 6336 /// <summary locid="M:J#Sys._Application.get_stateString"></summary> 6337 if (arguments.length !== 0) throw Error.parameterCount(); 6338 var hash = null; 6339 6340 if (isBrowser("Firefox")) { 6341 var href = window.location.href; 6342 var hashIndex = href.indexOf('#'); 6343 if (hashIndex !== -1) { 6344 hash = href.substring(hashIndex + 1); 6345 } 6346 else { 6347 hash = ""; 6348 } 6349 return hash; 6350 } 6351 else { 6352 hash = window.location.hash; 6353 } 6354 6355 if (hash.length && (hash.charAt(0) === '#')) { 6356 hash = hash.substring(1); 6357 } 6358 6359 return hash; 6360}; 6361 6362$prototype.get_enableHistory = function _Application$get_enableHistory() { 6363 /// <summary locid="M:J#Sys._Application.get_enableHistory"></summary> 6364 if (arguments.length !== 0) throw Error.parameterCount(); 6365 return !!this._enableHistory;
6366}; 6367 6368$prototype.set_enableHistory = function _Application$set_enableHistory(value) { 6369 if (this._initialized && !this._initializing) { 6370 throw Error.invalidOperation(Sys.Res.historyCannotEnableHistory); 6371 } 6372 else if (this._historyEnabledInScriptManager && !value) { 6373 throw Error.invalidOperation(Sys.Res.invalidHistorySettingCombination); 6374 } 6375 this._enableHistory = value; 6376}; 6377 6378$prototype.add_navigate = function _Application$add_navigate(handler) { 6379 /// <summary locid="E:J#Sys.Application.navigate"></summary> 6380 /// <param name="handler" type="Function"></param> 6381 var e = Function._validateParams(arguments, [ 6382 {name: "handler", type: Function} 6383 ]); 6384 if (e) throw e; 6385 this._addHandler("navigate", handler); 6386}; 6387 6388$prototype.remove_navigate = function _Application$remove_navigate(handler) { 6389 /// <summary locid="M:J#Sys._Application.remove_navigate"></summary> 6390 /// <param name="handler" type="Function"></param> 6391 var e = Function._validateParams(arguments, [ 6392 {name: "handler", type: Function} 6393 ]); 6394 if (e) throw e; 6395 this._removeHandler("navigate", handler); 6396}; 6397 6398$prototype.addHistoryPoint = function _Application$addHistoryPoint(state, title) { 6399 /// <summary locid="M:J#Sys.Application.addHistoryPoint"></summary> 6400 /// <param name="state" type="Object">A dictionary of state bits that will be added to the main state to form the global state of the new history point. The state must be a string dictionary. The application is responsible for converting the state bits from and into the relevant types.</param> 6401 /// <param name="title" type="String" optional="true" mayBeNull="true">The title for the new history point.</param> 6402 var e = Function._validateParams(arguments, [ 6403 {name: "state", type: Object}, 6404 {name: "title", type: String, mayBeNull: true, optional: true} 6405 ]); 6406 if (e) throw e; 6407 if (!this._enableHistory) throw Error.invalidOperation(Sys.Res.historyCannotAddHistoryPointWithHistoryDisabled); 6408 for (var n in state) { 6409 var v = state[n]; 6410 var t = typeof(v); 6411 if ((v !== null) && ((t === 'object') || (t === 'function') || (t === 'undefined'))) { 6412 throw Error.argument('state', Sys.Res.stateMustBeStringDictionary); 6413 } 6414 } 6415 this._ensureHistory(); 6416 var initialState = this._state; 6417 for (var key in state) { 6418 var value = state[key]; 6419 if (value === null) { 6420 if (typeof(initialState[key]) !== 'undefined') { 6421 delete initialState[key]; 6422 } 6423 } 6424 else { 6425 initialState[key] = value; 6426 } 6427 } 6428 var entry = this._serializeState(initialState); 6429 this._historyPointIsNew = true; 6430 this._setState(entry, title); 6431 this._raiseNavigate(); 6432}; 6433 6434$prototype.setServerId = function _Application$setServerId(clientId, uniqueId) { 6435 /// <summary locid="M:J#Sys.Application.setServerId"></summary> 6436 /// <param name="clientId" type="String"></param> 6437 /// <param name="uniqueId" type="String"></param> 6438 var e = Function._validateParams(arguments, [ 6439 {name: "clientId", type: String}, 6440 {name: "uniqueId", type: String} 6441 ]); 6442 if (e) throw e; 6443 this._clientId = clientId; 6444 this._uniqueId = uniqueId; 6445}; 6446 6447$prototype.setServerState = function _Application$setServerState(value) { 6448 /// <summary locid="M:J#Sys.Application.setServerState"></summary> 6449 /// <param name="value" type="String"></param> 6450 var e = Function._validateParams(arguments, [ 6451 {name: "value", type: String} 6452 ]); 6453 if (e) throw e; 6454 this._ensureHistory(); 6455 this._state.__s = value; 6456 this._updateHiddenField(value); 6457}; 6458 6459$prototype._deserializeState = function _Application$_deserializeState(entry) { 6460 var result = {}; 6461 entry = entry || ''; 6462 var serverSeparator = entry.indexOf('&&'); 6463 if ((serverSeparator !== -1) && (serverSeparator + 2 < entry.length)) { 6464 result.__s = entry.substr(serverSeparator + 2); 6465 entry = entry.substr(0, serverSeparator); 6466 } 6467 var tokens = entry.split('&'); 6468 for (var i = 0, l = tokens.length; i < l; i++) { 6469 var token = tokens[i]; 6470 var equal = token.indexOf('='); 6471 if ((equal !== -1) && (equal + 1 < token.length)) { 6472 var name = token.substr(0, equal); 6473 var value = token.substr(equal + 1); 6474 result[name] = decodeURIComponent(value); 6475 } 6476 } 6477 return result; 6478}; 6479 6480$prototype._enableHistoryInScriptManager = function _Application$_enableHistoryInScriptManager() { 6481 this._enableHistory = true; 6482 this._historyEnabledInScriptManager = true; 6483}; 6484 6485$prototype._ensureHistory = function _Application$_ensureHistory() { 6486 if (!this._historyInitialized && this._enableHistory) { 6487 if (isBrowser("InternetExplorer") && (Sys.Browser.documentMode < 8)) { 6488 this._historyFrame = Sys.get('#__historyFrame');
6489 if (!this._historyFrame) throw Error.invalidOperation(Sys.Res.historyMissingFrame); 6490 this._ignoreIFrame = true; 6491 } 6492 this._timerHandler = Function.createDelegate(this, this._onIdle); 6493 this._timerCookie = window.setTimeout(this._timerHandler, 100); 6494 6495 var e; 6496 try { 6497 this._initialState = this._deserializeState(this.get_stateString()); 6498 } 6499 catch(e) {} 6500 6501 this._historyInitialized = true; 6502 } 6503}; 6504 6505$prototype._navigate = function _Application$_navigate(entry) { 6506 this._ensureHistory(); 6507 6508 var state = this._deserializeState(entry); 6509 6510 if (this._uniqueId) { 6511 var oldServerEntry = this._state.__s || ''; 6512 var newServerEntry = state.__s || ''; 6513 if (newServerEntry !== oldServerEntry) { 6514 this._updateHiddenField(newServerEntry); 6515 __doPostBack(this._uniqueId, newServerEntry); 6516 this._state = state; 6517 return; 6518 } 6519 } 6520 this._setState(entry); 6521 this._state = state; 6522 this._raiseNavigate(); 6523}; 6524 6525$prototype._onIdle = function _Application$_onIdle() { 6526 delete this._timerCookie; 6527 6528 var entry = this.get_stateString(); 6529 if (entry !== this._currentEntry) { 6530 if (!this._ignoreTimer) { 6531 this._historyPointIsNew = false; 6532 this._navigate(entry); 6533 } 6534 } 6535 else { 6536 this._ignoreTimer = false; 6537 } 6538 this._timerCookie = window.setTimeout(this._timerHandler, 100); 6539}; 6540 6541$prototype._onIFrameLoad = function _Application$_onIFrameLoad(entry) { 6542 this._ensureHistory(); 6543 if (!this._ignoreIFrame) { 6544 this._historyPointIsNew = false; 6545 this._navigate(entry); 6546 } 6547 this._ignoreIFrame = false; 6548}; 6549 6550$prototype._onPageRequestManagerBeginRequest = function _Application$_onPageRequestManagerBeginRequest(sender, args) { 6551 this._ignoreTimer = true; 6552 this._originalTitle = document.title; 6553}; 6554 6555$prototype._onPageRequestManagerEndRequest = function _Application$_onPageRequestManagerEndRequest(sender, args) { 6556 var dataItem = args.get_dataItems()[this._clientId]; 6557 var originalTitle = this._originalTitle; 6558 this._originalTitle = null; 6559 6560 var eventTarget = Sys.get("#__EVENTTARGET"); 6561 if (eventTarget && eventTarget.value === this._uniqueId) { 6562 eventTarget.value = ''; 6563 } 6564 if (typeof(dataItem) !== 'undefined') { 6565 this.setServerState(dataItem); 6566 this._historyPointIsNew = true; 6567 } 6568 else { 6569 this._ignoreTimer = false; 6570 } 6571 var entry = this._serializeState(this._state); 6572 if (entry !== this._currentEntry) { 6573 this._ignoreTimer = true; 6574 if (typeof(originalTitle) === "string") { 6575 if (!isBrowser("InternetExplorer") || Sys.Browser.version > 7) { 6576 var newTitle = document.title; 6577 document.title = originalTitle; 6578 this._setState(entry); 6579 document.title = newTitle; 6580 } 6581 else { 6582 this._setState(entry); 6583 } 6584 this._raiseNavigate(); 6585 } 6586 else { 6587 this._setState(entry); 6588 this._raiseNavigate(); 6589 } 6590 } 6591}; 6592 6593$prototype._raiseNavigate = function _Application$_raiseNavigate() { 6594 var isNew = this._historyPointIsNew; 6595 var stateClone = {}; 6596 for (var key in this._state) { 6597 if (key !== '__s') { 6598 stateClone[key] = this._state[key]; 6599 } 6600 } 6601 var args = new Sys.HistoryEventArgs(stateClone); 6602 Sys.Observer.raiseEvent(this, "navigate", args); 6603 if (!isNew) { 6604 var err; 6605 try { 6606 if (isBrowser("Firefox") && window.location.hash && 6607 (!window.frameElement || window.top.location.hash)) { 6608 (Sys.Browser.version < 3.5) ? 6609 window.history.go(0) : 6610 location.hash = this.get_stateString(); 6611 } 6612 } 6613 catch(err) { 6614 } 6615 } 6616}; 6617 6618$prototype._serializeState = function _Application$_serializeState(state) { 6619 var serialized = []; 6620 for (var key in state) { 6621 var value = state[key]; 6622 if (key === '__s') { 6623 var serverState = value; 6624 } 6625 else { 6626 if (key.indexOf('=') !== -1) throw Error.argument('state', Sys.Res.stateFieldNameInvalid); 6627 serialized.push(key + '=' + encodeURIComponent(value)); 6628 } 6629 } 6630 return serialized.join('&') + (serverState ? '&&' + serverState : ''); 6631};
6632 6633$prototype._setState = function _Application$_setState(entry, title) { 6634 if (this._enableHistory) { 6635 entry = entry || ''; 6636 if (entry !== this._currentEntry) { 6637 if (window.theForm) { 6638 var action = window.theForm.action; 6639 var hashIndex = action.indexOf('#'); 6640 window.theForm.action = ((hashIndex !== -1) ? action.substring(0, hashIndex) : action) + '#' + entry; 6641 } 6642 6643 if (this._historyFrame && this._historyPointIsNew) { 6644 this._ignoreIFrame = true; 6645 var frameDoc = this._historyFrame.contentWindow.document; 6646 frameDoc.open("javascript:'<html></html>'"); 6647 frameDoc.write("<html><head><title>" + (title || document.title) + 6648 "</title><scri" + "pt type=\"text/javascript\">parent.Sys.Application._onIFrameLoad(" + 6649 Sys.Serialization.JavaScriptSerializer.serialize(entry) + 6650 ");</scri" + "pt></head><body></body></html>"); 6651 frameDoc.close(); 6652 } 6653 this._ignoreTimer = false; 6654 this._currentEntry = entry; 6655 if (this._historyFrame || this._historyPointIsNew) { 6656 var currentHash = this.get_stateString(); 6657 if (entry !== currentHash) { 6658 var loc = document.location; 6659 if (loc.href.length - loc.hash.length + entry.length > 2048) { 6660 throw Error.invalidOperation(String.format(Sys.Res.urlTooLong, 2048)); 6661 } 6662 window.location.hash = entry; 6663 this._currentEntry = this.get_stateString(); 6664 if ((typeof(title) !== 'undefined') && (title !== null)) { 6665 document.title = title; 6666 } 6667 } 6668 } 6669 this._historyPointIsNew = false; 6670 } 6671 } 6672}; 6673 6674$prototype._updateHiddenField = function _Application$_updateHiddenField(value) { 6675 if (this._clientId) { 6676 var serverStateField = document.getElementById(this._clientId); 6677 if (serverStateField) { 6678 serverStateField.value = value; 6679 } 6680 } 6681}; 6682 6683 6684 6685if (!window.XMLHttpRequest) { 6686 window.XMLHttpRequest = function window$XMLHttpRequest() { 6687 var ex, progIDs = [ 'Msxml2.XMLHTTP.3.0', 'Msxml2.XMLHTTP' ]; 6688 for (var i = 0, l = progIDs.length; i < l; i++) { 6689 try { 6690 return new ActiveXObject(progIDs[i]); 6691 } 6692 catch (ex) { 6693 } 6694 } 6695 return null; 6696 } 6697} 6698 6699Type.registerNamespace('Sys.Net'); 6700 6701$type = Sys.Net.WebRequestExecutor = function WebRequestExecutor() { 6702 /// <summary locid="M:J#Sys.Net.WebRequestExecutor.#ctor">Base class for WebRequestExecutors which handle the actual execution of a WebRequest</summary> 6703 if (arguments.length !== 0) throw Error.parameterCount(); 6704 this._webRequest = null; 6705 this._resultObject = null; 6706} 6707 6708 6709$type.prototype = { 6710 get_started: function WebRequestExecutor$get_started() { 6711 /// <value type="Boolean" locid="P:J#Sys.Net.WebRequestExecutor.started"></value> 6712 if (arguments.length !== 0) throw Error.parameterCount(); 6713 throw Error.notImplemented(); 6714 }, 6715 get_responseAvailable: function WebRequestExecutor$get_responseAvailable() { 6716 /// <value type="Boolean" locid="P:J#Sys.Net.WebRequestExecutor.responseAvailable"></value> 6717 if (arguments.length !== 0) throw Error.parameterCount(); 6718 throw Error.notImplemented(); 6719 }, 6720 get_timedOut: function WebRequestExecutor$get_timedOut() { 6721 /// <value type="Boolean" locid="P:J#Sys.Net.WebRequestExecutor.timedOut"></value> 6722 if (arguments.length !== 0) throw Error.parameterCount(); 6723 throw Error.notImplemented(); 6724 }, 6725 get_aborted: function WebRequestExecutor$get_aborted() { 6726 /// <value type="Boolean" locid="P:J#Sys.Net.WebRequestExecutor.aborted"></value> 6727 if (arguments.length !== 0) throw Error.parameterCount(); 6728 throw Error.notImplemented(); 6729 }, 6730 get_responseData: function WebRequestExecutor$get_responseData() { 6731 /// <value type="String" locid="P:J#Sys.Net.WebRequestExecutor.responseData"></value> 6732 if (arguments.length !== 0) throw Error.parameterCount(); 6733 throw Error.notImplemented(); 6734 }, 6735 get_statusCode: function WebRequestExecutor$get_statusCode() { 6736 /// <value type="Number" locid="P:J#Sys.Net.WebRequestExecutor.statusCode"></value> 6737 if (arguments.length !== 0) throw Error.parameterCount(); 6738 throw Error.notImplemented(); 6739 }, 6740 get_statusText: function WebRequestExecutor$get_statusText() { 6741 /// <value type="String" locid="P:J#Sys.Net.WebRequestExecutor.statusText"></value> 6742 if (arguments.length !== 0) throw Error.parameterCount(); 6743 throw Error.notImplemented(); 6744 }, 6745 get_xml: function WebRequestExecutor$get_xml() { 6746 /// <value locid="P:J#Sys.Net.WebRequestExecutor.xml"></value> 6747 if (arguments.length !== 0) throw Error.parameterCount(); 6748 throw Error.notImplemented(); 6749 }, 6750 executeRequest: function WebRequestExecutor$executeRequest() { 6751 /// <summary locid="M:J#Sys.Net.WebRequestExecutor.executeRequest">
6751Begins execution of the request.</summary> 6752 if (arguments.length !== 0) throw Error.parameterCount(); 6753 throw Error.notImplemented(); 6754 }, 6755 abort: function WebRequestExecutor$abort() { 6756 /// <summary locid="M:J#Sys.Net.WebRequestExecutor.abort">Aborts the request.</summary> 6757 if (arguments.length !== 0) throw Error.parameterCount(); 6758 throw Error.notImplemented(); 6759 }, 6760 getAllResponseHeaders: function WebRequestExecutor$getAllResponseHeaders() { 6761 /// <summary locid="M:J#Sys.Net.WebRequestExecutor.getAllResponseHeaders">Returns all the responses header.</summary> 6762 if (arguments.length !== 0) throw Error.parameterCount(); 6763 throw Error.notImplemented(); 6764 }, 6765 getResponseHeader: function WebRequestExecutor$getResponseHeader(header) { 6766 /// <summary locid="M:J#Sys.Net.WebRequestExecutor.getResponseHeader">Returns a response header.</summary> 6767 /// <param name="header" type="String">The requested header.</param> 6768 var e = Function._validateParams(arguments, [ 6769 {name: "header", type: String} 6770 ]); 6771 if (e) throw e; 6772 throw Error.notImplemented(); 6773 }, 6774 get_webRequest: function WebRequestExecutor$get_webRequest() { 6775 /// <value type="Sys.Net.WebRequest" locid="P:J#Sys.Net.WebRequestExecutor.webRequest"></value> 6776 if (arguments.length !== 0) throw Error.parameterCount(); 6777 return this._webRequest; 6778 }, 6779 _set_webRequest: function WebRequestExecutor$_set_webRequest(value) { 6780 if (this.get_started()) { 6781 throw Error.invalidOperation(String.format(Sys.Res.cannotCallOnceStarted, 'set_webRequest')); 6782 } 6783 this._webRequest = value; 6784 }, 6785 get_object: function WebRequestExecutor$get_object() { 6786 /// <value locid="P:J#Sys.Net.WebRequestExecutor.object">The JSON eval'd response.</value> 6787 if (arguments.length !== 0) throw Error.parameterCount(); 6788 var result = this._resultObject; 6789 if (!result) { 6790 this._resultObject = result = Sys.Serialization.JavaScriptSerializer.deserialize(this.get_responseData()); 6791 } 6792 return result; 6793 } 6794} 6795$type.registerClass('Sys.Net.WebRequestExecutor'); 6796Sys.Net.XMLDOM = function XMLDOM(markup) { 6797 /// <summary locid="M:J#Sys.Net.XMLDOM.#ctor">Creates an XML document from an XML string.</summary> 6798 /// <param name="markup" type="String">The XML string to parse.</param> 6799 var e = Function._validateParams(arguments, [ 6800 { name: "markup", type: String } 6801 ]); 6802 if (e) throw e; 6803 if (!window.DOMParser) { 6804 var ex, progIDs = ['Msxml2.DOMDocument.3.0', 'Msxml2.DOMDocument']; 6805 for (var i = 0, l = progIDs.length; i < l; i++) { 6806 try { 6807 var xmlDOM = new ActiveXObject(progIDs[i]); 6808 xmlDOM.async = false; 6809 xmlDOM.loadXML(markup); 6810 xmlDOM.setProperty('SelectionLanguage', 'XPath'); 6811 return xmlDOM; 6812 } 6813 catch (ex) { 6814 } 6815 } 6816 } 6817 else { 6818 try { 6819 var domParser = new window.DOMParser(); 6820 return domParser.parseFromString(markup, 'text/xml'); 6821 } 6822 catch (ex) { 6823 } 6824 } 6825 return null; 6826} 6827 6828$type = Sys.Net.XMLHttpExecutor = function XMLHttpExecutor() { 6829 /// <summary locid="M:J#Sys.Net.XMLHttpExecutor.#ctor">XMLHttpExecutor</summary> 6830 if (arguments.length !== 0) throw Error.parameterCount(); 6831 6832 Sys.Net.XMLHttpExecutor.initializeBase(this); 6833 6834 var _this = this; 6835 6836 this._onReadyStateChange = (function () { 6837 /* 6838 readyState values: 6839 0 = uninitialized 6840 1 = loading 6841 2 = loaded 6842 3 = interactive 6843 4 = complete 6844 */ 6845 if (_this._xmlHttpRequest.readyState === 4 /*complete*/) { 6846 try { 6847 if (typeof (_this._xmlHttpRequest.status) === "undefined") { 6848 return; 6849 } 6850 } 6851 catch (ex) { 6852 return; 6853 } 6854 6855 _this._clearTimer(); 6856 _this._responseAvailable = true; 6857 _this._webRequest.completed(Sys.EventArgs.Empty); 6858 if (_this._xmlHttpRequest) { 6859 _this._xmlHttpRequest.onreadystatechange = Function.emptyMethod; 6860 _this._xmlHttpRequest = null; 6861 } 6862 } 6863 });
6864 6865 this._clearTimer = (function () { 6866 if (_this._timer) { 6867 window.clearTimeout(_this._timer); 6868 _this._timer = null; 6869 } 6870 }); 6871 6872 this._onTimeout = (function () { 6873 if (!_this._responseAvailable) { 6874 _this._clearTimer(); 6875 _this._timedOut = true; 6876 var xhr = _this._xmlHttpRequest; 6877 xhr.onreadystatechange = Function.emptyMethod; 6878 xhr.abort(); 6879 _this._webRequest.completed(Sys.EventArgs.Empty); 6880 _this._xmlHttpRequest = null; 6881 } 6882 }); 6883 6884} 6885 6886$type.prototype = { 6887 6888 get_timedOut: function XMLHttpExecutor$get_timedOut() { 6889 /// <value type="Boolean" locid="P:J#Sys.Net.XMLHttpExecutor.timedOut">True if the executor has timed out.</value> 6890 if (arguments.length !== 0) throw Error.parameterCount(); 6891 return !!this._timedOut; 6892 }, 6893 6894 get_started: function XMLHttpExecutor$get_started() { 6895 /// <value type="Boolean" locid="P:J#Sys.Net.XMLHttpExecutor.started">True if the executor has started.</value> 6896 if (arguments.length !== 0) throw Error.parameterCount(); 6897 return !!this._started; 6898 }, 6899 6900 get_responseAvailable: function XMLHttpExecutor$get_responseAvailable() { 6901 /// <value type="Boolean" locid="P:J#Sys.Net.XMLHttpExecutor.responseAvailable">True if a response is available.</value> 6902 if (arguments.length !== 0) throw Error.parameterCount(); 6903 return !!this._responseAvailable; 6904 }, 6905 6906 get_aborted: function XMLHttpExecutor$get_aborted() { 6907 /// <value type="Boolean" locid="P:J#Sys.Net.XMLHttpExecutor.aborted">True if the executor has been aborted.</value> 6908 if (arguments.length !== 0) throw Error.parameterCount(); 6909 return !!this._aborted; 6910 }, 6911 6912 executeRequest: function XMLHttpExecutor$executeRequest() { 6913 /// <summary locid="M:J#Sys.Net.XMLHttpExecutor.executeRequest">Invokes the request.</summary> 6914 if (arguments.length === 1 && arguments[0].toString() !== '[object FormData]') { 6915 throw Error.argumentType(); 6916 } 6917 else if (arguments.length > 1) { 6918 throw Error.parameterCount(); 6919 } 6920 var isFileUploadRequest = false; 6921 if (arguments.length === 1 && arguments[0].toString() === '[object FormData]') { 6922 isFileUploadRequest = true; 6923 } 6924 var request = this.get_webRequest(); 6925 this._webRequest = request; 6926 6927 if (this._started) { 6928 throw Error.invalidOperation(String.format(Sys.Res.cannotCallOnceStarted, 'executeRequest')); 6929 } 6930 if (!this._webRequest) { 6931 throw Error.invalidOperation(Sys.Res.nullWebRequest); 6932 } 6933 6934 var body = request.get_body(); 6935 var headers = request.get_headers(); 6936 var xhr = new XMLHttpRequest(); 6937 this._xmlHttpRequest = xhr; 6938 xhr.onreadystatechange = this._onReadyStateChange; 6939 6940 if (isFileUploadRequest && xhr.upload) { 6941 xhr.upload.addEventListener('load', this.bind(this.load, this), false); 6942 xhr.upload.addEventListener('progress', this.bind(this.progress, this), false); 6943 xhr.upload.addEventListener('error', this.bind(this.error, this), false); 6944 xhr.upload.addEventListener('abort', this.bind(this.uploadAbort, this), false); 6945 } 6946 6947 var verb = request.get_httpVerb(); 6948 xhr.open(verb, request.getResolvedUrl(), true /*async*/); 6949 xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest"); 6950 if (headers) { 6951 for (var header in headers) { 6952 var val = headers[header]; 6953 if (typeof (val) !== "function") 6954 xhr.setRequestHeader(header, val); 6955 } 6956 } 6957 6958 if (verb.toLowerCase() === "post") { 6959 if (!isFileUploadRequest) { 6960 if ((headers === null) || !headers['Content-Type']) { 6961 xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8'); 6962 } 6963 } 6964 6965 if (!body) { 6966 body = ""; 6967 } 6968 } 6969 6970 var timeout = request.get_timeout(); 6971 if (timeout > 0) { 6972 this._timer = window.setTimeout(Function.createDelegate(this, this._onTimeout), timeout); 6973 } 6974 6975 if (isFileUploadRequest) { 6976 xhr.send(arguments[0]); 6977 } 6978 else { 6979 xhr.send(body); 6980 } 6981 this._started = true; 6982 }, 6983 6984 getResponseHeader: function XMLHttpExecutor$getResponseHeader(header) { 6985 /// <summary locid="M:J#Sys.Net.XMLHttpExecutor.getResponseHeader">Returns a response header.</summary> 6986 /// <param name="header" type="String">The requested header.</param> 6987 /// <returns type="String">The value of the header.</returns> 6988 var e = Function._validateParams(arguments, [ 6989 { name: "header", type: String } 6990 ]); 6991 if (e) throw e; 6992 if (!this._responseAvailable) {
6993 throw Error.invalidOperation(String.format(Sys.Res.cannotCallBeforeResponse, 'getResponseHeader')); 6994 } 6995 if (!this._xmlHttpRequest) { 6996 throw Error.invalidOperation(String.format(Sys.Res.cannotCallOutsideHandler, 'getResponseHeader')); 6997 } 6998 6999 var er, result; 7000 try { 7001 result = this._xmlHttpRequest.getResponseHeader(header); 7002 } catch (er) { 7003 } 7004 if (!result) result = ""; 7005 return result; 7006 }, 7007 7008 getAllResponseHeaders: function XMLHttpExecutor$getAllResponseHeaders() { 7009 /// <summary locid="M:J#Sys.Net.XMLHttpExecutor.getAllResponseHeaders">Returns all the responses header.</summary> 7010 /// <returns type="String">The text of all the headers.</returns> 7011 if (arguments.length !== 0) throw Error.parameterCount(); 7012 if (!this._responseAvailable) { 7013 throw Error.invalidOperation(String.format(Sys.Res.cannotCallBeforeResponse, 'getAllResponseHeaders')); 7014 } 7015 if (!this._xmlHttpRequest) { 7016 throw Error.invalidOperation(String.format(Sys.Res.cannotCallOutsideHandler, 'getAllResponseHeaders')); 7017 } 7018 7019 return this._xmlHttpRequest.getAllResponseHeaders(); 7020 }, 7021 7022 get_responseData: function XMLHttpExecutor$get_responseData() { 7023 /// <value type="String" locid="P:J#Sys.Net.XMLHttpExecutor.responseData">The text of the response.</value> 7024 if (arguments.length !== 0) throw Error.parameterCount(); 7025 if (!this._responseAvailable) { 7026 throw Error.invalidOperation(String.format(Sys.Res.cannotCallBeforeResponse, 'get_responseData')); 7027 } 7028 if (!this._xmlHttpRequest) { 7029 throw Error.invalidOperation(String.format(Sys.Res.cannotCallOutsideHandler, 'get_responseData')); 7030 } 7031 7032 return this._xmlHttpRequest.responseText; 7033 }, 7034 7035 get_statusCode: function XMLHttpExecutor$get_statusCode() { 7036 /// <value type="Number" locid="P:J#Sys.Net.XMLHttpExecutor.statusCode">The status code of the response.</value> 7037 if (arguments.length !== 0) throw Error.parameterCount(); 7038 if (!this._responseAvailable) { 7039 throw Error.invalidOperation(String.format(Sys.Res.cannotCallBeforeResponse, 'get_statusCode')); 7040 } 7041 if (!this._xmlHttpRequest) { 7042 throw Error.invalidOperation(String.format(Sys.Res.cannotCallOutsideHandler, 'get_statusCode')); 7043 } 7044 var ex, result = 0; 7045 try { 7046 result = this._xmlHttpRequest.status; 7047 } 7048 catch (ex) { 7049 } 7050 return result; 7051 }, 7052 7053 get_statusText: function XMLHttpExecutor$get_statusText() { 7054 /// <value type="String" locid="P:J#Sys.Net.XMLHttpExecutor.statusText">The status text of the repsonse.</value> 7055 if (arguments.length !== 0) throw Error.parameterCount(); 7056 if (!this._responseAvailable) { 7057 throw Error.invalidOperation(String.format(Sys.Res.cannotCallBeforeResponse, 'get_statusText')); 7058 } 7059 if (!this._xmlHttpRequest) { 7060 throw Error.invalidOperation(String.format(Sys.Res.cannotCallOutsideHandler, 'get_statusText')); 7061 } 7062 7063 return this._xmlHttpRequest.statusText; 7064 }, 7065 7066 get_xml: function XMLHttpExecutor$get_xml() { 7067 /// <value locid="P:J#Sys.Net.XMLHttpExecutor.xml">The response in xml format.</value> 7068 if (arguments.length !== 0) throw Error.parameterCount(); 7069 if (!this._responseAvailable) { 7070 throw Error.invalidOperation(String.format(Sys.Res.cannotCallBeforeResponse, 'get_xml')); 7071 } 7072 if (!this._xmlHttpRequest) { 7073 throw Error.invalidOperation(String.format(Sys.Res.cannotCallOutsideHandler, 'get_xml')); 7074 } 7075 var xhr = this._xmlHttpRequest; 7076 var xml = xhr.responseXML; 7077 if (!xml || !xml.documentElement) { 7078 7079 xml = Sys.Net.XMLDOM(xhr.responseText); 7080 7081 if (!xml || !xml.documentElement) 7082 return null; 7083 } 7084 else if (navigator.userAgent.indexOf('MSIE') !== -1) { 7085 xml.setProperty('SelectionLanguage', 'XPath'); 7086 } 7087 7088 if (xml.documentElement.namespaceURI === "http://www.mozilla.org/newlayout/xml/parsererror.xml" && 7089 xml.documentElement.tagName === "parsererror") { 7090 return null; 7091 } 7092 7093 if (xml.documentElement.firstChild && xml.documentElement.firstChild.tagName === "parsererror") { 7094 return null; 7095 } 7096 7097 return xml; 7098 }, 7099 7100 abort: function XMLHttpExecutor$abort() { 7101 /// <summary locid="M:J#Sys.Net.XMLHttpExecutor.abort">Aborts the request.</summary> 7102 if (arguments.length !== 0) throw Error.parameterCount(); 7103 if (!this._started) {
7104 throw Error.invalidOperation(Sys.Res.cannotAbortBeforeStart); 7105 } 7106 7107 if (this._aborted || this._responseAvailable || this._timedOut) 7108 return; 7109 7110 this._aborted = true; 7111 7112 this._clearTimer(); 7113 var xhr = this._xmlHttpRequest; 7114 if (xhr && !this._responseAvailable) { 7115 7116 xhr.onreadystatechange = Function.emptyMethod; 7117 xhr.abort(); 7118 7119 this._xmlHttpRequest = null; 7120 7121 this._webRequest.completed(Sys.EventArgs.Empty); 7122 } 7123 }, 7124 7125 bind: function (fn, bind) { 7126 return function () { 7127 fn.apply(bind, arguments); 7128 }; 7129 }, 7130 7131 add_load: function XMLHttpExecutor$add_load(handler) { 7132 /// <summary locid="E:J#Sys.Net.XMLHttpExecutor.load"></summary> 7133 var e = Function._validateParams(arguments, [{ name: "handler", type: Function}]); 7134 if (e) throw e; 7135 Sys.Observer.addEventHandler(this, "load", handler); 7136 }, 7137 7138 remove_load: function XMLHttpExecutor$remove_load(handler) { 7139 var e = Function._validateParams(arguments, [{ name: "handler", type: Function}]); 7140 if (e) throw e; 7141 Sys.Observer.removeEventHandler(this, "load", handler); 7142 }, 7143 7144 load: function XMLHttpExecutor$load(eventArgs) { 7145 /// <summary locid="M:J#Sys.Net.XMLHttpExecutor.load">The load method should be called when the request is completed.</summary> 7146 /// <param name="eventArgs" type="XMLHttpRequestProgressEvent">The event args to raise the event with.</param> 7147 var e; 7148 try { 7149 e = Function._validateParams(arguments, [ 7150 { name: "eventArgs", type: XMLHttpRequestProgressEvent } 7151 ]); 7152 } 7153 catch (ex) { 7154 e = Function._validateParams(arguments, [ 7155 { name: "eventArgs", type: Object } 7156 ]); 7157 } 7158 if (e) throw e; 7159 function raise(source, sender, eventName) { 7160 var handler = Sys.Observer._getContext(source, true).events.getHandler(eventName); 7161 if (handler) { 7162 handler(sender, eventArgs); 7163 } 7164 } 7165 7166 raise(this, this, "load"); 7167 Sys.Observer.clearEventHandlers(this, "load"); 7168 }, 7169 7170 add_progress: function XMLHttpExecutor$add_progress(handler) { 7171 /// <summary locid="E:J#Sys.Net.XMLHttpExecutor.progress"></summary> 7172 var e = Function._validateParams(arguments, [{ name: "handler", type: Function}]); 7173 if (e) throw e; 7174 Sys.Observer.addEventHandler(this, "progress", handler); 7175 }, 7176 7177 remove_progress: function XMLHttpExecutor$remove_progress(handler) { 7178 var e = Function._validateParams(arguments, [{ name: "handler", type: Function}]); 7179 if (e) throw e; 7180 Sys.Observer.removeEventHandler(this, "progress", handler); 7181 }, 7182 7183 progress: function XMLHttpExecutor$progress(eventArgs) { 7184 /// <summary locid="M:J#Sys.Net.XMLHttpExecutor.progress">The progress method should be called to know the progess of uploading file.</summary> 7185 /// <param name="eventArgs" type="Sys.EventArgs">The event args to raise the event with.</param> 7186 var e; 7187 try { 7188 e = Function._validateParams(arguments, [ 7189 { name: "eventArgs", type: XMLHttpRequestProgressEvent } 7190 ]); 7191 } 7192 catch (ex) { 7193 e = Function._validateParams(arguments, [ 7194 { name: "eventArgs", type: Object } 7195 ]); 7196 } 7197 if (e) throw e; 7198 function raise(source, sender, eventName) { 7199 var handler = Sys.Observer._getContext(source, true).events.getHandler(eventName); 7200 if (handler) { 7201 handler(sender, eventArgs); 7202 } 7203 } 7204 raise(this, this, "progress"); 7205 }, 7206 7207 add_error: function XMLHttpExecutor$add_error(handler) { 7208 /// <summary locid="E:J#Sys.Net.XMLHttpExecutor.error"></summary> 7209 var e = Function._validateParams(arguments, [{ name: "handler", type: Function}]); 7210 if (e) throw e; 7211 Sys.Observer.addEventHandler(this, "error", handler); 7212 }, 7213 7214 remove_error: function XMLHttpExecutor$remove_error(handler) { 7215 var e = Function._validateParams(arguments, [{ name: "handler", type: Function}]); 7216 if (e) throw e; 7217 Sys.Observer.removeEventHandler(this, "error", handler); 7218 }, 7219 7220 error: function XMLHttpExecutor$error(eventArgs) { 7221 /// <summary locid="M:J#Sys.Net.XMLHttpExecutor.error">The error method is called when an error occurs in the request.</summary> 7222 /// <param name="eventArgs" type="XMLHttpRequestProgressEvent">The event args to raise the event with.</param> 7223 try { 7224 var e = Function._validateParams(arguments, [ 7225 { name: "eventArgs", type: XMLHttpRequestProgressEvent } 7226 ]); 7227 } 7228 catch (ex) { 7229 e = Function._validateParams(arguments, [ 7230 { name: "eventArgs", type: Object } 7231 ]); 7232 } 7233 if (e) throw e; 7234 function raise(source, sender, eventName) { 7235 var handler = Sys.Observer._getContext(source, true).events.getHandler(eventName); 7236 if (handler) { 7237 handler(sender, eventArgs); 7238 } 7239 } 7240 raise(this, this, "error"); 7241 Sys.Observer.clearEventHandlers(this, "error"); 7242 }, 7243 7244 add_uploadAbort: function XMLHttpExecutor$add_uploadAbort(handler) { 7245 /// <summary locid="E:J#Sys.Net.XMLHttpExecutor.uploadAbort"></summary> 7246 var e = Function._validateParams(arguments, [{ name: "handler", type: Function}]); 7247 if (e) throw e; 7248 Sys.Observer.addEventHandler(this, "uploadAbort", handler); 7249 }, 7250 7251 remove_uploadAbort: function XMLHttpExecutor$remove_uploadAbort(handler) { 7252 var e = Function._validateParams(arguments, [{ name: "handler", type: Function}]); 7253 if (e) throw e; 7254 Sys.Observer.removeEventHandler(this, "uploadAbort", handler); 7255 }, 7256 7257 uploadAbort: function XMLHttpExecutor$uploadAbort(eventArgs) { 7258 /// <summary locid="M:J#Sys.Net.XMLHttpExecutor.uploadAbort">The uploadAbort method is called when upload file request is aborted.</summary> 7259 /// <param name="eventArgs" type="XMLHttpRequestProgressEvent">The event args to raise the event with.</param> 7260 try { 7261 var e = Function._validateParams(arguments, [ 7262 { name: "eventArgs", type: XMLHttpRequestProgressEvent } 7263 ]); 7264 } 7265 catch (ex) { 7266 e = Function._validateParams(arguments, [ 7267 { name: "eventArgs", type: Object } 7268 ]); 7269 } 7270 if (e) throw e; 7271 function raise(source, sender, eventName) { 7272 var handler = Sys.Observer._getContext(source, true).events.getHandler(eventName); 7273 if (handler) { 7274 handler(sender, eventArgs); 7275 } 7276 } 7277 raise(this, this, "uploadAbort"); 7278 Sys.Observer.clearEventHandlers(this, "uploadAbort"); 7279 } 7280} 7281$type.registerClass('Sys.Net.XMLHttpExecutor', Sys.Net.WebRequestExecutor); 7282$type = Sys.Net._WebRequestManager = function _WebRequestManager() { 7283 /// <summary locid="P:J#Sys.Net.WebRequestManager.#ctor"></summary> 7284 if (arguments.length !== 0) throw Error.parameterCount(); 7285 this._defaultExecutorType = "Sys.Net.XMLHttpExecutor"; 7286} 7287 7288$type.prototype = { 7289 add_invokingRequest: function _WebRequestManager$add_invokingRequest(handler) { 7290 /// <summary locid="E:J#Sys.Net.WebRequestManager.invokingRequest"></summary> 7291 var e = Function._validateParams(arguments, [{name: "handler", type: Function}]); 7292 if (e) throw e; 7293 Sys.Observer.addEventHandler(this, "invokingRequest", handler); 7294 }, 7295 remove_invokingRequest: function _WebRequestManager$remove_invokingRequest(handler) { 7296 var e = Function._validateParams(arguments, [{name: "handler", type: Function}]); 7297 if (e) throw e; 7298 Sys.Observer.removeEventHandler(this, "invokingRequest", handler); 7299 }, 7300 7301 add_completedRequest: function _WebRequestManager$add_completedRequest(handler) { 7302 /// <summary locid="E:J#Sys.Net.WebRequestManager.completedRequest"></summary> 7303 var e = Function._validateParams(arguments, [{name: "handler", type: Function}]); 7304 if (e) throw e; 7305 Sys.Observer.addEventHandler(this, "completedRequest", handler); 7306 }, 7307 remove_completedRequest: function _WebRequestManager$remove_completedRequest(handler) { 7308 var e = Function._validateParams(arguments, [{name: "handler", type: Function}]); 7309 if (e) throw e; 7310 Sys.Observer.removeEventHandler(this, "completedRequest", handler); 7311 }, 7312 get_defaultTimeout: function _WebRequestManager$get_defaultTimeout() { 7313 /// <value type="Number" locid="P:J#Sys.Net.WebRequestManager.defaultTimeout">The default timeout for requests in milliseconds.</value> 7314 if (arguments.length !== 0) throw Error.parameterCount(); 7315 return this._defaultTimeout || 0; 7316 }, 7317 set_defaultTimeout: function _WebRequestManager$set_defaultTimeout(value) { 7318 var e = Function._validateParams(arguments, [{name: "value", type: Number}]); 7319 if (e) throw e; 7320 if (value < 0) { 7321 throw Error.argumentOutOfRange("value", value, Sys.Res.invalidTimeout); 7322 } 7323 7324 this._defaultTimeout = value; 7325 }, 7326 7327 get_defaultExecutorType: function _WebRequestManager$get_defaultExecutorType() { 7328 /// <value type="String" locid="P:J#Sys.Net.WebRequestManager.defaultExecutorType">The default executor type name.</value> 7329 if (arguments.length !== 0) throw Error.parameterCount(); 7330 return this._defaultExecutorType; 7331 }, 7332 set_defaultExecutorType: function _WebRequestManager$set_defaultExecutorType(value) { 7333 var e = Function._validateParams(arguments, [{name: "value", type: String}]); 7334 if (e) throw e; 7335 this._defaultExecutorType = value; 7336 }, 7337 7338 executeRequest: function _WebRequestManager$executeRequest(webRequest) { 7339 /// <summary locid="M:J#Sys.Net.WebRequestManager.executeRequest">Executes a request.</summary> 7340 /// <param name="webRequest" type="Sys.Net.WebRequest">The webRequest to execute.</param> 7341 var e = Function._validateParams(arguments, [
7342 {name: "webRequest", type: Sys.Net.WebRequest} 7343 ]); 7344 if (e) throw e; 7345 var executor = webRequest.get_executor(); 7346 if (!executor) { 7347 var er, failed; 7348 try { 7349 var executorType = window.eval(this._defaultExecutorType); 7350 executor = new executorType(); 7351 } 7352 catch (er) { 7353 failed = true; 7354 } 7355 7356 if (failed || !Sys.Net.WebRequestExecutor.isInstanceOfType(executor) || !executor) { 7357 throw Error.argument("defaultExecutorType", String.format(Sys.Res.invalidExecutorType, this._defaultExecutorType)); 7358 } 7359 7360 webRequest.set_executor(executor); 7361 } 7362 7363 if (!executor.get_aborted()) { 7364 var evArgs = new Sys.Net.NetworkRequestEventArgs(webRequest); 7365 Sys.Observer.raiseEvent(this, "invokingRequest", evArgs); 7366 if (!evArgs.get_cancel()) { 7367 executor.executeRequest(); 7368 } 7369 } 7370 } 7371} 7372 7373$type.registerClass('Sys.Net._WebRequestManager'); 7374 7375Sys.Net.WebRequestManager = new Sys.Net._WebRequestManager(); 7376$type = Sys.Net.NetworkRequestEventArgs = function NetworkRequestEventArgs(webRequest) { 7377 /// <summary locid="M:J#Sys.Net.NetworkRequestEventArgs.#ctor">This class is raised by the WebRequestManager when a WebRequest is about to be executed.</summary> 7378 /// <param name="webRequest" type="Sys.Net.WebRequest">The identifier for the event.</param> 7379 var e = Function._validateParams(arguments, [ 7380 {name: "webRequest", type: Sys.Net.WebRequest} 7381 ]); 7382 if (e) throw e; 7383 Sys.Net.NetworkRequestEventArgs.initializeBase(this); 7384 this._webRequest = webRequest; 7385} 7386 7387$type.prototype = { 7388 get_webRequest: function NetworkRequestEventArgs$get_webRequest() { 7389 /// <value type="Sys.Net.WebRequest" locid="P:J#Sys.Net.NetworkRequestEventArgs.webRequest">The request about to be executed.</value> 7390 if (arguments.length !== 0) throw Error.parameterCount(); 7391 return this._webRequest; 7392 } 7393} 7394 7395$type.registerClass('Sys.Net.NetworkRequestEventArgs', Sys.CancelEventArgs); 7396$type = Sys.Net.WebRequest = function WebRequest() { 7397 /// <summary locid="M:J#Sys.Net.WebRequest.#ctor">WebRequest class</summary> 7398 if (arguments.length !== 0) throw Error.parameterCount(); 7399 this._url = ""; 7400 this._headers = { }; 7401 this._body = null; 7402 this._userContext = null; 7403 this._httpVerb = null; 7404} 7405 7406$type.prototype = { 7407 add_completed: function WebRequest$add_completed(handler) { 7408 /// <summary locid="E:J#Sys.Net.WebRequest.completed"></summary> 7409 var e = Function._validateParams(arguments, [{name: "handler", type: Function}]); 7410 if (e) throw e; 7411 Sys.Observer.addEventHandler(this, "completed", handler); 7412 }, 7413 remove_completed: function WebRequest$remove_completed(handler) { 7414 var e = Function._validateParams(arguments, [{name: "handler", type: Function}]); 7415 if (e) throw e; 7416 Sys.Observer.removeEventHandler(this, "completed", handler); 7417 }, 7418 7419 completed: function WebRequest$completed(eventArgs) { 7420 /// <summary locid="M:J#Sys.Net.WebRequest.completed">The completed method should be called when the request is completed.</summary> 7421 /// <param name="eventArgs" type="Sys.EventArgs">The event args to raise the event with.</param> 7422 var e = Function._validateParams(arguments, [ 7423 {name: "eventArgs", type: Sys.EventArgs} 7424 ]); 7425 if (e) throw e; 7426 function raise(source, sender, eventName) { 7427 var handler = Sys.Observer._getContext(source, true).events.getHandler(eventName); 7428 if (handler) { 7429 handler(sender, eventArgs); 7430 } 7431 } 7432 raise(Sys.Net.WebRequestManager, this._executor, "completedRequest"); 7433 raise(this, this._executor, "completed"); 7434 Sys.Observer.clearEventHandlers(this, "completed"); 7435 }, 7436 7437 get_url: function WebRequest$get_url() { 7438 /// <value type="String" locid="P:J#Sys.Net.WebRequest.url">The url.</value> 7439 if (arguments.length !== 0) throw Error.parameterCount(); 7440 return this._url; 7441 },
7442 set_url: function WebRequest$set_url(value) { 7443 var e = Function._validateParams(arguments, [{name: "value", type: String}]); 7444 if (e) throw e; 7445 this._url = value; 7446 }, 7447 7448 get_headers: function WebRequest$get_headers() { 7449 /// <value locid="P:J#Sys.Net.WebRequest.headers">The headers dictionary for the request.</value> 7450 if (arguments.length !== 0) throw Error.parameterCount(); 7451 return this._headers; 7452 }, 7453 7454 get_httpVerb: function WebRequest$get_httpVerb() { 7455 /// <value type="String" locid="P:J#Sys.Net.WebRequest.httpVerb">The httpVerb for the request.</value> 7456 if (arguments.length !== 0) throw Error.parameterCount(); 7457 if (this._httpVerb === null) { 7458 if (this._body === null) { 7459 return "GET"; 7460 } 7461 return "POST"; 7462 } 7463 return this._httpVerb; 7464 }, 7465 set_httpVerb: function WebRequest$set_httpVerb(value) { 7466 var e = Function._validateParams(arguments, [{name: "value", type: String}]); 7467 if (e) throw e; 7468 if (value.length === 0) { 7469 throw Error.argument('value', Sys.Res.invalidHttpVerb); 7470 } 7471 this._httpVerb = value; 7472 }, 7473 7474 get_body: function WebRequest$get_body() { 7475 /// <value mayBeNull="true" locid="P:J#Sys.Net.WebRequest.body">The body of the request.</value> 7476 if (arguments.length !== 0) throw Error.parameterCount(); 7477 return this._body; 7478 }, 7479 set_body: function WebRequest$set_body(value) { 7480 var e = Function._validateParams(arguments, [{name: "value", mayBeNull: true}]); 7481 if (e) throw e; 7482 this._body = value; 7483 }, 7484 7485 get_userContext: function WebRequest$get_userContext() { 7486 /// <value mayBeNull="true" locid="P:J#Sys.Net.WebRequest.userContext">The userContext of the request.</value> 7487 if (arguments.length !== 0) throw Error.parameterCount(); 7488 return this._userContext; 7489 }, 7490 set_userContext: function WebRequest$set_userContext(value) { 7491 var e = Function._validateParams(arguments, [{name: "value", mayBeNull: true}]); 7492 if (e) throw e; 7493 this._userContext = value; 7494 }, 7495 7496 get_executor: function WebRequest$get_executor() { 7497 /// <value type="Sys.Net.WebRequestExecutor" locid="P:J#Sys.Net.WebRequest.executor">The executor for the request.</value> 7498 if (arguments.length !== 0) throw Error.parameterCount(); 7499 return this._executor || null; 7500 }, 7501 set_executor: function WebRequest$set_executor(value) { 7502 var e = Function._validateParams(arguments, [{name: "value", type: Sys.Net.WebRequestExecutor}]); 7503 if (e) throw e; 7504 if (this._executor && this._executor.get_started()) { 7505 throw Error.invalidOperation(Sys.Res.setExecutorAfterActive); 7506 } 7507 this._executor = value; 7508 value._set_webRequest(this); 7509 }, 7510 7511 get_timeout: function WebRequest$get_timeout() { 7512 /// <value type="Number" locid="P:J#Sys.Net.WebRequest.timeout">The timeout in milliseconds for the request.</value> 7513 if (arguments.length !== 0) throw Error.parameterCount(); 7514 return this._timeout || Sys.Net.WebRequestManager.get_defaultTimeout(); 7515 }, 7516 set_timeout: function WebRequest$set_timeout(value) { 7517 var e = Function._validateParams(arguments, [{name: "value", type: Number}]); 7518 if (e) throw e; 7519 if (value < 0) { 7520 throw Error.argumentOutOfRange("value", value, Sys.Res.invalidTimeout); 7521 } 7522 this._timeout = value; 7523 }, 7524 7525 getResolvedUrl: function WebRequest$getResolvedUrl() { 7526 /// <summary locid="M:J#raise">The getResolvedUrl method returns the url resolved against the base url of the page if set.</summary> 7527 /// <returns type="String">The resolved url for the request.</returns> 7528 if (arguments.length !== 0) throw Error.parameterCount(); 7529 return Sys.Net.WebRequest._resolveUrl(this._url); 7530 }, 7531 7532 invoke: function WebRequest$invoke() { 7533 /// <summary locid="M:J#raise">Invokes the request</summary> 7534 if (arguments.length !== 0) throw Error.parameterCount(); 7535 if (this._invokeCalled) {
7536 throw Error.invalidOperation(Sys.Res.invokeCalledTwice); 7537 } 7538 Sys.Net.WebRequestManager.executeRequest(this); 7539 this._invokeCalled = true; 7540 } 7541} 7542 7543$type._resolveUrl = function WebRequest$_resolveUrl(url, baseUrl) { 7544 if (url && url.indexOf('://') > 0) { 7545 return url; 7546 } 7547 7548 if (!baseUrl || !baseUrl.length) { 7549 var baseElement = Sys.get('base'); 7550 if (baseElement && baseElement.href && baseElement.href.length) { 7551 baseUrl = baseElement.href; 7552 } 7553 else { 7554 baseUrl = document.URL; 7555 } 7556 } 7557 7558 var qsStart = baseUrl.indexOf('?'); 7559 if (qsStart > 0) { 7560 baseUrl = baseUrl.substr(0, qsStart); 7561 } 7562 qsStart = baseUrl.indexOf('#'); 7563 if (qsStart > 0) { 7564 baseUrl = baseUrl.substr(0, qsStart); 7565 } 7566 baseUrl = baseUrl.substr(0, baseUrl.lastIndexOf('/') + 1); 7567 7568 if (!url || !url.length) { 7569 return baseUrl; 7570 } 7571 7572 if (url.charAt(0) === '/') { 7573 var slashslash = baseUrl.indexOf('://'); 7574 if (slashslash === -1) { 7575 throw Error.argument("baseUrl", Sys.Res.badBaseUrl1); 7576 } 7577 7578 var nextSlash = baseUrl.indexOf('/', slashslash + 3); 7579 if (nextSlash === -1) { 7580 throw Error.argument("baseUrl", Sys.Res.badBaseUrl2); 7581 } 7582 7583 return baseUrl.substr(0, nextSlash) + url; 7584 } 7585 else { 7586 var lastSlash = baseUrl.lastIndexOf('/'); 7587 if (lastSlash === -1) { 7588 throw Error.argument("baseUrl", Sys.Res.badBaseUrl3); 7589 } 7590 7591 return baseUrl.substr(0, lastSlash+1) + url; 7592 } 7593} 7594 7595$type._createQueryString = function WebRequest$_createQueryString(queryString, encodeMethod, addParams) { 7596 encodeMethod = encodeMethod || encodeURIComponent; 7597 var i = 0, obj, val, arg, sb = new Sys.StringBuilder(); 7598 if (queryString) { 7599 for (arg in queryString) { 7600 obj = queryString[arg]; 7601 if (typeof(obj) === "function") continue; 7602 val = Sys.Serialization.JavaScriptSerializer.serialize(obj); 7603 if (i++) { 7604 sb.append('&'); 7605 } 7606 sb.append(arg); 7607 sb.append('='); 7608 sb.append(encodeMethod(val)); 7609 } 7610 } 7611 if (addParams) { 7612 if (i) { 7613 sb.append('&'); 7614 } 7615 sb.append(addParams); 7616 } 7617 return sb.toString(); 7618} 7619 7620$type._createUrl = function WebRequest$_createUrl(url, queryString, addParams) { 7621 if (!queryString && !addParams) { 7622 return url; 7623 } 7624 var qs = Sys.Net.WebRequest._createQueryString(queryString, null, addParams); 7625 return qs.length 7626 ? url + ((url && url.indexOf('?') >= 0) ? "&" : "?") + qs 7627 : url; 7628} 7629 7630$type.registerClass('Sys.Net.WebRequest'); 7631 7632 7633 7634Type.registerNamespace('Sys.Net'); 7635 7636$type = Sys.Net.WebServiceProxy = function WebServiceProxy() { 7637 var type = Object.getType(this); 7638 7639 if (type._staticInstance && (typeof(type._staticInstance.get_enableJsonp) === "function")) { 7640 this._jsonp = (type._staticInstance.get_enableJsonp()); 7641 } 7642} 7643$type.prototype = { 7644 get_timeout: function WebServiceProxy$get_timeout() { 7645 /// <value type="Number" locid="P:J#Sys.Net.WebServiceProxy.timeout">The timeout in milliseconds for the service.</value> 7646 if (arguments.length !== 0) throw Error.parameterCount(); 7647 return this._timeout || 0; 7648 }, 7649 set_timeout: function WebServiceProxy$set_timeout(value) { 7650 var e = Function._validateParams(arguments, [{name: "value", type: Number}]); 7651 if (e) throw e; 7652 if (value < 0) { 7653 throw Error.argumentOutOfRange('value', value, Sys.Res.invalidTimeout); 7654 } 7655 this._timeout = value; 7656 }, 7657 get_defaultUserContext: function WebServiceProxy$get_defaultUserContext() { 7658 /// <value mayBeNull="true" locid="P:J#Sys.Net.WebServiceProxy.defaultUserContext">The default userContext for this service.</value> 7659 if (arguments.length !== 0) throw Error.parameterCount(); 7660 return (typeof(this._userContext) === "undefined") ? null : this._userContext; 7661 }, 7662 set_defaultUserContext: function WebServiceProxy$set_defaultUserContext(value) { 7663 var e = Function._validateParams(arguments, [{name: "value", mayBeNull: true}]); 7664 if (e) throw e; 7665 this._userContext = value; 7666 }, 7667 get_defaultSucceededCallback: function WebServiceProxy$get_defaultSucceededCallback() { 7668 /// <value type="Function" mayBeNull="true" locid="P:J#Sys.Net.WebServiceProxy.defaultSucceededCallback">Returns the default succeededCallback for this service.</value> 7669 if (arguments.length !== 0) throw Error.parameterCount(); 7670 return this._succeeded || null; 7671 }, 7672 set_defaultSucceededCallback: function WebServiceProxy$set_defaultSucceededCallback(value) { 7673 var e = Function._validateParams(arguments, [{name: "value", type: Function, mayBeNull: true}]); 7674 if (e) throw e; 7675 this._succeeded = value; 7676 }, 7677 get_defaultFailedCallback: function WebServiceProxy$get_defaultFailedCallback() { 7678 /// <value type="Function" mayBeNull="true" locid="P:J#Sys.Net.WebServiceProxy.defaultFailedCallback">Returns the default failedCallback for this service.</value> 7679 if (arguments.length !== 0) throw Error.parameterCount(); 7680 return this._failed || null; 7681 }, 7682 set_defaultFailedCallback: function WebServiceProxy$set_defaultFailedCallback(value) { 7683 var e = Function._validateParams(arguments, [{name: "value", type: Function, mayBeNull: true}]); 7684 if (e) throw e; 7685 this._failed = value; 7686 }, 7687 get_enableJsonp: function WebServiceProxy$get_enableJsonp() { 7688 /// <value type="Boolean" locid="P:J#Sys.Net.WebServiceProxy.enableJsonp">Specifies whether the service supports JSONP for cross domain calling.</value> 7689 if (arguments.length !== 0) throw Error.parameterCount(); 7690 return !!this._jsonp; 7691 }, 7692 set_enableJsonp: function WebServiceProxy$set_enableJsonp(value) { 7693 var e = Function._validateParams(arguments, [{name: "value", type: Boolean}]); 7694 if (e) throw e; 7695 this._jsonp = value; 7696 }, 7697 get_path: function WebServiceProxy$get_path() { 7698 /// <value type="String" locid="P:J#Sys.Net.WebServiceProxy.path">The path to this service.</value> 7699 if (arguments.length !== 0) throw Error.parameterCount(); 7700 return this._path || null; 7701 }, 7702 set_path: function WebServiceProxy$set_path(value) { 7703 var e = Function._validateParams(arguments, [{name: "value", type: String}]); 7704 if (e) throw e; 7705 this._path = value; 7706 }, 7707 get_jsonpCallbackParameter: function WebServiceProxy$get_jsonpCallbackParameter() { 7708 /// <value type="String" locid="P:J#Sys.Net.WebServiceProxy.jsonpCallbackParameter">Specifies the parameter name that contains the callback function name for a JSONP request.</value> 7709 if (arguments.length !== 0) throw Error.parameterCount(); 7710 return this._callbackParameter || "callback"; 7711 }, 7712 set_jsonpCallbackParameter: function WebServiceProxy$set_jsonpCallbackParameter(value) { 7713 var e = Function._validateParams(arguments, [{name: "value", type: String}]); 7714 if (e) throw e; 7715 this._callbackParameter = value; 7716 }, 7717 _invoke: function WebServiceProxy$_invoke(servicePath, methodName, useGet, params, onSuccess, onF
7717ailure, userContext) { 7718 /// <summary locid="M:J#Sys.Net.WebServiceProxy._invoke"></summary> 7719 /// <param name="servicePath" type="String">Path to the webservice</param> 7720 /// <param name="methodName" type="String">Method to invoke</param> 7721 /// <param name="useGet" type="Boolean">Controls whether requests use HttpGet</param> 7722 /// <param name="params">Method args.</param> 7723 /// <param name="onSuccess" type="Function" mayBeNull="true" optional="true">Success callback</param> 7724 /// <param name="onFailure" type="Function" mayBeNull="true" optional="true">Failure callback</param> 7725 /// <param name="userContext" mayBeNull="true" optional="true">Success callback</param> 7726 /// <returns type="Sys.Net.WebRequest" mayBeNull="true">Returns the request that was sent</returns> 7727 var e = Function._validateParams(arguments, [ 7728 {name: "servicePath", type: String}, 7729 {name: "methodName", type: String}, 7730 {name: "useGet", type: Boolean}, 7731 {name: "params"}, 7732 {name: "onSuccess", type: Function, mayBeNull: true, optional: true}, 7733 {name: "onFailure", type: Function, mayBeNull: true, optional: true}, 7734 {name: "userContext", mayBeNull: true, optional: true} 7735 ]); 7736 if (e) throw e; 7737 7738 onSuccess = onSuccess || this.get_defaultSucceededCallback(); 7739 onFailure = onFailure || this.get_defaultFailedCallback(); 7740 if (userContext === null || typeof userContext === 'undefined') userContext = this.get_defaultUserContext(); 7741 return Sys.Net.WebServiceProxy.invoke(servicePath, methodName, useGet, params, onSuccess, onFailure, userContext, this.get_timeout(), this.get_enableJsonp(), this.get_jsonpCallbackParameter()); 7742 } 7743} 7744$type.registerClass('Sys.Net.WebServiceProxy'); 7745 7746$type.invoke = function WebServiceProxy$invoke(servicePath, methodName, useGet, params, onSuccess, onFailure, userContext, timeout, enableJsonp, jsonpCallbackParameter) { 7747 /// <summary locid="M:J#Sys.Net.WebServiceProxy.invoke"></summary> 7748 /// <param name="servicePath" type="String">Path to the webservice</param> 7749 /// <param name="methodName" type="String" mayBeNull="true" optional="true">Method to invoke</param> 7750 /// <param name="useGet" type="Boolean" optional="true" mayBeNull="true">Controls whether requests use HttpGet</param> 7751 /// <param name="params" mayBeNull="true" optional="true">Method args.</param> 7752 /// <param name="onSuccess" type="Function" mayBeNull="true" optional="true">Success callback</param> 7753 /// <param name="onFailure" type="Function" mayBeNull="true" optional="true">Failure callback</param> 7754 /// <param name="userContext" mayBeNull="true" optional="true">Success callback</param> 7755 /// <param name="timeout" type="Number" optional="true" mayBeNull="true">Timeout in milliseconds</param> 7756 /// <param name="enableJsonp" type="Boolean" optional="true" mayBeNull="true">Whether to use JSONP if the servicePath is for a different domain (default is true).</param> 7757 /// <param name="jsonpCallbackParameter" type="String" optional="true" mayBeNull="true">The name of the callback parameter for JSONP request (default is callback).</param> 7758 /// <returns type="Sys.Net.WebRequest" mayBeNull="true">Returns the request that was sent (null for JSONP requests).</returns> 7759 var e = Function._validateParams(arguments, [ 7760 {name: "servicePath", type: String}, 7761 {name: "methodName", type: String, mayBeNull: true, optional: true}, 7762 {name: "useGet", type: Boolean, mayBeNull: true, optional: true}, 7763 {name: "params", mayBeNull: true, optional: true}, 7764 {name: "onSuccess", type: Function, mayBeNull: true, optional: true}, 7765 {name: "onFailure", type: Function, mayBeNull: true, optional: true}, 7766 {name: "userContext", mayBeNull: true, optional: true}, 7767 {name: "timeout", type: Number, mayBeNull: true, optional: true}, 7768 {name: "enableJsonp", type: Boolean, mayBeNull: true, optional: true}, 7769 {name: "jsonpCallbackParameter", type: String, mayBeNull: true, optional: true} 7770 ]); 7771 if (e) throw e; 7772 var schemeHost = (enableJsonp !== false) ? Sys.Net.WebServiceProxy._xdomain.exec(servicePath) : null, 7773 tempCallback, jsonp = schemeHost && (schemeHost.length === 3) && 7774 ((schemeHost[1] !== location.protocol) || (schemeHost[2] !== location.host)); 7775 useGet = jsonp || useGet; 7776 if (jsonp) { 7777 jsonpCallbackParameter = jsonpCallbackParameter || "callback"; 7778 tempCallback = "_jsonp" + Sys._jsonp++; 7779 } 7780 if (!params) params = {};
7781 var urlParams = params; 7782 if (!useGet || !urlParams) urlParams = {}; 7783 var error, timeoutcookie = null, body = null, 7784 url = Sys.Net.WebRequest._createUrl(methodName 7785 ? (servicePath+"/"+encodeURIComponent(methodName)) 7786 : servicePath, urlParams, jsonp ? (jsonpCallbackParameter + "=Sys." + tempCallback) : null); 7787 if (jsonp) { 7788 function jsonpComplete(data, statusCode) { 7789 if (timeoutcookie !== null) { 7790 window.clearTimeout(timeoutcookie); 7791 timeoutcookie = null; 7792 } 7793 delete Sys[tempCallback]; 7794 tempCallback = null; 7795 if ((typeof(statusCode) !== "undefined") && (statusCode !== 200)) { 7796 if (onFailure) { 7797 error = new Sys.Net.WebServiceError(false, 7798 data.Message || String.format(Sys.Res.webServiceFailedNoMsg, methodName), 7799 data.StackTrace || null, 7800 data.ExceptionType || null, 7801 data); 7802 error._statusCode = statusCode; 7803 onFailure(error, userContext, methodName); 7804 } 7805 else { 7806 if (data.StackTrace && data.Message) { 7807 error = data.StackTrace + "-- " + data.Message; 7808 } 7809 else { 7810 error = data.StackTrace || data.Message; 7811 } 7812 error = String.format(error ? Sys.Res.webServiceFailed : Sys.Res.webServiceFailedNoMsg, methodName, error); 7813 throw Sys.Net.WebServiceProxy._createFailedError(methodName, String.format(Sys.Res.webServiceFailed, methodName, error)); 7814 } 7815 } 7816 else if (onSuccess) { 7817 onSuccess(data, userContext, methodName); 7818 } 7819 } 7820 Sys[tempCallback] = jsonpComplete; 7821 Sys._loadJsonp(url, function() { 7822 if (tempCallback) { 7823 jsonpComplete({ Message: String.format(Sys.Res.webServiceFailedNoMsg, methodName) }, -1); 7824 } 7825 }); 7826 return null; 7827 } 7828 var request = new Sys.Net.WebRequest(); 7829 request.set_url(url); 7830 request.get_headers()['Content-Type'] = 'application/json; charset=utf-8'; 7831 if (!useGet) { 7832 body = Sys.Serialization.JavaScriptSerializer.serialize(params); 7833 if (body === "{}") body = ""; 7834 } 7835 request.set_body(body); 7836 request.add_completed(onComplete); 7837 if (timeout > 0) request.set_timeout(timeout); 7838 request.invoke(); 7839 7840 function onComplete(response, eventArgs) { 7841 if (response.get_responseAvailable()) { 7842 var ex, statusCode = response.get_statusCode(); 7843 var result = null; 7844 var isJson; 7845 7846 try { 7847 var contentType = response.getResponseHeader("Content-Type"); 7848 isJson = contentType.startsWith("application/json"); 7849 result = isJson ? response.get_object() : 7850 (contentType.startsWith("text/xml") ? response.get_xml() : response.get_responseData()); 7851 } 7852 catch (ex) { 7853 } 7854 7855 var error = response.getResponseHeader("jsonerror"); 7856 var errorObj = (error === "true"); 7857 if (errorObj) { 7858 if (result) { 7859 result = new Sys.Net.WebServiceError(false, result.Message, result.StackTrace, result.ExceptionType, result); 7860 } 7861 } 7862 else if (isJson) { 7863 result = (!result || (typeof(result.d) === "undefined")) ? result : result.d; 7864 } 7865 if (((statusCode < 200) || (statusCode >= 300)) || errorObj) { 7866 if (onFailure) { 7867 if (!result || !errorObj) { 7868 result = new Sys.Net.WebServiceError(false /*timedout*/, String.format(Sys.Res.webServiceFailedNoMsg, methodName)); 7869 } 7870 result._statusCode = statusCode; 7871 onFailure(result, userContext, methodName); 7872 } 7873 else { 7874 if (result && errorObj) { 7875 error = result.get_exceptionType() + "-- " + result.get_message(); 7876 } 7877 else { 7878 error = response.get_responseData(); 7879 } 7880 throw Sys.Net.WebServiceProxy._createFailedError(methodName, String.format(Sys.Res.webServiceFailed, methodName, error)); 7881 } 7882 } 7883 else if (onSuccess) { 7884 onSuccess(result, userContext, methodName); 7885 } 7886 } 7887 else { 7888 var timedOut = response.get_timedOut(), 7889 msg = String.format((timedOut ? Sys.Res.webServiceTimedOut : Sys.Res.webServiceFailedNoMsg), methodName); 7890 if (onFailure) { 7891 onFailure(new Sys.Net.WebServiceError(timedOut, msg, "", ""), userContext, methodName); 7892 } 7893 else { 7894 throw Sys.Net.WebServiceProxy._createFailedError(methodName, msg); 7895 } 7896 } 7897 } 7898 7899 return request; 7900} 7901 7902$type._createFailedError = function WebServiceProxy$_createFailedError(methodName, errorMessage) { 7903 var displayMessage = "Sys.Net.WebServiceFailedException: " + errorMessage; 7904 var e = Error.create(displayMessage, { 'name': 'Sys.Net.WebServiceFailedException', 'methodName': methodName }); 7905 e.popStackFrame(); 7906 return e; 7907} 7908 7909$type._defaultFailedCallback = function WebServiceProxy$_defaultFailedCallback(err, methodName) { 7910 var error = err.get_exceptionType() + "-- " + err.get_message(); 7911 throw Sys.Net.WebServiceProxy._createFailedError(methodName, String.format(Sys.Res.webServiceFailed, methodName, error)); 7912} 7913 7914$type._generateTypedConstructor = function WebServiceProxy$_generateTypedConstructor(type) { 7915 return function(properties) { 7916 if (properties) { 7917 for (var name in properties) { 7918 this[name] = properties[name]; 7919 } 7920 } 7921 this.__type = type; 7922 } 7923} 7924 7925Sys._jsonp = 0; 7926 7927$type._xdomain = /^\s*([a-zA-Z0-9\+\-\.]+\:)\/\/([^?#\/]+)/; 7928 7929Sys._loadJsonp = function _loadJsonp(src, callback) { 7930 var script = document.createElement('script'); 7931 script.type = 'text/javascript'; 7932 script.src = src; 7933 var attachEvent = script.attachEvent; 7934 function onEvent() { 7935 if (!attachEvent || /loaded|complete/.test(script.readyState)) { 7936 if (attachEvent) { 7937 script.detachEvent("onreadystatechange", onEvent); 7938 } 7939 else { 7940 script.removeEventListener("load", onEvent, false); 7941 script.removeEventListener("error", onEvent, false); 7942 } 7943 callback.apply(script); 7944 script = null; 7945 } 7946 } 7947 if (attachEvent) { 7948 script.attachEvent("onreadystatechange", onEvent); 7949 } 7950 else { 7951 script.addEventListener("load", onEvent, false); 7952 script.addEventListener("error", onEvent, false); 7953 } 7954 Sys.get("head").appendChild(script); 7955} 7956$type = Sys.Net.WebServiceError = function WebServiceError(timedOut, message, stackTrace, exceptionType, errorObject) { 7957 /// <summary locid="M:J#Sys.Net.WebServiceError.#ctor">Represents a webservice error</summary> 7958 /// <param name="timedOut" type="Boolean">Whether the service timed out.</param> 7959 /// <param name="message" type="String" mayBeNull="true">The error message.</param> 7960 /// <param name="stackTrace" type="String" mayBeNull="true" optional="true">The stack trace of the error.</param> 7961 /// <param name="exceptionType" type="String" mayBeNull="true" optional="true">The server exception type.</param> 7962 /// <param name="errorObject" type="Object" mayBeNull="true" optional="true">The raw error information.</param> 7963 var e = Function._validateParams(arguments, [ 7964 {name: "timedOut", type: Boolean}, 7965 {name: "message", type: String, mayBeNull: true}, 7966 {name: "stackTrace", type: String, mayBeNull: true, optional: true}, 7967 {name: "exceptionType", type: String, mayBeNull: true, optional: true}, 7968 {name: "errorObject", type: Object, mayBeNull: true, optional: true} 7969 ]); 7970 if (e) throw e; 7971 this._timedOut = timedOut; 7972 this._message = message; 7973 this._stackTrace = stackTrace; 7974 this._exceptionType = exceptionType; 7975 this._errorObject = errorObject; 7976 this._statusCode = -1; 7977} 7978 7979$type.prototype = { 7980 get_timedOut: function WebServiceError$get_timedOut() { 7981 /// <value type="Boolean" locid="P:J#Sys.Net.WebServiceError.timedOut">Whether the service failed due to timeout.</value> 7982 if (arguments.length !== 0) throw Error.parameterCount(); 7983 return this._timedOut; 7984 }, 7985 7986 get_statusCode: function WebServiceError$get_statusCode() { 7987 /// <value type="Number" locid="P:J#Sys.Net.WebServiceError.statusCode">Int representing the status of the response.</value> 7988 if (arguments.length !== 0) throw Error.parameterCount(); 7989 return this._statusCode; 7990 }, 7991 7992 get_message: function WebServiceError$get_message() { 7993 /// <value type="String" locid="P:J#Sys.Net.WebServiceError.message">Error message</value> 7994 if (arguments.length !== 0) throw Error.parameterCount(); 7995 return this._message; 7996 }, 7997 7998 get_stackTrace: function WebServiceError$get_stackTrace() { 7999 /// <value type="String" locid="P:J#Sys.Net.WebServiceError.stackTrace">Stack trace of the error.</value> 8000 if (arguments.length !== 0) throw Error.parameterCount(); 8001 return this._stackTrace || ""; 8002 }, 8003 8004 get_exceptionType: function WebServiceError$get_exceptionType() { 8005 /// <value type="String" locid="P:J#Sys.Net.WebServiceError.exceptionType">Exception type of the error.</value> 8006 if (arguments.length !== 0) throw Error.parameterCount(); 8007 return this._exceptionType || ""; 8008 }, 8009 8010 get_errorObject: function WebServiceError$get_errorObject() { 8011 /// <value type="Object" locid="P:J#Sys.Net.WebServiceError.errorObject">The raw error object returned by the service.</value> 8012 if (arguments.length !== 0) throw Error.parameterCount(); 8013 return this._errorObject || null; 8014 } 8015} 8016$type.registerClass('Sys.Net.WebServiceError'); 8017 8018Type.registerNamespace("Sys.Services"); 8019var ns = Sys.Services; 8020var service = "Service", 8021 role = "Role", 8022 auth = "Authentication", 8023 profile = "Profile"; 8024function setPath(path) { 8025 this._path = path; 8026} 8027ns[auth+service] = { 8028 set_path: setPath, 8029 _setAuthenticated: function(auth) { 8030 this._auth = auth; 8031 } 8032}; 8033ns["_" + auth + service] = {}; 8034 8035ns[profile + service] = { set_path: setPath }; 8036ns["_" + profile + service] = {}; 8037ns.ProfileGroup = function ns$ProfileGroup(properties) { 8038 this._propertygroup = properties; 8039} 8040 8041ns[role + service] = { set_path: setPath }; 8042ns["_" + role + service] = {}; 8043 8044 8045 8046Sys._domLoaded(); 8047} 8048 8049if (Sys.loader) { 8050 Sys.loader.registerScript("MicrosoftAjax", null, execute); 8051} 8052else { 8053 execute(); 8054} 8055 8056})(window, window.Sys); 8057var $get, $create, $addHandler, $addHandlers, $clearHandlers; 8058 8059Type.registerNamespace('Sys'); 8060Sys.Res={ 8061"argumentInteger":"Value must be an integer.", 8062"argumentType":"Object cannot be converted to the required type.", 8063"argumentNull":"Value cannot be null.", 8064"scriptAlreadyLoaded":"The script \u0027{0}\u0027 has been referenced multiple times. If referencing Microsoft AJAX scripts explicitly, set the MicrosoftAjaxMode property of the ScriptManager to Explicit.", 8065"scriptDependencyNotFound":"The script \u0027{0}\u0027 failed to load because it is dependent on script \u0027{1}\u0027.",
8066"formatBadFormatSpecifier":"Format specifier was invalid.", 8067"requiredScriptReferenceNotIncluded":"\u0027{0}\u0027 requires that you have included a script reference to \u0027{1}\u0027.", 8068"webServiceFailedNoMsg":"The server method \u0027{0}\u0027 failed.", 8069"argumentDomElement":"Value must be a DOM element.", 8070"actualValue":"Actual value was {0}.", 8071"enumInvalidValue":"\u0027{0}\u0027 is not a valid value for enum {1}.", 8072"scriptLoadFailed":"The script \u0027{0}\u0027 could not be loaded.", 8073"parameterCount":"Parameter count mismatch.", 8074"cannotDeserializeEmptyString":"Cannot deserialize empty string.", 8075"formatInvalidString":"Input string was not in a correct format.", 8076"argument":"Value does not fall within the expected range.", 8077"cannotDeserializeInvalidJson":"Cannot deserialize. The data does not correspond to valid JSON.", 8078"cannotSerializeNonFiniteNumbers":"Cannot serialize non finite numbers.", 8079"argumentUndefined":"Value cannot be undefined.", 8080"webServiceInvalidReturnType":"The server method \u0027{0}\u0027 returned an invalid type. Expected type: {1}", 8081"servicePathNotSet":"The path to the web service has not been set.", 8082"argumentTypeWithTypes":"Object of type \u0027{0}\u0027 cannot be converted to type \u0027{1}\u0027.", 8083"paramName":"Parameter name: {0}", 8084"nullReferenceInPath":"Null reference while evaluating data path: \u0027{0}\u0027.", 8085"format":"One of the identified items was in an invalid format.", 8086"assertFailedCaller":"Assertion Failed: {0}\nat {1}", 8087"argumentOutOfRange":"Specified argument was out of the range of valid values.", 8088"webServiceTimedOut":"The server method \u0027{0}\u0027 timed out.", 8089"notImplemented":"The method or operation is not implemented.", 8090"assertFailed":"Assertion Failed: {0}", 8091"invalidOperation":"Operation is not valid due to the current state of the object.", 8092"breakIntoDebugger":"{0}\n\nBreak into debugger?", 8093"invokeCalledTwice":"Cannot call invoke more than once.", 8094"argumentTypeName":"Value is not the name of an existing type.", 8095"cantBeCalledAfterDispose":"Can\u0027t be called after dispose.", 8096"webServiceFailed":"The server method \u0027{0}\u0027 failed with the following error: {1}", 8097"componentCantSetIdAfterAddedToApp":"The id property of a component can\u0027t be set after it\u0027s been added to the Application object.", 8098"behaviorDuplicateName":"A behavior with name \u0027{0}\u0027 already exists or it is the name of an existing property on the target element.", 8099"notATypeName":"Value is not a valid type name.", 8100"elementNotFound":"An element with id \u0027{0}\u0027 could not be found.", 8101"stateMustBeStringDictionary":"The state object can only have null and string fields.", 8102"invalidExecutorType":"Could not create a valid Sys.Net.WebRequestExecutor from: {0}.", 8103"boolTrueOrFalse":"Value must be \u0027true\u0027 or \u0027false\u0027.", 8104"cannotCallBeforeResponse":"Cannot call {0} when responseAvailable is false.", 8105"scriptLoadFailedNoHead":"ScriptLoader requires pages to contain a \u003chead\u003e element.", 8106"stringFormatInvalid":"The format string is invalid.", 8107"referenceNotFound":"Component \u0027{0}\u0027 was not found.", 8108"enumReservedName":"\u0027{0}\u0027 is a reserved name that can\u0027t be used as an enum value name.", 8109"circularParentChain":"The chain of control parents can\u0027t have circular references.", 8110"namespaceContainsNonObject":"Object {0} already exists and is not an object.", 8111"undefinedEvent":"\u0027{0}\u0027 is not an event.", 8112"invalidTimeout":"Value must be greater than or equal to zero.", 8113"cannotAbortBeforeStart":"Cannot abort when executor has not started.", 8114"observableConflict":"Object already contains a member with the name \u0027{0}\u0027.", 8115"invalidHttpVerb":"httpVerb cannot be set to an empty or null string.", 8116"nullWebRequest":"Cannot call executeRequest with a null webRequest.", 8117"historyCannotEnableHistory":"Cannot set enableHistory after initialization.", 8118"eventHandlerInvalid":"Handler was not added through the Sys.UI.DomEvent.addHandler method.", 8119"scriptLoadFailedDebug":"The script \u0027{0}\u0027 failed to load. Check for:\n Inaccessible path.\n Script errors. (IE) Enable \u0027Display a notification about every script error\u0027 under advanced settings.", 8120"propertyNotWritable":"\u0027{0}\u0027 is not a writable property.", 8121"enumInvalidValueName":"\u0027{0}\u0027 is not a valid name for an enum value.", 8122"cannotCallOnceStarted":"Cannot call {0} once started.", 8123"controlAlreadyDefined":"A control is already associated with the element.", 8124"addHandlerCantBeUsedForError":"Can\u0027t add a handler for the error event using this method. Please set the window.onerror property instead.", 8125"badBaseUrl1":"Base URL does not contain ://.", 8126"badBaseUrl2":"Base URL does not contain another /.", 8127"badBaseUrl3":"Cannot find last / in base URL.", 8128"setExecutorAfterActive":"Cannot set executor after it has become active.", 8129"cantAddNonFunctionhandler":"Can\u0027t add a handler that is not a function.", 8130"invalidNameSpace":"Value is not a valid namespace identifier.", 8131"notAnInterface":"Value is not a valid interface.", 8132"eventHandlerNotFunction":"Handler must be a function.", 8133"propertyNotAnArray":"\u0027{0}\u0027 is not an Array property.", 8134"namespaceContainsClass":"Object {0} already exists as a class, enum, or interface.", 8135"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.", 8136"cantSetNameAfterInit":"The name property can\u0027t be set on this object after initialization.", 8137"historyMissingFrame":"For the history feature to work in IE, the page must have an iFrame element with id \u0027__historyFrame\u0027 pointed to a page that gets its title from the \u0027title\u0027 query string parameter and calls Sys.Application._onIFrameLoad() on the parent window. This can be done by setting EnableHistory to true on ScriptManager.", 8138"appDuplicateComponent":"Two components with the same id \u0027{0}\u0027 can\u0027t be added to the application.", 8139"historyCannotAddHistoryPointWithHistoryDisabled":"A history point can only be added if enableHistory is set to true.", 8140"expectedElementOrId":"Value must be a DOM element or DOM element id.", 8141"selectorNotFound":"An element with selector \u0027{0}\u0027 could not be found.", 8142"cannotCallOutsideHandler":"Cannot call {0} outside of a completed event handler.", 8143"methodNotFound":"No method found with name \u0027{0}\u0027.", 8144"arrayParseBadFormat":"Value must be a valid string representation for an array. It must start with a \u0027[\u0027 and end with a \u0027]\u0027.", 8145"cannotSerializeObjectWithCycle":"Cannot serialize object with cyclic reference within child properties.", 8146"stateFieldNameInvalid":"State field names must not contain any \u0027=\u0027 characters.",
8147"stringFormatBraceMismatch":"The format string contains an unmatched opening or closing brace.", 8148"enumValueNotInteger":"An enumeration definition can only contain integer values.", 8149"propertyNullOrUndefined":"Cannot set the properties of \u0027{0}\u0027 because it returned a null value.", 8150"expectedDomElementOrSelector":"\u0027{0}\u0027 must be a DOM element or DOM element selector.", 8151"argumentDomNode":"Value must be a DOM element or a text node.", 8152"componentCantSetIdTwice":"The id property of a component can\u0027t be set more than once.", 8153"createComponentOnDom":"Value must be null for Components that are not Controls or Behaviors.", 8154"createNoDom":"Value must not be null for Controls and Behaviors.", 8155"cantAddWithoutId":"Can\u0027t add a component that doesn\u0027t have an id.", 8156"urlTooLong":"The history state must be small enough to not make the url larger than {0} characters.", 8157"notObservable":"Instances of type \u0027{0}\u0027 cannot be observed.", 8158"badTypeName":"Value is not the name of the type being registered or the name is a reserved word." 8159};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.