PageSourceSearch

https://www.portoseguro.org.br/scriptresource.axd?d=6XQwBaKUm_FaNK…2YVZK36jwW5lRHMwnyfVwjA2&t=ffffffff9b7d03cf

js portoseguro.org.br collected 2026-10-03 22:10:31 UTC 15,906 bytes, 427 lines download raw bytes

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