PageRenderTime 63ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 1ms

/src/Samples/Xmlt.Sample/Scripts/embed/MicrosoftAjaxWebForms.debug.js

#
JavaScript | 2130 lines | 1812 code | 247 blank | 71 comment | 373 complexity | 78a92650b654e37c04b37e5699db3c46 MD5 | raw file
  1. // (c) 2010 CodePlex Foundation
  2. (function() {
  3. function execute() {
  4. Type._registerScript("MicrosoftAjaxWebForms.js", [
  5. "MicrosoftAjaxCore.js",
  6. "MicrosoftAjaxSerialization.js",
  7. "MicrosoftAjaxNetwork.js",
  8. "MicrosoftAjaxComponentModel.js"]);
  9. var $type, $prototype;
  10. Type.registerNamespace('Sys.WebForms');
  11. $type = Sys.WebForms.BeginRequestEventArgs = function BeginRequestEventArgs(request, postBackElement, updatePanelsToUpdate) {
  12. /// <summary locid="M:J#Sys.WebForms.BeginRequestEventArgs.#ctor">The arguments for the PageRequestManager's beginRequest event. The beginRequest event is raised when a request is about to be made.</summary>
  13. /// <param name="request" type="Sys.Net.WebRequest">The web request for the EventArgs.</param>
  14. /// <param name="postBackElement" domElement="true" mayBeNull="true">The postback element that initiated the async postback.</param>
  15. /// <param name="updatePanelsToUpdate" type="Array" elementType="String" mayBeNull="true" optional="true">A list of UniqueIDs for UpdatePanel controls that are requested to update their rendering by the client. Server-side processing may update additional UpdatePanels.</param>
  16. var e = Function._validateParams(arguments, [
  17. {name: "request", type: Sys.Net.WebRequest},
  18. {name: "postBackElement", mayBeNull: true, domElement: true},
  19. {name: "updatePanelsToUpdate", type: Array, mayBeNull: true, optional: true, elementType: String}
  20. ]);
  21. if (e) throw e;
  22. Sys.WebForms.BeginRequestEventArgs.initializeBase(this);
  23. this._request = request;
  24. this._postBackElement = postBackElement;
  25. this._updatePanelsToUpdate = updatePanelsToUpdate;
  26. }
  27. $type.prototype = {
  28. get_postBackElement: function BeginRequestEventArgs$get_postBackElement() {
  29. /// <value domElement="true" mayBeNull="true" locid="P:J#Sys.WebForms.BeginRequestEventArgs.postBackElement"></value>
  30. if (arguments.length !== 0) throw Error.parameterCount();
  31. return this._postBackElement;
  32. },
  33. get_request: function BeginRequestEventArgs$get_request() {
  34. /// <value type="Sys.Net.WebRequest" locid="P:J#Sys.WebForms.BeginRequestEventArgs.request"></value>
  35. if (arguments.length !== 0) throw Error.parameterCount();
  36. return this._request;
  37. },
  38. get_updatePanelsToUpdate: function BeginRequestEventArgs$get_updatePanelsToUpdate() {
  39. /// <value type="Array" elementType="String" locid="P:J#Sys.WebForms.BeginRequestEventArgs.updatePanelsToUpdate"></value>
  40. if (arguments.length !== 0) throw Error.parameterCount();
  41. return this._updatePanelsToUpdate ? Array.clone(this._updatePanelsToUpdate) : [];
  42. }
  43. }
  44. $type.registerClass('Sys.WebForms.BeginRequestEventArgs', Sys.EventArgs);
  45. $type = Sys.WebForms.EndRequestEventArgs = function EndRequestEventArgs(error, dataItems, response) {
  46. /// <summary locid="M:J#Sys.WebForms.EndRequestEventArgs.#ctor">The arguments for the PageRequestManager's endRequest event. The endRequest event is raised when a response has finished processing.</summary>
  47. /// <param name="error" type="Error" mayBeNull="true"></param>
  48. /// <param name="dataItems" type="Object" mayBeNull="true"></param>
  49. /// <param name="response" type="Sys.Net.WebRequestExecutor"></param>
  50. var e = Function._validateParams(arguments, [
  51. {name: "error", type: Error, mayBeNull: true},
  52. {name: "dataItems", type: Object, mayBeNull: true},
  53. {name: "response", type: Sys.Net.WebRequestExecutor}
  54. ]);
  55. if (e) throw e;
  56. Sys.WebForms.EndRequestEventArgs.initializeBase(this);
  57. this._errorHandled = false;
  58. this._error = error;
  59. this._dataItems = dataItems || new Object();
  60. this._response = response;
  61. }
  62. $type.prototype = {
  63. get_dataItems: function EndRequestEventArgs$get_dataItems() {
  64. /// <value type="Object" locid="P:J#Sys.WebForms.EndRequestEventArgs.dataItems"></value>
  65. if (arguments.length !== 0) throw Error.parameterCount();
  66. return this._dataItems;
  67. },
  68. get_error: function EndRequestEventArgs$get_error() {
  69. /// <value type="Error" locid="P:J#Sys.WebForms.EndRequestEventArgs.error"></value>
  70. if (arguments.length !== 0) throw Error.parameterCount();
  71. return this._error;
  72. },
  73. get_errorHandled: function EndRequestEventArgs$get_errorHandled() {
  74. /// <value type="Boolean" locid="P:J#Sys.WebForms.EndRequestEventArgs.errorHandled"></value>
  75. if (arguments.length !== 0) throw Error.parameterCount();
  76. return this._errorHandled;
  77. },
  78. set_errorHandled: function EndRequestEventArgs$set_errorHandled(value) {
  79. var e = Function._validateParams(arguments, [{name: "value", type: Boolean}]);
  80. if (e) throw e;
  81. this._errorHandled = value;
  82. },
  83. get_response: function EndRequestEventArgs$get_response() {
  84. /// <value type="Sys.Net.WebRequestExecutor" locid="P:J#Sys.WebForms.EndRequestEventArgs.response"></value>
  85. if (arguments.length !== 0) throw Error.parameterCount();
  86. return this._response;
  87. }
  88. }
  89. $type.registerClass('Sys.WebForms.EndRequestEventArgs', Sys.EventArgs);
  90. $type = Sys.WebForms.InitializeRequestEventArgs = function InitializeRequestEventArgs(request, postBackElement, updatePanelsToUpdate) {
  91. /// <summary locid="M:J#Sys.WebForms.InitializeRequestEventArgs.#ctor">The arguments for the PageRequestManager's initializeRequest event. The initializeRequest event is raised when a request is being prepared and can be cancelled.</summary>
  92. /// <param name="request" type="Sys.Net.WebRequest">The web request to be packaged in this EventArgs.</param>
  93. /// <param name="postBackElement" domElement="true" mayBeNull="true">The postback element that initiated the async postback.</param>
  94. /// <param name="updatePanelsToUpdate" type="Array" elementType="String" mayBeNull="true" optional="true">A list of UniqueIDs for UpdatePanel controls that are requested to update their rendering by the client. Server-side processing may update additional UpdatePanels.</param>
  95. var e = Function._validateParams(arguments, [
  96. {name: "request", type: Sys.Net.WebRequest},
  97. {name: "postBackElement", mayBeNull: true, domElement: true},
  98. {name: "updatePanelsToUpdate", type: Array, mayBeNull: true, optional: true, elementType: String}
  99. ]);
  100. if (e) throw e;
  101. Sys.WebForms.InitializeRequestEventArgs.initializeBase(this);
  102. this._request = request;
  103. this._postBackElement = postBackElement;
  104. this._updatePanelsToUpdate = updatePanelsToUpdate;
  105. }
  106. $type.prototype = {
  107. get_postBackElement: function InitializeRequestEventArgs$get_postBackElement() {
  108. /// <value domElement="true" mayBeNull="true" locid="P:J#Sys.WebForms.InitializeRequestEventArgs.postBackElement"></value>
  109. if (arguments.length !== 0) throw Error.parameterCount();
  110. return this._postBackElement;
  111. },
  112. get_request: function InitializeRequestEventArgs$get_request() {
  113. /// <value type="Sys.Net.WebRequest" locid="P:J#Sys.WebForms.InitializeRequestEventArgs.request"></value>
  114. if (arguments.length !== 0) throw Error.parameterCount();
  115. return this._request;
  116. },
  117. get_updatePanelsToUpdate: function InitializeRequestEventArgs$get_updatePanelsToUpdate() {
  118. /// <value type="Array" elementType="String" locid="P:J#Sys.WebForms.InitializeRequestEventArgs.updatePanelsToUpdate"></value>
  119. if (arguments.length !== 0) throw Error.parameterCount();
  120. return this._updatePanelsToUpdate ? Array.clone(this._updatePanelsToUpdate) : [];
  121. },
  122. set_updatePanelsToUpdate: function InitializeRequestEventArgs$set_updatePanelsToUpdate(value) {
  123. var e = Function._validateParams(arguments, [{name: "value", type: Array, elementType: String}]);
  124. if (e) throw e;
  125. this._updated = true;
  126. this._updatePanelsToUpdate = value;
  127. }
  128. }
  129. $type.registerClass('Sys.WebForms.InitializeRequestEventArgs', Sys.CancelEventArgs);
  130. $type = Sys.WebForms.PageLoadedEventArgs = function PageLoadedEventArgs(panelsUpdated, panelsCreated, dataItems) {
  131. /// <summary locid="M:J#Sys.WebForms.PageLoadedEventArgs.#ctor">The arguments for the PageRequestManager's pageLoaded event. The pageLoaded event is raised after the DOM has been updated.</summary>
  132. /// <param name="panelsUpdated" type="Array">An array of UpdatePanels that were updated.</param>
  133. /// <param name="panelsCreated" type="Array">An array of UpdatePanels that were created.</param>
  134. /// <param name="dataItems" type="Object" mayBeNull="true"></param>
  135. var e = Function._validateParams(arguments, [
  136. {name: "panelsUpdated", type: Array},
  137. {name: "panelsCreated", type: Array},
  138. {name: "dataItems", type: Object, mayBeNull: true}
  139. ]);
  140. if (e) throw e;
  141. Sys.WebForms.PageLoadedEventArgs.initializeBase(this);
  142. this._panelsUpdated = panelsUpdated;
  143. this._panelsCreated = panelsCreated;
  144. this._dataItems = dataItems || new Object();
  145. }
  146. $type.prototype = {
  147. get_dataItems: function PageLoadedEventArgs$get_dataItems() {
  148. /// <value type="Object" locid="P:J#Sys.WebForms.PageLoadedEventArgs.dataItems"></value>
  149. if (arguments.length !== 0) throw Error.parameterCount();
  150. return this._dataItems;
  151. },
  152. get_panelsCreated: function PageLoadedEventArgs$get_panelsCreated() {
  153. /// <value type="Array" locid="P:J#Sys.WebForms.PageLoadedEventArgs.panelsCreated"></value>
  154. if (arguments.length !== 0) throw Error.parameterCount();
  155. return this._panelsCreated;
  156. },
  157. get_panelsUpdated: function PageLoadedEventArgs$get_panelsUpdated() {
  158. /// <value type="Array" locid="P:J#Sys.WebForms.PageLoadedEventArgs.panelsUpdated"></value>
  159. if (arguments.length !== 0) throw Error.parameterCount();
  160. return this._panelsUpdated;
  161. }
  162. }
  163. $type.registerClass('Sys.WebForms.PageLoadedEventArgs', Sys.EventArgs);
  164. $type = Sys.WebForms.PageLoadingEventArgs = function PageLoadingEventArgs(panelsUpdating, panelsDeleting, dataItems) {
  165. /// <summary locid="M:J#Sys.WebForms.PageLoadingEventArgs.#ctor">The arguments for the PageRequestManager's pageLoading event. The pageLoading event is raised before the DOM has been updated.</summary>
  166. /// <param name="panelsUpdating" type="Array">An array of UpdatePanels that are going to be updated.</param>
  167. /// <param name="panelsDeleting" type="Array">An array of UpdatePanels that are going to be deleted.</param>
  168. /// <param name="dataItems" type="Object" mayBeNull="true"></param>
  169. var e = Function._validateParams(arguments, [
  170. {name: "panelsUpdating", type: Array},
  171. {name: "panelsDeleting", type: Array},
  172. {name: "dataItems", type: Object, mayBeNull: true}
  173. ]);
  174. if (e) throw e;
  175. Sys.WebForms.PageLoadingEventArgs.initializeBase(this);
  176. this._panelsUpdating = panelsUpdating;
  177. this._panelsDeleting = panelsDeleting;
  178. this._dataItems = dataItems || new Object();
  179. }
  180. $type.prototype = {
  181. get_dataItems: function PageLoadingEventArgs$get_dataItems() {
  182. /// <value type="Object" locid="P:J#Sys.WebForms.PageLoadingEventArgs.dataItems"></value>
  183. if (arguments.length !== 0) throw Error.parameterCount();
  184. return this._dataItems;
  185. },
  186. get_panelsDeleting: function PageLoadingEventArgs$get_panelsDeleting() {
  187. /// <value type="Array" locid="P:J#Sys.WebForms.PageLoadingEventArgs.panelsDeleting"></value>
  188. if (arguments.length !== 0) throw Error.parameterCount();
  189. return this._panelsDeleting;
  190. },
  191. get_panelsUpdating: function PageLoadingEventArgs$get_panelsUpdating() {
  192. /// <value type="Array" locid="P:J#Sys.WebForms.PageLoadingEventArgs.panelsUpdating"></value>
  193. if (arguments.length !== 0) throw Error.parameterCount();
  194. return this._panelsUpdating;
  195. }
  196. }
  197. $type.registerClass('Sys.WebForms.PageLoadingEventArgs', Sys.EventArgs);
  198. $type = Sys._ScriptLoaderTask = function _ScriptLoaderTask(scriptElement, completedCallback) {
  199. /// <summary locid="M:J#Sys._ScriptLoaderTask.#ctor"></summary>
  200. /// <param name="scriptElement" domElement="true">The script element to add to the DOM.</param>
  201. /// <param name="completedCallback" type="Function">Callback to call when the script has loaded or failed to load.</param>
  202. var e = Function._validateParams(arguments, [
  203. {name: "scriptElement", domElement: true},
  204. {name: "completedCallback", type: Function}
  205. ]);
  206. if (e) throw e;
  207. this._scriptElement = scriptElement;
  208. this._completedCallback = completedCallback;
  209. }
  210. $type.prototype = {
  211. get_scriptElement: function _ScriptLoaderTask$get_scriptElement() {
  212. /// <value domElement="true" locid="P:J#Sys._ScriptLoaderTask.scriptElement">The script element.</value>
  213. if (arguments.length !== 0) throw Error.parameterCount();
  214. return this._scriptElement;
  215. },
  216. dispose: function _ScriptLoaderTask$dispose() {
  217. if(this._disposed) {
  218. return;
  219. }
  220. this._disposed = true;
  221. this._removeScriptElementHandlers();
  222. Sys._ScriptLoaderTask._clearScript(this._scriptElement);
  223. this._scriptElement = null;
  224. },
  225. execute: function _ScriptLoaderTask$execute() {
  226. /// <summary locid="M:J#Sys._ScriptLoaderTask.execute">Begins loading the given script element.</summary>
  227. if (arguments.length !== 0) throw Error.parameterCount();
  228. this._addScriptElementHandlers();
  229. var headElements = document.getElementsByTagName('head');
  230. if (headElements.length === 0) {
  231. throw new Error.invalidOperation(Sys.Res.scriptLoadFailedNoHead);
  232. }
  233. else {
  234. headElements[0].appendChild(this._scriptElement);
  235. }
  236. },
  237. _addScriptElementHandlers: function _ScriptLoaderTask$_addScriptElementHandlers() {
  238. this._scriptLoadDelegate = Function.createDelegate(this, this._scriptLoadHandler);
  239. if (document.addEventListener) {
  240. this._scriptElement.readyState = 'loaded';
  241. $addHandler(this._scriptElement, 'load', this._scriptLoadDelegate);
  242. }
  243. else {
  244. $addHandler(this._scriptElement, 'readystatechange', this._scriptLoadDelegate);
  245. }
  246. if (this._scriptElement.addEventListener) {
  247. this._scriptErrorDelegate = Function.createDelegate(this, this._scriptErrorHandler);
  248. this._scriptElement.addEventListener('error', this._scriptErrorDelegate, false);
  249. }
  250. },
  251. _removeScriptElementHandlers: function _ScriptLoaderTask$_removeScriptElementHandlers() {
  252. if(this._scriptLoadDelegate) {
  253. var scriptElement = this.get_scriptElement();
  254. if (document.addEventListener) {
  255. $removeHandler(scriptElement, 'load', this._scriptLoadDelegate);
  256. }
  257. else {
  258. $removeHandler(scriptElement, 'readystatechange', this._scriptLoadDelegate);
  259. }
  260. if (this._scriptErrorDelegate) {
  261. this._scriptElement.removeEventListener('error', this._scriptErrorDelegate, false);
  262. this._scriptErrorDelegate = null;
  263. }
  264. this._scriptLoadDelegate = null;
  265. }
  266. },
  267. _scriptErrorHandler: function _ScriptLoaderTask$_scriptErrorHandler() {
  268. if(this._disposed) {
  269. return;
  270. }
  271. this._completedCallback(this.get_scriptElement(), false);
  272. },
  273. _scriptLoadHandler: function _ScriptLoaderTask$_scriptLoadHandler() {
  274. if(this._disposed) {
  275. return;
  276. }
  277. var scriptElement = this.get_scriptElement();
  278. if ((scriptElement.readyState !== 'loaded') &&
  279. (scriptElement.readyState !== 'complete')) {
  280. return;
  281. }
  282. this._completedCallback(scriptElement, true);
  283. }
  284. }
  285. $type.registerClass("Sys._ScriptLoaderTask", null, Sys.IDisposable);
  286. $type._clearScript = function _ScriptLoaderTask$_clearScript(scriptElement) {
  287. if (!Sys.Debug.isDebug) {
  288. scriptElement.parentNode.removeChild(scriptElement);
  289. }
  290. }
  291. $type = Sys._ScriptLoader = function _ScriptLoader() {
  292. this._scriptsToLoad = null;
  293. this._sessions = [];
  294. this._scriptLoadedDelegate = Function.createDelegate(this, this._scriptLoadedHandler);
  295. }
  296. $type.prototype = {
  297. dispose: function _ScriptLoader$dispose() {
  298. this._stopSession();
  299. this._loading = false;
  300. if(this._events) {
  301. delete this._events;
  302. }
  303. this._sessions = null;
  304. this._currentSession = null;
  305. this._scriptLoadedDelegate = null;
  306. },
  307. loadScripts: function _ScriptLoader$loadScripts(scriptTimeout, allScriptsLoadedCallback, scriptLoadFailedCallback, scriptLoadTimeoutCallback) {
  308. /// <summary locid="M:J#Sys._ScriptLoader.loadScripts">Begins loading scripts that have been queued.</summary>
  309. /// <param name="scriptTimeout" type="Number" integer="true">Timeout in seconds for loading all scripts.</param>
  310. /// <param name="allScriptsLoadedCallback" type="Function" mayBeNull="true">Callback for notification when all scripts have successfully loaded.</param>
  311. /// <param name="scriptLoadFailedCallback" type="Function" mayBeNull="true">Callback for notification when a script fails to load.</param>
  312. /// <param name="scriptLoadTimeoutCallback" type="Function" mayBeNull="true">Callback for notification when scripts have not finished loading within the given timeout.</param>
  313. var e = Function._validateParams(arguments, [
  314. {name: "scriptTimeout", type: Number, integer: true},
  315. {name: "allScriptsLoadedCallback", type: Function, mayBeNull: true},
  316. {name: "scriptLoadFailedCallback", type: Function, mayBeNull: true},
  317. {name: "scriptLoadTimeoutCallback", type: Function, mayBeNull: true}
  318. ]);
  319. if (e) throw e;
  320. var session = {
  321. allScriptsLoadedCallback: allScriptsLoadedCallback,
  322. scriptLoadFailedCallback: scriptLoadFailedCallback,
  323. scriptLoadTimeoutCallback: scriptLoadTimeoutCallback,
  324. scriptsToLoad: this._scriptsToLoad,
  325. scriptTimeout: scriptTimeout };
  326. this._scriptsToLoad = null;
  327. this._sessions.push(session);
  328. if (!this._loading) {
  329. this._nextSession();
  330. }
  331. },
  332. queueCustomScriptTag: function _ScriptLoader$queueCustomScriptTag(scriptAttributes) {
  333. /// <summary locid="M:J#Sys._ScriptLoader.queueCustomScriptTag">Queues a script reference with the given set of custom script element attributes.</summary>
  334. /// <param name="scriptAttributes" mayBeNull="false">A JSON object that describtes the attributes to apply to the script element.</param>
  335. var e = Function._validateParams(arguments, [
  336. {name: "scriptAttributes"}
  337. ]);
  338. if (e) throw e;
  339. if(!this._scriptsToLoad) {
  340. this._scriptsToLoad = [];
  341. }
  342. Array.add(this._scriptsToLoad, scriptAttributes);
  343. },
  344. queueScriptBlock: function _ScriptLoader$queueScriptBlock(scriptContent) {
  345. /// <summary locid="M:J#Sys._ScriptLoader.queueScriptBlock">Queues a script reference with literal script.</summary>
  346. /// <param name="scriptContent" type="String" mayBeNull="false">Literal script to execute.</param>
  347. var e = Function._validateParams(arguments, [
  348. {name: "scriptContent", type: String}
  349. ]);
  350. if (e) throw e;
  351. if(!this._scriptsToLoad) {
  352. this._scriptsToLoad = [];
  353. }
  354. Array.add(this._scriptsToLoad, {text: scriptContent});
  355. },
  356. queueScriptReference: function _ScriptLoader$queueScriptReference(scriptUrl) {
  357. /// <summary locid="M:J#Sys._ScriptLoader.queueScriptReference">Queues a script reference to the given script URL.</summary>
  358. /// <param name="scriptUrl" type="String" mayBeNull="false">URL to the script to reference.</param>
  359. var e = Function._validateParams(arguments, [
  360. {name: "scriptUrl", type: String}
  361. ]);
  362. if (e) throw e;
  363. if(!this._scriptsToLoad) {
  364. this._scriptsToLoad = [];
  365. }
  366. Array.add(this._scriptsToLoad, {src: scriptUrl});
  367. },
  368. _createScriptElement: function _ScriptLoader$_createScriptElement(queuedScript) {
  369. var scriptElement = document.createElement('script');
  370. scriptElement.type = 'text/javascript';
  371. for (var attr in queuedScript) {
  372. scriptElement[attr] = queuedScript[attr];
  373. }
  374. return scriptElement;
  375. },
  376. _loadScriptsInternal: function _ScriptLoader$_loadScriptsInternal() {
  377. var session = this._currentSession;
  378. if (session.scriptsToLoad && session.scriptsToLoad.length > 0) {
  379. var nextScript = Array.dequeue(session.scriptsToLoad);
  380. var scriptElement = this._createScriptElement(nextScript);
  381. if (scriptElement.text && Sys.Browser.agent === Sys.Browser.Safari) {
  382. scriptElement.innerHTML = scriptElement.text;
  383. delete scriptElement.text;
  384. }
  385. if (typeof(nextScript.src) === "string") {
  386. this._currentTask = new Sys._ScriptLoaderTask(scriptElement, this._scriptLoadedDelegate);
  387. this._currentTask.execute();
  388. }
  389. else {
  390. var headElements = document.getElementsByTagName('head');
  391. if (headElements.length === 0) {
  392. throw new Error.invalidOperation(Sys.Res.scriptLoadFailedNoHead);
  393. }
  394. else {
  395. headElements[0].appendChild(scriptElement);
  396. }
  397. Sys._ScriptLoaderTask._clearScript(scriptElement);
  398. this._loadScriptsInternal();
  399. }
  400. }
  401. else {
  402. this._stopSession();
  403. var callback = session.allScriptsLoadedCallback;
  404. if(callback) {
  405. callback(this);
  406. }
  407. this._nextSession();
  408. }
  409. },
  410. _nextSession: function _ScriptLoader$_nextSession() {
  411. if (this._sessions.length === 0) {
  412. this._loading = false;
  413. this._currentSession = null;
  414. return;
  415. }
  416. this._loading = true;
  417. var session = Array.dequeue(this._sessions);
  418. this._currentSession = session;
  419. this._loadScriptsInternal();
  420. },
  421. _raiseError: function _ScriptLoader$_raiseError() {
  422. var callback = this._currentSession.scriptLoadFailedCallback;
  423. var scriptElement = this._currentTask.get_scriptElement();
  424. this._stopSession();
  425. if(callback) {
  426. callback(this, scriptElement);
  427. this._nextSession();
  428. }
  429. else {
  430. this._loading = false;
  431. throw Sys._ScriptLoader._errorScriptLoadFailed(scriptElement.src);
  432. }
  433. },
  434. _scriptLoadedHandler: function _ScriptLoader$_scriptLoadedHandler(scriptElement, loaded) {
  435. if (loaded) {
  436. Array.add(Sys._ScriptLoader._getLoadedScripts(), scriptElement.src);
  437. this._currentTask.dispose();
  438. this._currentTask = null;
  439. this._loadScriptsInternal();
  440. }
  441. else {
  442. this._raiseError();
  443. }
  444. },
  445. _stopSession: function _ScriptLoader$_stopSession() {
  446. if(this._currentTask) {
  447. this._currentTask.dispose();
  448. this._currentTask = null;
  449. }
  450. }
  451. }
  452. $type.registerClass('Sys._ScriptLoader', null, Sys.IDisposable);
  453. $type.getInstance = function _ScriptLoader$getInstance() {
  454. var sl = Sys._ScriptLoader._activeInstance;
  455. if(!sl) {
  456. sl = Sys._ScriptLoader._activeInstance = new Sys._ScriptLoader();
  457. }
  458. return sl;
  459. }
  460. $type.isScriptLoaded = function _ScriptLoader$isScriptLoaded(scriptSrc) {
  461. var dummyScript = document.createElement('script');
  462. dummyScript.src = scriptSrc;
  463. return Array.contains(Sys._ScriptLoader._getLoadedScripts(), dummyScript.src);
  464. }
  465. $type.readLoadedScripts = function _ScriptLoader$readLoadedScripts() {
  466. if(!Sys._ScriptLoader._referencedScripts) {
  467. var referencedScripts = Sys._ScriptLoader._referencedScripts = [];
  468. var existingScripts = document.getElementsByTagName('script');
  469. for (var i = existingScripts.length - 1; i >= 0; i--) {
  470. var scriptNode = existingScripts[i];
  471. var scriptSrc = scriptNode.src;
  472. if (scriptSrc.length) {
  473. if (!Array.contains(referencedScripts, scriptSrc)) {
  474. Array.add(referencedScripts, scriptSrc);
  475. }
  476. }
  477. }
  478. }
  479. }
  480. $type._errorScriptLoadFailed = function _ScriptLoader$_errorScriptLoadFailed(scriptUrl) {
  481. var errorMessage;
  482. errorMessage = Sys.Res.scriptLoadFailedDebug;
  483. var displayMessage = "Sys.ScriptLoadFailedException: " + String.format(errorMessage, scriptUrl);
  484. var e = Error.create(displayMessage, {name: 'Sys.ScriptLoadFailedException', 'scriptUrl': scriptUrl });
  485. e.popStackFrame();
  486. return e;
  487. }
  488. $type._getLoadedScripts = function _ScriptLoader$_getLoadedScripts() {
  489. if(!Sys._ScriptLoader._referencedScripts) {
  490. Sys._ScriptLoader._referencedScripts = [];
  491. Sys._ScriptLoader.readLoadedScripts();
  492. }
  493. return Sys._ScriptLoader._referencedScripts;
  494. }
  495. $type = Sys.WebForms.PageRequestManager = function PageRequestManager() {
  496. this._form = null;
  497. this._activeDefaultButton = null;
  498. this._activeDefaultButtonClicked = false;
  499. this._updatePanelIDs = null;
  500. this._updatePanelClientIDs = null;
  501. this._updatePanelHasChildrenAsTriggers = null;
  502. this._asyncPostBackControlIDs = null;
  503. this._asyncPostBackControlClientIDs = null;
  504. this._postBackControlIDs = null;
  505. this._postBackControlClientIDs = null;
  506. this._scriptManagerID = null;
  507. this._pageLoadedHandler = null;
  508. this._additionalInput = null;
  509. this._onsubmit = null;
  510. this._onSubmitStatements = [];
  511. this._originalDoPostBack = null;
  512. this._originalDoPostBackWithOptions = null;
  513. this._originalFireDefaultButton = null;
  514. this._originalDoCallback = null;
  515. this._isCrossPost = false;
  516. this._postBackSettings = null;
  517. this._request = null;
  518. this._onFormSubmitHandler = null;
  519. this._onFormElementClickHandler = null;
  520. this._onWindowUnloadHandler = null;
  521. this._asyncPostBackTimeout = null;
  522. this._controlIDToFocus = null;
  523. this._scrollPosition = null;
  524. this._processingRequest = false;
  525. this._scriptDisposes = {};
  526. this._transientFields = ["__VIEWSTATEENCRYPTED", "__VIEWSTATEFIELDCOUNT"];
  527. }
  528. $type.prototype = {
  529. get_isInAsyncPostBack: function PageRequestManager$get_isInAsyncPostBack() {
  530. /// <value type="Boolean" locid="P:J#Sys.WebForms.PageRequestManager.isInAsyncPostBack"></value>
  531. if (arguments.length !== 0) throw Error.parameterCount();
  532. return this._request !== null;
  533. },
  534. add_beginRequest: function PageRequestManager$add_beginRequest(handler) {
  535. /// <summary locid="E:J#Sys.WebForms.PageRequestManager.beginRequest">Adds a beginRequest event handler.</summary>
  536. var e = Function._validateParams(arguments, [{name: "handler", type: Function}]);
  537. if (e) throw e;
  538. Sys.Observer.addEventHandler(this, "beginRequest", handler);
  539. },
  540. remove_beginRequest: function PageRequestManager$remove_beginRequest(handler) {
  541. var e = Function._validateParams(arguments, [{name: "handler", type: Function}]);
  542. if (e) throw e;
  543. Sys.Observer.removeEventHandler(this, "beginRequest", handler);
  544. },
  545. add_endRequest: function PageRequestManager$add_endRequest(handler) {
  546. /// <summary locid="E:J#Sys.WebForms.PageRequestManager.endRequest">Adds a endRequest event handler.</summary>
  547. var e = Function._validateParams(arguments, [{name: "handler", type: Function}]);
  548. if (e) throw e;
  549. Sys.Observer.addEventHandler(this, "endRequest", handler);
  550. },
  551. remove_endRequest: function PageRequestManager$remove_endRequest(handler) {
  552. var e = Function._validateParams(arguments, [{name: "handler", type: Function}]);
  553. if (e) throw e;
  554. Sys.Observer.removeEventHandler(this, "endRequest", handler);
  555. },
  556. add_initializeRequest: function PageRequestManager$add_initializeRequest(handler) {
  557. /// <summary locid="E:J#Sys.WebForms.PageRequestManager.initializeRequest">Adds a initializeRequest event handler.</summary>
  558. var e = Function._validateParams(arguments, [{name: "handler", type: Function}]);
  559. if (e) throw e;
  560. Sys.Observer.addEventHandler(this, "initializeRequest", handler);
  561. },
  562. remove_initializeRequest: function PageRequestManager$remove_initializeRequest(handler) {
  563. var e = Function._validateParams(arguments, [{name: "handler", type: Function}]);
  564. if (e) throw e;
  565. Sys.Observer.removeEventHandler(this, "initializeRequest", handler);
  566. },
  567. add_pageLoaded: function PageRequestManager$add_pageLoaded(handler) {
  568. /// <summary locid="E:J#Sys.WebForms.PageRequestManager.pageLoaded">Adds a pageLoaded event handler.</summary>
  569. var e = Function._validateParams(arguments, [{name: "handler", type: Function}]);
  570. if (e) throw e;
  571. Sys.Observer.addEventHandler(this, "pageLoaded", handler);
  572. },
  573. remove_pageLoaded: function PageRequestManager$remove_pageLoaded(handler) {
  574. var e = Function._validateParams(arguments, [{name: "handler", type: Function}]);
  575. if (e) throw e;
  576. Sys.Observer.removeEventHandler(this, "pageLoaded", handler);
  577. },
  578. add_pageLoading: function PageRequestManager$add_pageLoading(handler) {
  579. /// <summary locid="E:J#Sys.WebForms.PageRequestManager.pageLoading">Adds a pageLoading event handler.</summary>
  580. var e = Function._validateParams(arguments, [{name: "handler", type: Function}]);
  581. if (e) throw e;
  582. Sys.Observer.addEventHandler(this, "pageLoading", handler);
  583. },
  584. remove_pageLoading: function PageRequestManager$remove_pageLoading(handler) {
  585. var e = Function._validateParams(arguments, [{name: "handler", type: Function}]);
  586. if (e) throw e;
  587. Sys.Observer.removeEventHandler(this, "pageLoading", handler);
  588. },
  589. abortPostBack: function PageRequestManager$abortPostBack() {
  590. if (!this._processingRequest && this._request) {
  591. this._request.get_executor().abort();
  592. this._request = null;
  593. }
  594. },
  595. beginAsyncPostBack: function PageRequestManager$beginAsyncPostBack(updatePanelsToUpdate, eventTarget, eventArgument, causesValidation, validationGroup) {
  596. /// <summary locid="M:J#Sys.WebForms.PageRequestManager.beginAsyncPostBack">Begins an asynchronous postback.</summary>
  597. /// <param name="updatePanelsToUpdate" type="Array" elementType="String" mayBeNull="true" optional="true">A list of UniqueIDs or ClientIDs of UpdatePanel controls that should have their rendering updated.</param>
  598. /// <param name="eventTarget" type="String" mayBeNull="true" optional="true"></param>
  599. /// <param name="eventArgument" type="String" mayBeNull="true" optional="true"></param>
  600. /// <param name="causesValidation" type="Boolean" mayBeNull="true" optional="true"></param>
  601. /// <param name="validationGroup" type="String" mayBeNull="true" optional="true"></param>
  602. var e = Function._validateParams(arguments, [
  603. {name: "updatePanelsToUpdate", type: Array, mayBeNull: true, optional: true, elementType: String},
  604. {name: "eventTarget", type: String, mayBeNull: true, optional: true},
  605. {name: "eventArgument", type: String, mayBeNull: true, optional: true},
  606. {name: "causesValidation", type: Boolean, mayBeNull: true, optional: true},
  607. {name: "validationGroup", type: String, mayBeNull: true, optional: true}
  608. ]);
  609. if (e) throw e;
  610. if (causesValidation && (typeof(Page_ClientValidate) === 'function') && !Page_ClientValidate(validationGroup || null)) {
  611. return;
  612. }
  613. this._postBackSettings = this._createPostBackSettings(true, updatePanelsToUpdate, eventTarget);
  614. var form = this._form;
  615. form.__EVENTTARGET.value = (eventTarget || "");
  616. form.__EVENTARGUMENT.value = (eventArgument || "");
  617. this._isCrossPost = false;
  618. this._additionalInput = null;
  619. this._onFormSubmit();
  620. },
  621. _cancelPendingCallbacks: function PageRequestManager$_cancelPendingCallbacks() {
  622. for (var i = 0, l = window.__pendingCallbacks.length; i < l; i++) {
  623. var callback = window.__pendingCallbacks[i];
  624. if (callback) {
  625. if (!callback.async) {
  626. window.__synchronousCallBackIndex = -1;
  627. }
  628. window.__pendingCallbacks[i] = null;
  629. var callbackFrameID = "__CALLBACKFRAME" + i;
  630. var xmlRequestFrame = document.getElementById(callbackFrameID);
  631. if (xmlRequestFrame) {
  632. xmlRequestFrame.parentNode.removeChild(xmlRequestFrame);
  633. }
  634. }
  635. }
  636. },
  637. _commitControls: function PageRequestManager$_commitControls(updatePanelData, asyncPostBackTimeout) {
  638. if (updatePanelData) {
  639. this._updatePanelIDs = updatePanelData.updatePanelIDs;
  640. this._updatePanelClientIDs = updatePanelData.updatePanelClientIDs;
  641. this._updatePanelHasChildrenAsTriggers = updatePanelData.updatePanelHasChildrenAsTriggers;
  642. this._asyncPostBackControlIDs = updatePanelData.asyncPostBackControlIDs;
  643. this._asyncPostBackControlClientIDs = updatePanelData.asyncPostBackControlClientIDs;
  644. this._postBackControlIDs = updatePanelData.postBackControlIDs;
  645. this._postBackControlClientIDs = updatePanelData.postBackControlClientIDs;
  646. }
  647. if (typeof(asyncPostBackTimeout) !== 'undefined' && asyncPostBackTimeout !== null) {
  648. this._asyncPostBackTimeout = asyncPostBackTimeout * 1000;
  649. }
  650. },
  651. _createHiddenField: function PageRequestManager$_createHiddenField(id, value) {
  652. var container, field = document.getElementById(id);
  653. if (field) {
  654. if (!field._isContained) {
  655. field.parentNode.removeChild(field);
  656. }
  657. else {
  658. container = field.parentNode;
  659. }
  660. }
  661. if (!container) {
  662. container = document.createElement('span');
  663. container.style.cssText = "display:none !important";
  664. this._form.appendChild(container);
  665. }
  666. container.innerHTML = "<input type='hidden' />";
  667. field = container.childNodes[0];
  668. field._isContained = true;
  669. field.id = field.name = id;
  670. field.value = value;
  671. },
  672. _createPageRequestManagerTimeoutError: function PageRequestManager$_createPageRequestManagerTimeoutError() {
  673. var displayMessage = "Sys.WebForms.PageRequestManagerTimeoutException: " + Sys.WebForms.Res.PRM_TimeoutError;
  674. var e = Error.create(displayMessage, {name: 'Sys.WebForms.PageRequestManagerTimeoutException'});
  675. e.popStackFrame();
  676. return e;
  677. },
  678. _createPageRequestManagerServerError: function PageRequestManager$_createPageRequestManagerServerError(httpStatusCode, message) {
  679. var displayMessage = "Sys.WebForms.PageRequestManagerServerErrorException: " +
  680. (message || String.format(Sys.WebForms.Res.PRM_ServerError, httpStatusCode));
  681. var e = Error.create(displayMessage, {
  682. name: 'Sys.WebForms.PageRequestManagerServerErrorException',
  683. httpStatusCode: httpStatusCode
  684. });
  685. e.popStackFrame();
  686. return e;
  687. },
  688. _createPageRequestManagerParserError: function PageRequestManager$_createPageRequestManagerParserError(parserErrorMessage) {
  689. var displayMessage = "Sys.WebForms.PageRequestManagerParserErrorException: " + String.format(Sys.WebForms.Res.PRM_ParserError, parserErrorMessage);
  690. var e = Error.create(displayMessage, {name: 'Sys.WebForms.PageRequestManagerParserErrorException'});
  691. e.popStackFrame();
  692. return e;
  693. },
  694. _createPanelID: function PageRequestManager$_createPanelID(panelsToUpdate, postBackSettings) {
  695. var asyncTarget = postBackSettings.asyncTarget,
  696. toUpdate = this._ensureUniqueIds(panelsToUpdate || postBackSettings.panelsToUpdate),
  697. panelArg = (toUpdate instanceof Array)
  698. ? toUpdate.join(',')
  699. : (toUpdate || this._scriptManagerID);
  700. if (asyncTarget) {
  701. panelArg += "|" + asyncTarget;
  702. }
  703. return encodeURIComponent(this._scriptManagerID) + '=' + encodeURIComponent(panelArg) + '&';
  704. },
  705. _createPostBackSettings: function PageRequestManager$_createPostBackSettings(async, panelsToUpdate, asyncTarget, sourceElement) {
  706. return { async:async, asyncTarget: asyncTarget, panelsToUpdate: panelsToUpdate, sourceElement: sourceElement };
  707. },
  708. _convertToClientIDs: function PageRequestManager$_convertToClientIDs(source, destinationIDs, destinationClientIDs, version4) {
  709. if (source) {
  710. for (var i = 0, l = source.length; i < l; i += (version4 ? 2 : 1)) {
  711. var uniqueID = source[i],
  712. clientID = (version4 ? source[i+1] : "") || this._uniqueIDToClientID(uniqueID);
  713. Array.add(destinationIDs, uniqueID);
  714. Array.add(destinationClientIDs, clientID);
  715. }
  716. }
  717. },
  718. dispose: function PageRequestManager$dispose() {
  719. Sys.Observer.clearEventHandlers(this);
  720. if (this._form) {
  721. Sys.UI.DomEvent.removeHandler(this._form, 'submit', this._onFormSubmitHandler);
  722. Sys.UI.DomEvent.removeHandler(this._form, 'click', this._onFormElementClickHandler);
  723. Sys.UI.DomEvent.removeHandler(window, 'unload', this._onWindowUnloadHandler);
  724. Sys.UI.DomEvent.removeHandler(window, 'load', this._pageLoadedHandler);
  725. }
  726. if (this._originalDoPostBack) {
  727. window.__doPostBack = this._originalDoPostBack;
  728. this._originalDoPostBack = null;
  729. }
  730. if (this._originalDoPostBackWithOptions) {
  731. window.WebForm_DoPostBackWithOptions = this._originalDoPostBackWithOptions;
  732. this._originalDoPostBackWithOptions = null;
  733. }
  734. if (this._originalFireDefaultButton) {
  735. window.WebForm_FireDefaultButton = this._originalFireDefaultButton;
  736. this._originalFireDefaultButton = null;
  737. }
  738. if (this._originalDoCallback) {
  739. window.WebForm_DoCallback = this._originalDoCallback;
  740. this._originalDoCallback = null;
  741. }
  742. this._form = null;
  743. this._updatePanelIDs = null;
  744. this._updatePanelClientIDs = null;
  745. this._asyncPostBackControlIDs = null;
  746. this._asyncPostBackControlClientIDs = null;
  747. this._postBackControlIDs = null;
  748. this._postBackControlClientIDs = null;
  749. this._asyncPostBackTimeout = null;
  750. this._scrollPosition = null;
  751. },
  752. _doCallback: function PageRequestManager$_doCallback(eventTarget, eventArgument, eventCallback, context, errorCallback, useAsync) {
  753. if (!this.get_isInAsyncPostBack()) {
  754. this._originalDoCallback(eventTarget, eventArgument, eventCallback, context, errorCallback, useAsync);
  755. }
  756. },
  757. _doPostBack: function PageRequestManager$_doPostBack(eventTarget, eventArgument) {
  758. this._additionalInput = null;
  759. var form = this._form;
  760. if ((eventTarget === null) || (typeof(eventTarget) === "undefined") || (this._isCrossPost)) {
  761. this._postBackSettings = this._createPostBackSettings(false);
  762. this._isCrossPost = false;
  763. }
  764. else {
  765. var mpUniqueID = this._masterPageUniqueID;
  766. var clientID = this._uniqueIDToClientID(eventTarget);
  767. var postBackElement = document.getElementById(clientID);
  768. if (!postBackElement && mpUniqueID) {
  769. if (clientID.indexOf(mpUniqueID + "$") === 0) {
  770. postBackElement = document.getElementById(clientID.substr(mpUniqueID.length + 1));
  771. }
  772. }
  773. if (!postBackElement) {
  774. if (Array.contains(this._asyncPostBackControlIDs, eventTarget)) {
  775. this._postBackSettings = this._createPostBackSettings(true, null, eventTarget);
  776. }
  777. else {
  778. if (Array.contains(this._postBackControlIDs, eventTarget)) {
  779. this._postBackSettings = this._createPostBackSettings(false);
  780. }
  781. else {
  782. var nearestUniqueIDMatch = this._findNearestElement(eventTarget);
  783. if (nearestUniqueIDMatch) {
  784. this._postBackSettings = this._getPostBackSettings(nearestUniqueIDMatch, eventTarget);
  785. }
  786. else {
  787. if (mpUniqueID) {
  788. mpUniqueID += "$";
  789. if (eventTarget.indexOf(mpUniqueID) === 0) {
  790. nearestUniqueIDMatch = this._findNearestElement(eventTarget.substr(mpUniqueID.length));
  791. }
  792. }
  793. if (nearestUniqueIDMatch) {
  794. this._postBackSettings = this._getPostBackSettings(nearestUniqueIDMatch, eventTarget);
  795. }
  796. else {
  797. this._postBackSettings = this._createPostBackSettings(false);
  798. }
  799. }
  800. }
  801. }
  802. }
  803. else {
  804. this._postBackSettings = this._getPostBackSettings(postBackElement, eventTarget);
  805. }
  806. }
  807. if (!this._postBackSettings.async) {
  808. form.onsubmit = this._onsubmit;
  809. this._originalDoPostBack(eventTarget, eventArgument);
  810. form.onsubmit = null;
  811. return;
  812. }
  813. form.__EVENTTARGET.value = eventTarget;
  814. form.__EVENTARGUMENT.value = eventArgument;
  815. this._onFormSubmit();
  816. },
  817. _doPostBackWithOptions: function PageRequestManager$_doPostBackWithOptions(options) {
  818. this._isCrossPost = options && options.actionUrl;
  819. this._originalDoPostBackWithOptions(options);
  820. },
  821. _elementContains: function PageRequestManager$_elementContains(container, element) {
  822. while (element) {
  823. if (element === container) {
  824. return true;
  825. }
  826. element = element.parentNode;
  827. }
  828. return false;
  829. },
  830. _endPostBack: function PageRequestManager$_endPostBack(error, executor, data) {
  831. if (this._request === executor.get_webRequest()) {
  832. this._processingRequest = false;
  833. this._additionalInput = null;
  834. this._request = null;
  835. }
  836. var eventArgs = new Sys.WebForms.EndRequestEventArgs(error, data ? data.dataItems : {}, executor);
  837. Sys.Observer.raiseEvent(this, "endRequest", eventArgs);
  838. if (error && !eventArgs.get_errorHandled()) {
  839. throw error;
  840. }
  841. },
  842. _ensureUniqueIds: function PageRequestManager$_ensureUniqueIds(ids) {
  843. if (!ids) return ids;
  844. ids = ids instanceof Array ? ids : [ids];
  845. var uniqueIds = [];
  846. for (var i = 0, l = ids.length; i < l; i++) {
  847. var id = ids[i], index = Array.indexOf(this._updatePanelClientIDs, id);
  848. uniqueIds.push(index > -1 ? this._updatePanelIDs[index] : id);
  849. }
  850. return uniqueIds;
  851. },
  852. _findNearestElement: function PageRequestManager$_findNearestElement(uniqueID) {
  853. while (uniqueID.length > 0) {
  854. var clientID = this._uniqueIDToClientID(uniqueID);
  855. var element = document.getElementById(clientID);
  856. if (element) {
  857. return element;
  858. }
  859. var indexOfLastDollar = uniqueID.lastIndexOf('$');
  860. if (indexOfLastDollar === -1) {
  861. return null;
  862. }
  863. uniqueID = uniqueID.substring(0, indexOfLastDollar);
  864. }
  865. return null;
  866. },
  867. _findText: function PageRequestManager$_findText(text, location) {
  868. var startIndex = Math.max(0, location - 20);
  869. var endIndex = Math.min(text.length, location + 20);
  870. return text.substring(startIndex, endIndex);
  871. },
  872. _fireDefaultButton: function PageRequestManager$_fireDefaultButton(event, target) {
  873. if (event.keyCode === 13) {
  874. var src = event.srcElement || event.target;
  875. if (!src || (src.tagName.toLowerCase() !== "textarea")) {
  876. var defaultButton = document.getElementById(target);
  877. if (defaultButton && (typeof(defaultButton.click) !== "undefined")) {
  878. this._activeDefaultButton = defaultButton;
  879. this._activeDefaultButtonClicked = false;
  880. try {
  881. defaultButton.click();
  882. }
  883. finally {
  884. this._activeDefaultButton = null;
  885. }
  886. event.cancelBubble = true;
  887. if (typeof(event.stopPropagation) === "function") {
  888. event.stopPropagation();
  889. }
  890. return false;
  891. }
  892. }
  893. }
  894. return true;
  895. },
  896. _getPageLoadedEventArgs: function PageRequestManager$_getPageLoadedEventArgs(initialLoad, data) {
  897. var updated = [];
  898. var created = [];
  899. var version4 = data ? data.version4 : false;
  900. var upData = data ? data.updatePanelData : null;
  901. var newIDs, newClientIDs, childIDs, refreshedIDs;
  902. if (!upData) {
  903. newIDs = this._updatePanelIDs;
  904. newClientIDs = this._updatePanelClientIDs;
  905. childIDs = null;
  906. refreshedIDs = null;
  907. }
  908. else {
  909. newIDs = upData.updatePanelIDs;
  910. newClientIDs = upData.updatePanelClientIDs;
  911. childIDs = upData.childUpdatePanelIDs;
  912. refreshedIDs = upData.panelsToRefreshIDs;
  913. }
  914. var i, l, uniqueID, clientID;
  915. if (refreshedIDs) {
  916. for (i = 0, l = refreshedIDs.length; i < l; i += (version4 ? 2 : 1)) {
  917. uniqueID = refreshedIDs[i];
  918. clientID = (version4 ? refreshedIDs[i+1] : "") || this._uniqueIDToClientID(uniqueID);
  919. Array.add(updated, document.getElementById(clientID));
  920. }
  921. }
  922. for (i = 0, l = newIDs.length; i < l; i++) {
  923. if (initialLoad || Array.indexOf(childIDs, newIDs[i]) !== -1) {
  924. Array.add(created, document.getElementById(newClientIDs[i]));
  925. }
  926. }
  927. return new Sys.WebForms.PageLoadedEventArgs(updated, created, data ? data.dataItems : {});
  928. },
  929. _getPageLoadingEventArgs: function PageRequestManager$_getPageLoadingEventArgs(data) {
  930. var updated = [],
  931. deleted = [],
  932. upData = data.updatePanelData,
  933. oldIDs = upData.oldUpdatePanelIDs,
  934. oldClientIDs = upData.oldUpdatePanelClientIDs,
  935. newIDs = upData.updatePanelIDs,
  936. childIDs = upData.childUpdatePanelIDs,
  937. refreshedIDs = upData.panelsToRefreshIDs,
  938. i, l, uniqueID, clientID,
  939. version4 = data.version4;
  940. for (i = 0, l = refreshedIDs.length; i < l; i += (version4 ? 2 : 1)) {
  941. uniqueID = refreshedIDs[i];
  942. clientID = (version4 ? refreshedIDs[i+1] : "") || this._uniqueIDToClientID(uniqueID);
  943. Array.add(updated, document.getElementById(clientID));
  944. }
  945. for (i = 0, l = oldIDs.length; i < l; i++) {
  946. uniqueID = oldIDs[i];
  947. if (Array.indexOf(refreshedIDs, uniqueID) === -1 &&
  948. (Array.indexOf(newIDs, uniqueID) === -1 || Array.indexOf(childIDs, uniqueID) > -1)) {
  949. Array.add(deleted, document.getElementById(oldClientIDs[i]));
  950. }
  951. }
  952. return new Sys.WebForms.PageLoadingEventArgs(updated, deleted, data.dataItems);
  953. },
  954. _getPostBackSettings: function PageRequestManager$_getPostBackSettings(element, elementUniqueID) {
  955. var originalElement = element;
  956. var proposedSettings = null;
  957. while (element) {
  958. if (element.id) {
  959. if (!proposedSettings && Array.contains(this._asyncPostBackControlClientIDs, element.id)) {
  960. proposedSettings = this._createPostBackSettings(true, null, elementUniqueID, originalElement);
  961. }
  962. else {
  963. if (!proposedSettings && Array.contains(this._postBackControlClientIDs, element.id)) {
  964. return this._createPostBackSettings(false);
  965. }
  966. else {
  967. var indexOfPanel = Array.indexOf(this._updatePanelClientIDs, element.id);
  968. if (indexOfPanel !== -1) {
  969. if (this._updatePanelHasChildrenAsTriggers[indexOfPanel]) {
  970. return this._createPostBackSettings(true, [this._updatePanelIDs[indexOfPanel]], elementUniqueID, originalElement);
  971. }
  972. else {
  973. return this._createPostBackSettings(true, null, elementUniqueID, originalElement);
  974. }
  975. }
  976. }
  977. }
  978. if (!proposedSettings && this._matchesParentIDInList(element.id, this._asyncPostBackControlClientIDs)) {
  979. proposedSettings = this._createPostBackSettings(true, null, elementUniqueID, originalElement);
  980. }
  981. else {
  982. if (!proposedSettings && this._matchesParentIDInList(element.id, this._postBackControlClientIDs)) {
  983. return this._createPostBackSettings(false);
  984. }
  985. }
  986. }
  987. element = element.parentNode;
  988. }
  989. if (!proposedSettings) {
  990. return this._createPostBackSettings(false);
  991. }
  992. else {
  993. return proposedSettings;
  994. }
  995. },
  996. _getScrollPosition: function PageRequestManager$_getScrollPosition() {
  997. var d = document.documentElement;
  998. if (d && (this._validPosition(d.scrollLeft) || this._validPosition(d.scrollTop))) {
  999. return {
  1000. x: d.scrollLeft,
  1001. y: d.scrollTop
  1002. };
  1003. }
  1004. else {
  1005. d = document.body;
  1006. if (d && (this._validPosition(d.scrollLeft) || this._validPosition(d.scrollTop))) {
  1007. return {
  1008. x: d.scrollLeft,
  1009. y: d.scrollTop
  1010. };
  1011. }
  1012. else {
  1013. if (this._validPosition(window.pageXOffset) || this._validPosition(window.pageYOffset)) {
  1014. return {
  1015. x: window.pageXOffset,
  1016. y: window.pageYOffset
  1017. };
  1018. }
  1019. else {
  1020. return {
  1021. x: 0,
  1022. y: 0
  1023. };
  1024. }
  1025. }
  1026. }
  1027. },
  1028. _initializeInternal: function PageRequestManager$_initializeInternal(scriptManagerID, formElement, updatePanelIDs, asyncPostBackControlIDs, postBackControlIDs, asyncPostBackTimeout, masterPageUniqueID) {
  1029. if (this._prmInitialized) {
  1030. throw Error.invalidOperation(Sys.WebForms.Res.PRM_CannotRegisterTwice);
  1031. }
  1032. this._prmInitialized = true;
  1033. this._masterPageUniqueID = masterPageUniqueID;
  1034. this._scriptManagerID = scriptManagerID;
  1035. this._form = Sys.UI.DomElement.resolveElement(formElement);
  1036. this._onsubmit = this._form.onsubmit;
  1037. this._form.onsubmit = null;
  1038. this._onFormSubmitHandler = Function.createDelegate(this, this._onFormSubmit);
  1039. this._onFormElementClickHandler = Function.createDelegate(this, this._onFormElementClick);
  1040. this._onWindowUnloadHandler = Function.createDelegate(this, this._onWindowUnload);
  1041. Sys.UI.DomEvent.addHandler(this._form, 'submit', this._onFormSubmitHandler);
  1042. Sys.UI.DomEvent.addHandler(this._form, 'click', this._onFormElementClickHandler);
  1043. Sys.UI.DomEvent.addHandler(window, 'unload', this._onWindowUnloadHandler);
  1044. this._originalDoPostBack = window.__doPostBack;
  1045. if (this._originalDoPostBack) {
  1046. window.__doPostBack = Function.createDelegate(this, this._doPostBack);
  1047. }
  1048. this._originalDoPostBackWithOptions = window.WebForm_DoPostBackWithOptions;
  1049. if (this._originalDoPostBackWithOptions) {
  1050. window.WebForm_DoPostBackWithOptions = Function.createDelegate(this, this._doPostBackWithOptions);
  1051. }
  1052. this._originalFireDefaultButton = window.WebForm_FireDefaultButton;
  1053. if (this._originalFireDefaultButton) {
  1054. window.WebForm_FireDefaultButton = Function.createDelegate(this, this._fireDefaultButton);
  1055. }
  1056. this._originalDoCallback = window.WebForm_DoCallback;
  1057. if (this._originalDoCallback) {
  1058. window.WebForm_DoCallback = Function.createDelegate(this, this._doCallback);
  1059. }
  1060. this._pageLoadedHandler = Function.createDelegate(this, this._pageLoadedInitialLoad);
  1061. Sys.UI.DomEvent.addHandler(window, 'load', this._pageLoadedHandler);
  1062. if (updatePanelIDs) {
  1063. this._updateControls(updatePanelIDs, asyncPostBackControlIDs, postBackControlIDs, asyncPostBackTimeout, true);
  1064. }
  1065. },
  1066. _matchesParentIDInList: function PageRequestManager$_matchesParentIDInList(clientID, parentIDList) {
  1067. for (var i = 0, l = parentIDList.length; i < l; i++) {
  1068. if (clientID.startsWith(parentIDList[i] + "_")) {
  1069. return true;
  1070. }
  1071. }
  1072. return false;
  1073. },
  1074. _onFormElementActive: function PageRequestManager$_onFormElementActive(element, offsetX, offsetY) {
  1075. if (element.disabled) {
  1076. return;
  1077. }
  1078. this._postBackSettings = this._getPostBackSettings(element, element.name);
  1079. if (element.name) {
  1080. var tagName = element.tagName.toUpperCase();
  1081. if (tagName === 'INPUT') {
  1082. var type = element.type;
  1083. if (type === 'submit') {
  1084. this._additionalInput = encodeURIComponent(element.name) + '=' + encodeURIComponent(element.value);
  1085. }
  1086. else if (type === 'image') {
  1087. this._additionalInput = encodeURIComponent(element.name) + '.x=' + offsetX + '&' + encodeURIComponent(element.name) + '.y=' + offsetY;
  1088. }
  1089. }
  1090. else if ((tagName === 'BUTTON') && (element.name.length !== 0) && (element.type === 'submit')) {
  1091. this._additionalInput = encodeURIComponent(element.name) + '=' + encodeURIComponent(element.value);
  1092. }
  1093. }
  1094. },
  1095. _onFormElementClick: function PageRequestManager$_onFormElementClick(evt) {
  1096. this._activeDefaultButtonClicked = (evt.target === this._activeDefaultButton);
  1097. this._onFormElementActive(evt.target, evt.offsetX, evt.offsetY);
  1098. },
  1099. _onFormSubmit: function PageRequestManager$_onFormSubmit(evt) {
  1100. var i, l, continueSubmit = true,
  1101. isCrossPost = this._isCrossPost;
  1102. this._isCrossPost = false;
  1103. if (this._onsubmit) {
  1104. continueSubmit = this._onsubmit();
  1105. }
  1106. if (continueSubmit) {
  1107. for (i = 0, l = this._onSubmitStatements.length; i < l; i++) {
  1108. if (!this._onSubmitStatements[i]()) {
  1109. continueSubmit = false;
  1110. break;
  1111. }
  1112. }
  1113. }
  1114. if (!continueSubmit) {
  1115. if (evt) {
  1116. evt.preventDefault();
  1117. }
  1118. return;
  1119. }
  1120. var form = this._form;
  1121. if (isCrossPost) {
  1122. return;
  1123. }
  1124. if (this._activeDefaultButton && !this._activeDefaultButtonClicked) {
  1125. this._onFormElementActive(this._activeDefaultButton, 0, 0);
  1126. }
  1127. if (!this._postBackSettings || !this._postBackSettings.async) {
  1128. return;
  1129. }
  1130. var formBody = new Sys.StringBuilder(),
  1131. count = form.elements.length,
  1132. panelID = this._createPanelID(null, this._postBackSettings);
  1133. formBody.append(panelID);
  1134. for (i = 0; i < count; i++) {
  1135. var element = form.elements[i];
  1136. var name = element.name;
  1137. if (typeof(name) === "undefined" || (name === null) || (name.length === 0) || (name === this._scriptManagerID)) {
  1138. continue;
  1139. }
  1140. var tagName = element.tagName.toUpperCase();
  1141. if (tagName === 'INPUT') {
  1142. var type = element.type;
  1143. if ((type === 'text') ||
  1144. (type === 'password') ||
  1145. (type === 'hidden') ||
  1146. (((type === 'checkbox') || (type === 'radio')) && element.checked)) {
  1147. formBody.append(encodeURIComponent(name));
  1148. formBody.append('=');
  1149. formBody.append(encodeURIComponent(element.value));
  1150. formBody.append('&');
  1151. }
  1152. }
  1153. else if (tagName === 'SELECT') {
  1154. var optionCount = element.options.length;
  1155. for (var j = 0; j < optionCount; j++) {
  1156. var option = element.options[j];
  1157. if (option.selected) {
  1158. formBody.append(encodeURIComponent(name));
  1159. formBody.append('=');
  1160. formBody.append(encodeURIComponent(option.value));
  1161. formBody.append('&');
  1162. }
  1163. }
  1164. }
  1165. else if (tagName === 'TEXTAREA') {
  1166. formBody.append(encodeURIComponent(name));
  1167. formBody.append('=');
  1168. formBody.append(encodeURIComponent(element.value));
  1169. formBody.append('&');
  1170. }
  1171. }
  1172. formBody.append("__ASYNCPOST=true&");
  1173. if (this._additionalInput) {
  1174. formBody.append(this._additionalInput);
  1175. this._additionalInput = null;
  1176. }
  1177. var request = new Sys.Net.WebRequest();
  1178. var action = form.action;
  1179. if (Sys.Browser.agent === Sys.Browser.InternetExplorer) {
  1180. var fragmentIndex = action.indexOf('#');
  1181. if (fragmentIndex !== -1) {
  1182. action = action.substr(0, fragmentIndex);
  1183. }
  1184. var queryIndex = action.indexOf('?');
  1185. if (queryIndex !== -1) {
  1186. var path = action.substr(0, queryIndex);
  1187. if (path.indexOf("%") === -1) {
  1188. action = encodeURI(path) + action.substr(queryIndex);
  1189. }
  1190. }
  1191. else if (action.indexOf("%") === -1) {
  1192. action = encodeURI(action);
  1193. }
  1194. }
  1195. request.set_url(action);
  1196. request.get_headers()['X-MicrosoftAjax'] = 'Delta=true';
  1197. request.get_headers()['Cache-Control'] = 'no-cache';
  1198. request.set_timeout(this._asyncPostBackTimeout);
  1199. request.add_completed(Function.createDelegate(this, this._onFormSubmitCompleted));
  1200. request.set_body(formBody.toString());
  1201. var panelsToUpdate, eventArgs;
  1202. panelsToUpdate = this._postBackSettings.panelsToUpdate;
  1203. eventArgs = new Sys.WebForms.InitializeRequestEventArgs(request, this._postBackSettings.sourceElement, panelsToUpdate);
  1204. Sys.Observer.raiseEvent(this, "initializeRequest", eventArgs);
  1205. continueSubmit = !eventArgs.get_cancel();
  1206. if (!continueSubmit) {
  1207. if (evt) {
  1208. evt.preventDefault();
  1209. }
  1210. return;
  1211. }
  1212. if (eventArgs && eventArgs._updated) {
  1213. panelsToUpdate = eventArgs.get_updatePanelsToUpdate();
  1214. request.set_body(request.get_body().replace(panelID, this._createPanelID(panelsToUpdate, this._postBackSettings)));
  1215. }
  1216. this._scrollPosition = this._getScrollPosition();
  1217. this.abortPostBack();
  1218. eventArgs = new Sys.WebForms.BeginRequestEventArgs(request, this._postBackSettings.sourceElement,
  1219. panelsToUpdate || this._postBackSettings.panelsToUpdate);
  1220. Sys.Observer.raiseEvent(this, "beginRequest", eventArgs);
  1221. if (this._originalDoCallback) {
  1222. this._cancelPendingCallbacks();
  1223. }
  1224. this._request = request;
  1225. this._processingRequest = false;
  1226. request.invoke();
  1227. if (evt) {
  1228. evt.preventDefault();
  1229. }
  1230. },
  1231. _onFormSubmitCompleted: function PageRequestManager$_onFormSubmitCompleted(sender, eventArgs) {
  1232. this._processingRequest = true;
  1233. if (sender.get_timedOut()) {
  1234. this._endPostBack(this._createPageRequestManagerTimeoutError(), sender, null);
  1235. return;
  1236. }
  1237. if (sender.get_aborted()) {
  1238. this._endPostBack(null, sender, null);
  1239. return;
  1240. }
  1241. if (!this._request || (sender.get_webRequest() !== this._request)) {
  1242. return;
  1243. }
  1244. if (sender.get_statusCode() !== 200) {
  1245. this._endPostBack(this._createPageRequestManagerServerError(sender.get_statusCode()), sender, null);
  1246. return;
  1247. }
  1248. var data = this._parseDelta(sender);
  1249. if (!data) return;
  1250. var i, l;
  1251. if (data.asyncPostBackControlIDsNode && data.postBackControlIDsNode &&
  1252. data.updatePanelIDsNode && data.panelsToRefreshNode && data.childUpdatePanelIDsNode) {
  1253. var oldUpdatePanelIDs = this._updatePanelIDs,
  1254. oldUpdatePanelClientIDs = this._updatePanelClientIDs;
  1255. var childUpdatePanelIDsString = data.childUpdatePanelIDsNode.content;
  1256. var childUpdatePanelIDs = childUpdatePanelIDsString.length ? childUpdatePanelIDsString.split(',') : [];
  1257. var asyncPostBackControlIDsArray = this._splitNodeIntoArray(data.asyncPostBackControlIDsNode);
  1258. var postBackControlIDsArray = this._splitNodeIntoArray(data.postBackControlIDsNode);
  1259. var updatePanelIDsArray = this._splitNodeIntoArray(data.updatePanelIDsNode);
  1260. var panelsToRefreshIDs = this._splitNodeIntoArray(data.panelsToRefreshNode);
  1261. var v4 = data.version4;
  1262. for (i = 0, l = panelsToRefreshIDs.length; i < l; i+= (v4 ? 2 : 1)) {
  1263. var panelClientID = (v4 ? panelsToRefreshIDs[i+1] : "") || this._uniqueIDToClientID(panelsToRefreshIDs[i]);
  1264. if (!document.getElementById(panelClientID)) {
  1265. this._endPostBack(Error.invalidOperation(String.format(Sys.WebForms.Res.PRM_MissingPanel, panelClientID)), sender, data);
  1266. return;
  1267. }
  1268. }
  1269. var updatePanelData = this._processUpdatePanelArrays(
  1270. updatePanelIDsArray,
  1271. asyncPostBackControlIDsArray,
  1272. postBackControlIDsArray, v4);
  1273. updatePanelData.oldUpdatePanelIDs = oldUpdatePanelIDs;
  1274. updatePanelData.oldUpdatePanelClientIDs = oldUpdatePanelClientIDs;
  1275. updatePanelData.childUpdatePanelIDs = childUpdatePanelIDs;
  1276. updatePanelData.panelsToRefreshIDs = panelsToRefreshIDs;
  1277. data.updatePanelData = updatePanelData;
  1278. }
  1279. data.dataItems = {};
  1280. var node;
  1281. for (i = 0, l = data.dataItemNodes.length; i < l; i++) {
  1282. node = data.dataItemNodes[i];
  1283. data.dataItems[node.id] = node.content;
  1284. }
  1285. for (i = 0, l = data.dataItemJsonNodes.length; i < l; i++) {
  1286. node = data.dataItemJsonNodes[i];
  1287. data.dataItems[node.id] = Sys.Serialization.JavaScriptSerializer.deserialize(node.content);
  1288. }
  1289. var handler = Sys.Observer._getContext(this, true).events.getHandler("pageLoading");
  1290. if (handler) {
  1291. handler(this, this._getPageLoadingEventArgs(data));
  1292. }
  1293. Sys._ScriptLoader.readLoadedScripts();
  1294. Sys.Application.beginCreateComponents();
  1295. var scriptLoader = Sys._ScriptLoader.getInstance();
  1296. this._queueScripts(scriptLoader, data.scriptBlockNodes, true, false);
  1297. this._processingRequest = true;
  1298. scriptLoader.loadScripts(0,
  1299. Function.createDelegate(this, Function.createCallback(this._scriptIncludesLoadComplete, data)),
  1300. Function.createDelegate(this, Function.createCallback(this._scriptIncludesLoadFailed, data)),
  1301. null);
  1302. },
  1303. _onWindowUnload: function PageRequestManager$_onWindowUnload(evt) {
  1304. this.dispose();
  1305. },
  1306. _pageLoaded: function PageRequestManager$_pageLoaded(initialLoad, data) {
  1307. Sys.Observer.raiseEvent(this, "pageLoaded", this._getPageLoadedEventArgs(initialLoad, data));
  1308. if (!initialLoad) {
  1309. Sys.Application.raiseLoad();
  1310. }
  1311. },
  1312. _pageLoadedInitialLoad: function PageRequestManager$_pageLoadedInitialLoad(evt) {
  1313. this._pageLoaded(true, null);
  1314. },
  1315. _parseDelta: function PageRequestManager$_parseDelta(executor) {
  1316. var reply = executor.get_responseData();
  1317. var delimiterIndex, len, type, id, content;
  1318. var replyIndex = 0;
  1319. var parserErrorDetails = null;
  1320. var delta = [];
  1321. while (replyIndex < reply.length) {
  1322. delimiterIndex = reply.indexOf('|', replyIndex);
  1323. if (delimiterIndex === -1) {
  1324. parserErrorDetails = this._findText(reply, replyIndex);
  1325. break;
  1326. }
  1327. len = parseInt(reply.substring(replyIndex, delimiterIndex), 10);
  1328. if ((len % 1) !== 0) {
  1329. parserErrorDetails = this._findText(reply, replyIndex);
  1330. break;
  1331. }
  1332. replyIndex = delimiterIndex + 1;
  1333. delimiterIndex = reply.indexOf('|', replyIndex);
  1334. if (delimiterIndex === -1) {
  1335. parserErrorDetails = this._findText(reply, replyIndex);
  1336. break;
  1337. }
  1338. type = reply.substring(replyIndex, delimiterIndex);
  1339. replyIndex = delimiterIndex + 1;
  1340. delimiterIndex = reply.indexOf('|', replyIndex);
  1341. if (delimiterIndex === -1) {
  1342. parserErrorDetails = this._findText(reply, replyIndex);
  1343. break;
  1344. }
  1345. id = reply.substring(replyIndex, delimiterIndex);
  1346. replyIndex = delimiterIndex + 1;
  1347. if ((replyIndex + len) >= reply.length) {
  1348. parserErrorDetails = this._findText(reply, reply.length);
  1349. break;
  1350. }
  1351. content = reply.substr(replyIndex, len);
  1352. replyIndex += len;
  1353. if (reply.charAt(replyIndex) !== '|') {
  1354. parserErrorDetails = this._findText(reply, replyIndex);
  1355. break;
  1356. }
  1357. replyIndex++;
  1358. Array.add(delta, {type: type, id: id, content: content});
  1359. }
  1360. if (parserErrorDetails) {
  1361. this._endPostBack(this._createPageRequestManagerParserError(String.format(Sys.WebForms.Res.PRM_ParserErrorDetails, parserErrorDetails)), executor, null);
  1362. return null;
  1363. }
  1364. var updatePanelNodes = [];
  1365. var hiddenFieldNodes = [];
  1366. var arrayDeclarationNodes = [];
  1367. var scriptBlockNodes = [];
  1368. var scriptStartupNodes = [];
  1369. var expandoNodes = [];
  1370. var onSubmitNodes = [];
  1371. var dataItemNodes = [];
  1372. var dataItemJsonNodes = [];
  1373. var scriptDisposeNodes = [];
  1374. var asyncPostBackControlIDsNode, postBackControlIDsNode,
  1375. updatePanelIDsNode, asyncPostBackTimeoutNode,
  1376. childUpdatePanelIDsNode, panelsToRefreshNode, formActionNode,
  1377. versionNode;
  1378. for (var i = 0, l = delta.length; i < l; i++) {
  1379. var deltaNode = delta[i];
  1380. switch (deltaNode.type) {
  1381. case "#":
  1382. versionNode = deltaNode;
  1383. break;
  1384. case "updatePanel":
  1385. Array.add(updatePanelNodes, deltaNode);
  1386. break;
  1387. case "hiddenField":
  1388. Array.add(hiddenFieldNodes, deltaNode);
  1389. break;
  1390. case "arrayDeclaration":
  1391. Array.add(arrayDeclarationNodes, deltaNode);
  1392. break;
  1393. case "scriptBlock":
  1394. Array.add(scriptBlockNodes, deltaNode);
  1395. break;
  1396. case "scriptStartupBlock":
  1397. Array.add(scriptStartupNodes, deltaNode);
  1398. break;
  1399. case "expando":
  1400. Array.add(expandoNodes, deltaNode);
  1401. break;
  1402. case "onSubmit":
  1403. Array.add(onSubmitNodes, deltaNode);
  1404. break;
  1405. case "asyncPostBackControlIDs":
  1406. asyncPostBackControlIDsNode = deltaNode;
  1407. break;
  1408. case "postBackControlIDs":
  1409. postBackControlIDsNode = deltaNode;
  1410. break;
  1411. case "updatePanelIDs":
  1412. updatePanelIDsNode = deltaNode;
  1413. break;
  1414. case "asyncPostBackTimeout":
  1415. asyncPostBackTimeoutNode = deltaNode;
  1416. break;
  1417. case "childUpdatePanelIDs":
  1418. childUpdatePanelIDsNode = deltaNode;
  1419. break;
  1420. case "panelsToRefreshIDs":
  1421. panelsToRefreshNode = deltaNode;
  1422. break;
  1423. case "formAction":
  1424. formActionNode = deltaNode;
  1425. break;
  1426. case "dataItem":
  1427. Array.add(dataItemNodes, deltaNode);
  1428. break;
  1429. case "dataItemJson":
  1430. Array.add(dataItemJsonNodes, deltaNode);
  1431. break;
  1432. case "scriptDispose":
  1433. Array.add(scriptDisposeNodes, deltaNode);
  1434. break;
  1435. case "pageRedirect":
  1436. if (Sys.Browser.agent === Sys.Browser.InternetExplorer) {
  1437. var anchor = document.createElement("a");
  1438. anchor.style.display = 'none';
  1439. anchor.attachEvent("onclick", cancelBubble);
  1440. anchor.href = deltaNode.content;
  1441. this._form.parentNode.insertBefore(anchor, this._form);
  1442. anchor.click();
  1443. anchor.detachEvent("onclick", cancelBubble);
  1444. this._form.parentNode.removeChild(anchor);
  1445. function cancelBubble(e) {
  1446. e.cancelBubble = true;
  1447. }
  1448. }
  1449. else {
  1450. window.location.href = deltaNode.content;
  1451. }
  1452. return null;
  1453. case "error":
  1454. this._endPostBack(this._createPageRequestManagerServerError(Number.parseInvariant(deltaNode.id), deltaNode.content), executor, null);
  1455. return null;
  1456. case "pageTitle":
  1457. document.title = deltaNode.content;
  1458. break;
  1459. case "focus":
  1460. this._controlIDToFocus = deltaNode.content;
  1461. break;
  1462. default:
  1463. this._endPostBack(this._createPageRequestManagerParserError(String.format(Sys.WebForms.Res.PRM_UnknownToken, deltaNode.type)), executor, null);
  1464. return null;
  1465. } // switch
  1466. } // for (var i = 0, l = delta.length; i < l; i++)
  1467. return {
  1468. version4: versionNode ? (parseFloat(versionNode.content) >= 4) : false,
  1469. executor: executor,
  1470. updatePanelNodes: updatePanelNodes,
  1471. hiddenFieldNodes: hiddenFieldNodes,
  1472. arrayDeclarationNodes: arrayDeclarationNodes,
  1473. scriptBlockNodes: scriptBlockNodes,
  1474. scriptStartupNodes: scriptStartupNodes,
  1475. expandoNodes: expandoNodes,
  1476. onSubmitNodes: onSubmitNodes,
  1477. dataItemNodes: dataItemNodes,
  1478. dataItemJsonNodes: dataItemJsonNodes,
  1479. scriptDisposeNodes: scriptDisposeNodes,
  1480. asyncPostBackControlIDsNode: asyncPostBackControlIDsNode,
  1481. postBackControlIDsNode: postBackControlIDsNode,
  1482. updatePanelIDsNode: updatePanelIDsNode,
  1483. asyncPostBackTimeoutNode: asyncPostBackTimeoutNode,
  1484. childUpdatePanelIDsNode: childUpdatePanelIDsNode,
  1485. panelsToRefreshNode: panelsToRefreshNode,
  1486. formActionNode: formActionNode };
  1487. },
  1488. _processUpdatePanelArrays: function PageRequestManager$_processUpdatePanelArrays(updatePanelIDs, asyncPostBackControlIDs, postBackControlIDs, version4) {
  1489. var newUpdatePanelIDs, newUpdatePanelClientIDs, newUpdatePanelHasChildrenAsTriggers;
  1490. if (updatePanelIDs) {
  1491. var l = updatePanelIDs.length,
  1492. m = version4 ? 2 : 1;
  1493. newUpdatePanelIDs = new Array(l/m);
  1494. newUpdatePanelClientIDs = new Array(l/m);
  1495. newUpdatePanelHasChildrenAsTriggers = new Array(l/m);
  1496. for (var i = 0, j = 0; i < l; i += m, j++) {
  1497. var ct,
  1498. uniqueID = updatePanelIDs[i],
  1499. clientID = version4 ? updatePanelIDs[i+1] : "";
  1500. ct = (uniqueID.charAt(0) === 't');
  1501. uniqueID = uniqueID.substr(1);
  1502. if (!clientID) {
  1503. clientID = this._uniqueIDToClientID(uniqueID);
  1504. }
  1505. newUpdatePanelHasChildrenAsTriggers[j] = ct;
  1506. newUpdatePanelIDs[j] = uniqueID;
  1507. newUpdatePanelClientIDs[j] = clientID;
  1508. }
  1509. }
  1510. else {
  1511. newUpdatePanelIDs = [];
  1512. newUpdatePanelClientIDs = [];
  1513. newUpdatePanelHasChildrenAsTriggers = [];
  1514. }
  1515. var newAsyncPostBackControlIDs = [];
  1516. var newAsyncPostBackControlClientIDs = [];
  1517. this._convertToClientIDs(asyncPostBackControlIDs, newAsyncPostBackControlIDs, newAsyncPostBackControlClientIDs, version4);
  1518. var newPostBackControlIDs = [];
  1519. var newPostBackControlClientIDs = [];
  1520. this._convertToClientIDs(postBackControlIDs, newPostBackControlIDs, newPostBackControlClientIDs, version4);
  1521. return {
  1522. updatePanelIDs: newUpdatePanelIDs,
  1523. updatePanelClientIDs: newUpdatePanelClientIDs,
  1524. updatePanelHasChildrenAsTriggers: newUpdatePanelHasChildrenAsTriggers,
  1525. asyncPostBackControlIDs: newAsyncPostBackControlIDs,
  1526. asyncPostBackControlClientIDs: newAsyncPostBackControlClientIDs,
  1527. postBackControlIDs: newPostBackControlIDs,
  1528. postBackControlClientIDs: newPostBackControlClientIDs
  1529. };
  1530. },
  1531. _queueScripts: function PageRequestManager$_queueScripts(scriptLoader, scriptBlockNodes, queueIncludes, queueBlocks) {
  1532. for (var i = 0, l = scriptBlockNodes.length; i < l; i++) {
  1533. var scriptBlockType = scriptBlockNodes[i].id;
  1534. switch (scriptBlockType) {
  1535. case "ScriptContentNoTags":
  1536. if (!queueBlocks) {
  1537. continue;
  1538. }
  1539. scriptLoader.queueScriptBlock(scriptBlockNodes[i].content);
  1540. break;
  1541. case "ScriptContentWithTags":
  1542. var scriptTagAttributes = window.eval("(" + scriptBlockNodes[i].content + ")");
  1543. if (scriptTagAttributes.src) {
  1544. if (!queueIncludes || Sys._ScriptLoader.isScriptLoaded(scriptTagAttributes.src)) {
  1545. continue;
  1546. }
  1547. }
  1548. else if (!queueBlocks) {
  1549. continue;
  1550. }
  1551. scriptLoader.queueCustomScriptTag(scriptTagAttributes);
  1552. break;
  1553. case "ScriptPath":
  1554. if (!queueIncludes || Sys._ScriptLoader.isScriptLoaded(scriptBlockNodes[i].content)) {
  1555. continue;
  1556. }
  1557. scriptLoader.queueScriptReference(scriptBlockNodes[i].content);
  1558. break;
  1559. }
  1560. }
  1561. },
  1562. _registerDisposeScript: function PageRequestManager$_registerDisposeScript(panelID, disposeScript) {
  1563. if (!this._scriptDisposes[panelID]) {
  1564. this._scriptDisposes[panelID] = [disposeScript];
  1565. }
  1566. else {
  1567. Array.add(this._scriptDisposes[panelID], disposeScript);
  1568. }
  1569. },
  1570. _scriptIncludesLoadComplete: function PageRequestManager$_scriptIncludesLoadComplete(scriptLoader, data) {
  1571. if (data.executor.get_webRequest() !== this._request) {
  1572. return;
  1573. }
  1574. this._commitControls(data.updatePanelData,
  1575. data.asyncPostBackTimeoutNode ? data.asyncPostBackTimeoutNode.content : null);
  1576. if (data.formActionNode) {
  1577. this._form.action = data.formActionNode.content;
  1578. }
  1579. var i, l, node;
  1580. for (i = 0, l = data.updatePanelNodes.length; i < l; i++) {
  1581. node = data.updatePanelNodes[i];
  1582. var updatePanelElement = document.getElementById(node.id);
  1583. if (!updatePanelElement) {
  1584. this._endPostBack(Error.invalidOperation(String.format(Sys.WebForms.Res.PRM_MissingPanel, node.id)), data.executor, data);
  1585. return;
  1586. }
  1587. this._updatePanel(updatePanelElement, node.content);
  1588. }
  1589. for (i = 0, l = data.scriptDisposeNodes.length; i < l; i++) {
  1590. node = data.scriptDisposeNodes[i];
  1591. this._registerDisposeScript(node.id, node.content);
  1592. }
  1593. for (i = 0, l = this._transientFields.length; i < l; i++) {
  1594. var field = document.getElementById(this._transientFields[i]);
  1595. if (field) {
  1596. var toRemove = field._isContained ? field.parentNode : field;
  1597. toRemove.parentNode.removeChild(toRemove);
  1598. }
  1599. }
  1600. for (i = 0, l = data.hiddenFieldNodes.length; i < l; i++) {
  1601. node = data.hiddenFieldNodes[i];
  1602. this._createHiddenField(node.id, node.content);
  1603. }
  1604. if (data.scriptsFailed) {
  1605. throw Sys._ScriptLoader._errorScriptLoadFailed(data.scriptsFailed.src, data.scriptsFailed.multipleCallbacks);
  1606. }
  1607. this._queueScripts(scriptLoader, data.scriptBlockNodes, false, true);
  1608. var arrayScript = '';
  1609. for (i = 0, l = data.arrayDeclarationNodes.length; i < l; i++) {
  1610. node = data.arrayDeclarationNodes[i];
  1611. arrayScript += "Sys.WebForms.PageRequestManager._addArrayElement('" + node.id + "', " + node.content + ");\r\n";
  1612. }
  1613. var expandoScript = '';
  1614. for (i = 0, l = data.expandoNodes.length; i < l; i++) {
  1615. node = data.expandoNodes[i];
  1616. expandoScript += node.id + " = " + node.content + "\r\n";
  1617. }
  1618. if (arrayScript.length) {
  1619. scriptLoader.queueScriptBlock(arrayScript);
  1620. }
  1621. if (expandoScript.length) {
  1622. scriptLoader.queueScriptBlock(expandoScript);
  1623. }
  1624. this._queueScripts(scriptLoader, data.scriptStartupNodes, true, true);
  1625. var onSubmitStatementScript = '';
  1626. for (i = 0, l = data.onSubmitNodes.length; i < l; i++) {
  1627. if (i === 0) {
  1628. onSubmitStatementScript = 'Array.add(Sys.WebForms.PageRequestManager.getInstance()._onSubmitStatements, function() {\r\n';
  1629. }
  1630. onSubmitStatementScript += data.onSubmitNodes[i].content + "\r\n";
  1631. }
  1632. if (onSubmitStatementScript.length) {
  1633. onSubmitStatementScript += "\r\nreturn true;\r\n});\r\n";
  1634. scriptLoader.queueScriptBlock(onSubmitStatementScript);
  1635. }
  1636. scriptLoader.loadScripts(0,
  1637. Function.createDelegate(this, Function.createCallback(this._scriptsLoadComplete, data)), null, null);
  1638. },
  1639. _scriptIncludesLoadFailed: function PageRequestManager$_scriptIncludesLoadFailed(scriptLoader, scriptElement, multipleCallbacks, data) {
  1640. data.scriptsFailed = { src: scriptElement.src, multipleCallbacks: multipleCallbacks };
  1641. this._scriptIncludesLoadComplete(scriptLoader, data);
  1642. },
  1643. _scriptsLoadComplete: function PageRequestManager$_scriptsLoadComplete(scriptLoader, data) {
  1644. var response = data.executor;
  1645. if (window.__theFormPostData) {
  1646. window.__theFormPostData = "";
  1647. }
  1648. if (window.__theFormPostCollection) {
  1649. window.__theFormPostCollection = [];
  1650. }
  1651. if (window.WebForm_InitCallback) {
  1652. window.WebForm_InitCallback();
  1653. }
  1654. if (this._scrollPosition) {
  1655. if (window.scrollTo) {
  1656. window.scrollTo(this._scrollPosition.x, this._scrollPosition.y);
  1657. }
  1658. this._scrollPosition = null;
  1659. }
  1660. Sys.Application.endCreateComponents();
  1661. this._pageLoaded(false, data);
  1662. this._endPostBack(null, response, data);
  1663. if (this._controlIDToFocus) {
  1664. var focusTarget;
  1665. var oldContentEditableSetting;
  1666. if (Sys.Browser.agent === Sys.Browser.InternetExplorer) {
  1667. var targetControl = $get(this._controlIDToFocus);
  1668. focusTarget = targetControl;
  1669. if (targetControl && (!WebForm_CanFocus(targetControl))) {
  1670. focusTarget = WebForm_FindFirstFocusableChild(targetControl);
  1671. }
  1672. if (focusTarget && (typeof(focusTarget.contentEditable) !== "undefined")) {
  1673. oldContentEditableSetting = focusTarget.contentEditable;
  1674. focusTarget.contentEditable = false;
  1675. }
  1676. else {
  1677. focusTarget = null;
  1678. }
  1679. }
  1680. WebForm_AutoFocus(this._controlIDToFocus);
  1681. if (focusTarget) {
  1682. focusTarget.contentEditable = oldContentEditableSetting;
  1683. }
  1684. this._controlIDToFocus = null;
  1685. }
  1686. },
  1687. _splitNodeIntoArray: function PageRequestManager$_splitNodeIntoArray(node) {
  1688. var str = node.content;
  1689. var arr = str.length ? str.split(',') : [];
  1690. return arr;
  1691. },
  1692. _uniqueIDToClientID: function PageRequestManager$_uniqueIDToClientID(uniqueID) {
  1693. return uniqueID.replace(/\$/g, '_');
  1694. },
  1695. _updateControls: function PageRequestManager$_updateControls(updatePanelIDs, asyncPostBackControlIDs, postBackControlIDs, asyncPostBackTimeout, version4) {
  1696. this._commitControls(
  1697. this._processUpdatePanelArrays(updatePanelIDs, asyncPostBackControlIDs, postBackControlIDs, version4),
  1698. asyncPostBackTimeout);
  1699. },
  1700. _updatePanel: function PageRequestManager$_updatePanel(updatePanelElement, rendering) {
  1701. for (var updatePanelID in this._scriptDisposes) {
  1702. if (this._elementContains(updatePanelElement, document.getElementById(updatePanelID))) {
  1703. var disposeScripts = this._scriptDisposes[updatePanelID];
  1704. for (var i = 0, l = disposeScripts.length; i < l; i++) {
  1705. window.eval(disposeScripts[i]);
  1706. }
  1707. delete this._scriptDisposes[updatePanelID];
  1708. }
  1709. }
  1710. Sys.Application.disposeElement(updatePanelElement, true);
  1711. updatePanelElement.innerHTML = rendering;
  1712. },
  1713. _validPosition: function PageRequestManager$_validPosition(position) {
  1714. return (typeof(position) !== "undefined") && (position !== null) && (position !== 0);
  1715. }
  1716. }
  1717. $type.getInstance = function PageRequestManager$getInstance() {
  1718. /// <summary locid="M:J#Sys.WebForms.PageRequestManager.getInstance">Gets the current instance of the PageRequestManager.</summary>
  1719. /// <returns type="Sys.WebForms.PageRequestManager"></returns>
  1720. if (arguments.length !== 0) throw Error.parameterCount();
  1721. var prm = Sys.WebForms.PageRequestManager._instance;
  1722. if (!prm) {
  1723. prm = Sys.WebForms.PageRequestManager._instance = new Sys.WebForms.PageRequestManager();
  1724. }
  1725. return prm;
  1726. }
  1727. $type._addArrayElement = function PageRequestManager$_addArrayElement(arrayName) {
  1728. if (!window[arrayName]) {
  1729. window[arrayName] = new Array();
  1730. }
  1731. for (var i = 1, l = arguments.length; i < l; i++) {
  1732. Array.add(window[arrayName], arguments[i]);
  1733. }
  1734. }
  1735. $type._initialize = function PageRequestManager$_initialize() {
  1736. var prm = Sys.WebForms.PageRequestManager.getInstance();
  1737. prm._initializeInternal.apply(prm, arguments);
  1738. }
  1739. $type.registerClass('Sys.WebForms.PageRequestManager');
  1740. $type = Sys.UI._UpdateProgress = function _UpdateProgress(element) {
  1741. Sys.UI._UpdateProgress.initializeBase(this,[element]);
  1742. this._displayAfter = 500;
  1743. this._dynamicLayout = true;
  1744. this._associatedUpdatePanelId = null;
  1745. this._beginRequestHandlerDelegate = null;
  1746. this._startDelegate = null;
  1747. this._endRequestHandlerDelegate = null;
  1748. this._pageRequestManager = null;
  1749. this._timerCookie = null;
  1750. }
  1751. $type.prototype = {
  1752. get_displayAfter: function _UpdateProgress$get_displayAfter() {
  1753. /// <value type="Number" locid="P:J#Sys.UI._UpdateProgress.displayAfter"></value>
  1754. if (arguments.length !== 0) throw Error.parameterCount();
  1755. return this._displayAfter;
  1756. },
  1757. set_displayAfter: function _UpdateProgress$set_displayAfter(value) {
  1758. var e = Function._validateParams(arguments, [{name: "value", type: Number}]);
  1759. if (e) throw e;
  1760. this._displayAfter = value;
  1761. },
  1762. get_dynamicLayout: function _UpdateProgress$get_dynamicLayout() {
  1763. /// <value type="Boolean" locid="P:J#Sys.UI._UpdateProgress.dynamicLayout"></value>
  1764. if (arguments.length !== 0) throw Error.parameterCount();
  1765. return this._dynamicLayout;
  1766. },
  1767. set_dynamicLayout: function _UpdateProgress$set_dynamicLayout(value) {
  1768. var e = Function._validateParams(arguments, [{name: "value", type: Boolean}]);
  1769. if (e) throw e;
  1770. this._dynamicLayout = value;
  1771. },
  1772. get_associatedUpdatePanelId: function _UpdateProgress$get_associatedUpdatePanelId() {
  1773. /// <value type="String" mayBeNull="true" locid="P:J#Sys.UI._UpdateProgress.associatedUpdatePanelId"></value>
  1774. if (arguments.length !== 0) throw Error.parameterCount();
  1775. return this._associatedUpdatePanelId;
  1776. },
  1777. set_associatedUpdatePanelId: function _UpdateProgress$set_associatedUpdatePanelId(value) {
  1778. var e = Function._validateParams(arguments, [{name: "value", type: String, mayBeNull: true}]);
  1779. if (e) throw e;
  1780. this._associatedUpdatePanelId = value;
  1781. },
  1782. get_role: function _UpdateProgress$get_role() {
  1783. /// <value type="String" locid="P:J#Sys.UI._UpdateProgress.role"></value>
  1784. if (arguments.length !== 0) throw Error.parameterCount();
  1785. return "status";
  1786. },
  1787. _clearTimeout: function _UpdateProgress$_clearTimeout() {
  1788. if (this._timerCookie) {
  1789. window.clearTimeout(this._timerCookie);
  1790. this._timerCookie = null;
  1791. }
  1792. },
  1793. _getUniqueID: function _UpdateProgress$_getUniqueID(clientID) {
  1794. var i = Array.indexOf(this._pageRequestManager._updatePanelClientIDs, clientID);
  1795. return i === -1 ? null : this._pageRequestManager._updatePanelIDs[i];
  1796. },
  1797. _handleBeginRequest: function _UpdateProgress$_handleBeginRequest(sender, arg) {
  1798. var curElem = arg.get_postBackElement(),
  1799. showProgress = true,
  1800. upID = this._associatedUpdatePanelId;
  1801. if (this._associatedUpdatePanelId) {
  1802. var updating = arg.get_updatePanelsToUpdate();
  1803. if (updating && updating.length) {
  1804. showProgress = (Array.contains(updating, upID) || Array.contains(updating, this._getUniqueID(upID)))
  1805. }
  1806. else {
  1807. showProgress = false;
  1808. }
  1809. }
  1810. while (!showProgress && curElem) {
  1811. if (curElem.id && this._associatedUpdatePanelId === curElem.id) {
  1812. showProgress = true;
  1813. }
  1814. curElem = curElem.parentNode;
  1815. }
  1816. if (showProgress) {
  1817. this._timerCookie = window.setTimeout(this._startDelegate, this._displayAfter);
  1818. }
  1819. },
  1820. _startRequest: function _UpdateProgress$_startRequest() {
  1821. if (this._pageRequestManager.get_isInAsyncPostBack()) {
  1822. var element = this.get_element();
  1823. if (this._dynamicLayout) {
  1824. element.style.display = 'block';
  1825. }
  1826. else {
  1827. element.style.visibility = 'visible';
  1828. }
  1829. if (this.get_role() === "status") {
  1830. element.setAttribute("aria-hidden", "false");
  1831. }
  1832. }
  1833. this._timerCookie = null;
  1834. },
  1835. _handleEndRequest: function _UpdateProgress$_handleEndRequest(sender, arg) {
  1836. var element = this.get_element();
  1837. if (this._dynamicLayout) {
  1838. element.style.display = 'none';
  1839. }
  1840. else {
  1841. element.style.visibility = 'hidden';
  1842. }
  1843. if (this.get_role() === "status") {
  1844. element.setAttribute("aria-hidden", "true");
  1845. }
  1846. this._clearTimeout();
  1847. },
  1848. dispose: function _UpdateProgress$dispose() {
  1849. if (this._beginRequestHandlerDelegate !== null) {
  1850. this._pageRequestManager.remove_beginRequest(this._beginRequestHandlerDelegate);
  1851. this._pageRequestManager.remove_endRequest(this._endRequestHandlerDelegate);
  1852. this._beginRequestHandlerDelegate = null;
  1853. this._endRequestHandlerDelegate = null;
  1854. }
  1855. this._clearTimeout();
  1856. Sys.UI._UpdateProgress.callBaseMethod(this,"dispose");
  1857. },
  1858. initialize: function _UpdateProgress$initialize() {
  1859. Sys.UI._UpdateProgress.callBaseMethod(this, 'initialize');
  1860. if (this.get_role() === "status") {
  1861. this.get_element().setAttribute("aria-hidden", "true");
  1862. }
  1863. this._beginRequestHandlerDelegate = Function.createDelegate(this, this._handleBeginRequest);
  1864. this._endRequestHandlerDelegate = Function.createDelegate(this, this._handleEndRequest);
  1865. this._startDelegate = Function.createDelegate(this, this._startRequest);
  1866. if (Sys.WebForms && Sys.WebForms.PageRequestManager) {
  1867. this._pageRequestManager = Sys.WebForms.PageRequestManager.getInstance();
  1868. }
  1869. if (this._pageRequestManager !== null ) {
  1870. this._pageRequestManager.add_beginRequest(this._beginRequestHandlerDelegate);
  1871. this._pageRequestManager.add_endRequest(this._endRequestHandlerDelegate);
  1872. }
  1873. }
  1874. }
  1875. $type.registerClass('Sys.UI._UpdateProgress', Sys.UI.Control);
  1876. }
  1877. if (window.Sys && Sys.loader) {
  1878. Sys.loader.registerScript("WebForms", ["ComponentModel", "Serialization", "Network"], execute);
  1879. }
  1880. else {
  1881. execute();
  1882. }
  1883. })();