1// Name: DynamicPopulate.DynamicPopulateBehavior.debug.js 2// Assembly: AjaxControlToolkit 3// Version: 4.1.60501.0 4// FileVersion: 4.1.60501 5// (c) 2010 CodePlex Foundation 6 7 8 9/// <reference name="MicrosoftAjax.debug.js" /> 10/// <reference path="../ExtenderBase/BaseScripts.js" /> 11/// <reference path="../Common/Common.js" /> 12 13(function() { 14var scriptName = "ExtendedDynamicPopulate"; 15 16function execute() { 17 18Type.registerNamespace('Sys.Extended.UI'); 19 20Sys.Extended.UI.DynamicPopulateBehavior = function(element) { 21 /// <summary> 22 /// The DynamicPopulateBehavior replaces the contents of an element with the result of a web service or page method call. The method call returns a string of HTML that is inserted as the children of the target element. 23 /// </summary> 24 /// <param name="element" type="Sys.UI.DomElement" domElement="true"> 25 /// DOM Element the behavior is associated with 26 /// </param> 27 Sys.Extended.UI.DynamicPopulateBehavior.initializeBase(this, [element]);
28 29 this._servicePath = location.pathname; 30 this._serviceMethod = null; 31 this._contextKey = null; 32 this._cacheDynamicResults = false; 33 this._populateTriggerID = null; 34 this._setUpdatingCssClass = null; 35 this._clearDuringUpdate = true; 36 this._customScript = null; 37 38 this._clickHandler = null; 39 40 this._callID = 0; 41 this._currentCallID = -1; 42 43 this._populated = false; 44} 45Sys.Extended.UI.DynamicPopulateBehavior.prototype = { 46 initialize : function() { 47 /// <summary> 48 /// Initialize the behavior 49 /// </summary> 50 Sys.Extended.UI.DynamicPopulateBehavior.callBaseMethod(this, 'initialize'); 51 $common.prepareHiddenElementForATDeviceUpdate(); 52 53 if (this._populateTriggerID) { 54 var populateTrigger = $get(this._populateTriggerID); 55 if (populateTrigger) { 56 this._clickHandler = Function.createDelegate(this, this._onPopulateTriggerClick); 57 $addHandler(populateTrigger, "click", this._clickHandler); 58 } 59 } 60 }, 61 62 dispose : function() { 63 /// <summary> 64 /// Dispose the behavior 65 /// </summary> 66 67 if (this._populateTriggerID && this._clickHandler) { 68 var populateTrigger = $get(this._populateTriggerID); 69 if (populateTrigger) { 70 $removeHandler(populateTrigger, "click", this._clickHandler); 71 } 72 this._populateTriggerID = null; 73 this._clickHandler = null; 74 } 75 76 Sys.Extended.UI.DynamicPopulateBehavior.callBaseMethod(this, 'dispose'); 77 }, 78 79 populate : function(contextKey) { 80 /// <summary> 81 /// Get the dymanic content and use it to populate the target element 82 /// </summary> 83 /// <param name="contextKey" type="String" mayBeNull="true" optional="true"> 84 /// An arbitrary string value to be passed to the web method. For example, if the element to be 85 /// populated is within a data-bound repeater, this could be the ID of the current row. 86 /// </param> 87 88 if (this._populated && this._cacheDynamicResults) { 89 return; 90 } 91 92 if (this._currentCallID == -1) { 93 var eventArgs = new Sys.CancelEventArgs(); 94 this.raisePopulating(eventArgs); 95 if (eventArgs.get_cancel()) { 96 return; 97 } 98 this._setUpdating(true); 99 } 100 101 if (this._customScript) { 102 var scriptResult = eval(this._customScript); 103 this._setTargetHtml(scriptResult); 104 this._setUpdating(false); 105 } else { 106 this._currentCallID = ++this._callID; 107 if (this._servicePath && this._serviceMethod) { 108 Sys.Net.WebServiceProxy.invoke(this._servicePath, this._serviceMethod, false, 109 { contextKey:(contextKey ? contextKey : this._contextKey) }, 110 Function.createDelegate(this, this._onMethodComplete), Function.createDelegate(this, this._onMethodError), 111 this._currentCallID); 112 $common.updateFormToRefreshATDeviceBuffer(); 113 } 114 } 115 }, 116 117 _onMethodComplete : function (result, userContext, methodName) { 118 /// <summary> 119 /// Callback used when the populating service returns successfully 120 /// </summary> 121 /// <param name="result" type="Object" mayBeNull=""> 122 /// The data returned from the Web service method call 123 /// </param> 124 /// <param name="userContext" type="Object"> 125 /// The context information that was passed when the Web service method was invoked 126 /// </param> 127 /// <param name="methodName" type="String"> 128 /// The Web service method that was invoked 129 /// </param> 130 131 if (userContext != this._currentCallID) return; 132 133 this._setTargetHtml(result); 134 135 this._setUpdating(false); 136 }, 137 138 _onMethodError : function(webServiceError, userContext, methodName) { 139 /// <summary> 140 /// Callback used when the populating service fails 141 /// </summary> 142 /// <param name="webServiceError" type="Sys.Net.WebServiceError"> 143 /// Web service error 144 /// </param> 145 /// <param name="userContext" type="Object"> 146 /// The context information that was passed when the Web service method was invoked 147 /// </param> 148 /// <param name="methodName" type="String"> 149 /// The Web service method that was invoked 150 /// </param> 151 152 if (userContext != this._currentCallID) return; 153 154 if (webServiceError.get_timedOut()) { 155 this._setTargetHtml(Sys.Extended.UI.Resources.DynamicPopulate_WebServiceTimeout); 156 } else { 157 this._setTargetHtml(String.format(Sys.Extended.UI.Resources.DynamicPopulate_WebServiceError, webServiceError.get_statusCode())); 158 } 159 160 this._setUpdating(false); 161 }, 162 163 _onPopulateTriggerClick : function() { 164 /// <summary> 165 /// Handler for the element described by PopulateTriggerID's click event 166 /// </summary> 167 168 this.populate(this._contextKey); 169 }, 170 171 _setUpdating : function(updating) { 172 /// <summary> 173 /// Toggle the display elements to indicate if they are being updated or not 174 /// </summary> 175 /// <param name="updating" type="Boolean"> 176 /// Whether or not the display should indicated it is being updated 177 /// </param> 178 179 this.setStyle(updating); 180 181 if (!updating) { 182 this._currentCallID = -1; 183 this._populated = true;
184 this.raisePopulated(this, Sys.EventArgs.Empty); 185 } 186 }, 187 188 _setTargetHtml : function(value) { 189 /// <summary> 190 /// Populate the target element with the given value 191 /// </summary> 192 /// <param name="value" type="String"> 193 /// The data to populate the target element. 194 /// </param> 195 196 var e = this.get_element() 197 if (e) { 198 if (e.tagName == "INPUT") { 199 e.value = value; 200 } else { 201 e.innerHTML = value; 202 } 203 } 204 }, 205 206 setStyle : function(updating) { 207 /// <summary> 208 /// Set the style of the display 209 /// </summary> 210 /// <param name="updating" type="Boolean"> 211 /// Whether or not the display is being updated 212 /// </param> 213 214 var e = this.get_element(); 215 if (this._setUpdatingCssClass) { 216 if (!updating) { 217 e.className = this._oldCss; 218 this._oldCss = null; 219 } else { 220 this._oldCss = e.className; 221 e.className = this._setUpdatingCssClass; 222 } 223 } 224 225 if (updating && this._clearDuringUpdate) { 226 this._setTargetHtml(""); 227 } 228 }, 229 230 get_ClearContentsDuringUpdate : function() { 231 /// <value type="Boolean"> 232 /// Whether the contents of the target should be cleared when an update begins 233 /// </value> 234 return this._clearDuringUpdate; 235 }, 236 set_ClearContentsDuringUpdate : function(value) { 237 if (this._clearDuringUpdate != value) { 238 this._clearDuringUpdate = value; 239 this.raisePropertyChanged('ClearContentsDuringUpdate'); 240 } 241 }, 242 243 get_ContextKey : function() { 244 /// <value type="String"> 245 /// An arbitrary string value to be passed to the web method. 246 /// For example, if the element to be populated is within a 247 /// data-bound repeater, this could be the ID of the current row. 248 /// </value> 249 return this._contextKey; 250 }, 251 set_ContextKey : function(value) { 252 if (this._contextKey != value) { 253 this._contextKey = value; 254 this.raisePropertyChanged('ContextKey'); 255 } 256 }, 257 258 get_PopulateTriggerID : function() { 259 /// <value type="String" mayBeNull="true" optional="true"> 260 /// Name of an element that triggers the population of the target when clicked 261 /// </value> 262 return this._populateTriggerID; 263 }, 264 set_PopulateTriggerID : function(value) { 265 if (this._populateTriggerID != value) { 266 this._populateTriggerID = value; 267 this.raisePropertyChanged('PopulateTriggerID'); 268 } 269 }, 270 271 get_ServicePath : function() { 272 /// <value type="String" mayBeNull="true" optional="true"> 273 /// The URL of the web service to call. If the ServicePath is not defined, then we will invoke a PageMethod instead of a web service. 274 /// </value> 275 return this._servicePath; 276 }, 277 set_ServicePath : function(value) { 278 if (this._servicePath != value) { 279 this._servicePath = value; 280 this.raisePropertyChanged('ServicePath'); 281 } 282 }, 283 284 get_ServiceMethod : function() { 285 /// <value type="String"> 286 /// The name of the method to call on the page or web service 287 /// </value> 288 /// <remarks> 289 /// The signature of the method must exactly match the following: 290 /// [WebMethod] 291 /// string DynamicPopulateMethod(string contextKey) 292 /// { 293 /// ... 294 /// } 295 /// </remarks> 296 return this._serviceMethod; 297 }, 298 set_ServiceMethod : function(value) { 299 if (this._serviceMethod != value) { 300 this._serviceMethod = value; 301 this.raisePropertyChanged('ServiceMethod'); 302 } 303 }, 304 305 get_cacheDynamicResults : function() { 306 /// <value type="Boolean" mayBeNull="false"> 307 /// Whether the results of the dynamic population should be cached and 308 /// not fetched again after the first load 309 /// </value> 310 return this._cacheDynamicResults; 311 }, 312 set_cacheDynamicResults : function(value) { 313 if (this._cacheDynamicResults != value) { 314 this._cacheDynamicResults = value; 315 this.raisePropertyChanged('cacheDynamicResults'); 316 } 317 }, 318 319 get_UpdatingCssClass : function() { 320 /// <value type="String"> 321 /// The CSS class to apply to the target during asynchronous calls 322 /// </value> 323 return this._setUpdatingCssClass; 324 }, 325 set_UpdatingCssClass : function(value) { 326 if (this._setUpdatingCssClass != value) { 327 this._setUpdatingCssClass = value; 328 this.raisePropertyChanged('UpdatingCssClass'); 329 } 330 }, 331 332 get_CustomScript : function() { 333 /// <value type="String"> 334 /// The script to invoke instead of calling a Web or Page method. This script must evaluate to a string value. 335 /// </value> 336 return this._customScript; 337 }, 338 set_CustomScript : function(value) { 339 if (this._customScript != value) { 340 this._customScript = value; 341 this.raisePropertyChanged('CustomScript'); 342 } 343 }, 344 345 add_populating : function(handler) { 346 /// <summary> 347 /// Add an event handler for the populating event 348 /// </summary> 349 /// <param name="handler" type="Function" mayBeNull="false"> 350 /// Event handler 351 /// </param> 352 /// <returns /> 353 this.get_events().addHandler('populating', handler); 354 }, 355 remove_populating : function(handler) { 356 /// <summary> 357 /// Remove an event handler from the populating event 358 /// </summary> 359 /// <param name="handler" type="Function" mayBeNull="false"> 360 /// Event handler 361 /// </param> 362 /// <returns /> 363 this.get_events().removeHandler('populating', handler); 364 },
365 raisePopulating : function(eventArgs) { 366 /// <summary> 367 /// Raise the populating event 368 /// </summary> 369 /// <param name="eventArgs" type="Sys.CancelEventArgs" mayBeNull="false"> 370 /// Event arguments for the populating event 371 /// </param> 372 /// <returns /> 373 374 var handler = this.get_events().getHandler('populating'); 375 if (handler) { 376 handler(this, eventArgs); 377 } 378 }, 379 380 add_populated : function(handler) { 381 /// <summary> 382 /// Add an event handler for the populated event 383 /// </summary> 384 /// <param name="handler" type="Function" mayBeNull="false"> 385 /// Event handler 386 /// </param> 387 /// <returns /> 388 this.get_events().addHandler('populated', handler); 389 }, 390 remove_populated : function(handler) { 391 /// <summary> 392 /// Remove an event handler from the populated event 393 /// </summary> 394 /// <param name="handler" type="Function" mayBeNull="false"> 395 /// Event handler 396 /// </param> 397 /// <returns /> 398 this.get_events().removeHandler('populated', handler); 399 }, 400 raisePopulated : function(eventArgs) { 401 /// <summary> 402 /// Raise the populated event 403 /// </summary> 404 /// <param name="eventArgs" type="Sys.EventArgs" mayBeNull="false"> 405 /// Event arguments for the populated event 406 /// </param> 407 /// <returns /> 408 409 var handler = this.get_events().getHandler('populated'); 410 if (handler) { 411 handler(this, eventArgs); 412 } 413 } 414} 415Sys.Extended.UI.DynamicPopulateBehavior.registerClass('Sys.Extended.UI.DynamicPopulateBehavior', Sys.Extended.UI.BehaviorBase); 416Sys.registerComponent(Sys.Extended.UI.DynamicPopulateBehavior, { name: "dynamicPopulate" }); 417 418} // execute 419 420if (window.Sys && Sys.loader) { 421 Sys.loader.registerScript(scriptName, ["ExtendedBase", "ExtendedCommon", "Network"], execute); 422} 423else { 424 execute(); 425} 426 427})();
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.