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