PageSourceSearch

https://aussiefloyd.com/ScriptResource.axd?d=fBn8CcjauWHQ1J0p0YW9T…cQZi5PmtoN58ftK_q1_UzgRPpek4lN81&t=51e37521

js aussiefloyd.com collected 2026-10-02 06:19:34 UTC 22,077 bytes, 506 lines download raw bytes

1// Name:        ValidatorCallout.ValidatorCalloutBehavior.debug.js
2// Assembly:    AjaxControlToolkit
3// Version:     4.1.7.1213
4// FileVersion: 4.1.7.1213
5// (c) 2010 CodePlex Foundation
6
7
8
9/// <reference name="MicrosoftAjax.debug.js" />
10/// <reference name="MicrosoftAjaxTimer.debug.js" />
11/// <reference name="MicrosoftAjaxWebForms.debug.js" />
12/// <reference path="../ExtenderBase/BaseScripts.js" />
13/// <reference path="../Common/Common.js" />
14/// <reference path="../Compat/Timer/Timer.js" />
15/// <reference path="../Animation/Animations.js" />
16/// <reference path="../Animation/AnimationBehavior.js" />
17/// <reference path="../PopupExtender/PopupBehavior.js" />
18
19
20Type.registerNamespace('Sys.Extended.UI');
21
22Sys.Extended.UI.ValidatorCalloutBehavior = function Sys$Extended$UI$ValidatorCalloutBehavior(element) {
23    Sys.Extended.UI.ValidatorCalloutBehavior.initializeBase(this, [element]);
24    
25    this._warningIconImageUrl = null;
26    this._closeImageUrl = null;
27    this._cssClass = "ajax__validatorcallout";
28    this._highlightCssClass = null;
29    this._popupPosition = Sys.Extended.UI.ValidatorCalloutPosition.Right;
30    this._width = "200px";
31    this._invalid = false;
32    this._originalValidationMethod = null;
33    this._validationMethodOverride = null;
34    this._elementToValidate = null;
35    this._popupTable = null;
36    this._errorMessageCell = null;
37    this._calloutArrowCell = null;
38    this._warningIconImage = null;
39    this._closeImage = null;
40    this._closeCellInnerDiv = null;
41    this._popupBehavior = null;
42    this._onShowJson = null;
43    this._onHideJson = null;
44    this._focusAttached = false;
45    this._isBuilt = false;
46    this._focusHandler = Function.createDelegate(this, this._onfocus);
47    this._closeClickHandler = Function.createDelegate(this, this._oncloseClick);
48};
49Sys.Extended.UI.ValidatorCalloutBehavior.prototype = {
50    initialize : function() {
51        Sys.Extended.UI.ValidatorCalloutBehavior.callBaseMethod(this, 'initialize');
52        var elt = this.get_element();
53        if(elt.evaluationfunction) {
54            this._originalValidationMethod = Function.createDelegate(elt, elt.evaluationfunction);
55            this._validationMethodOverride = Function.createDelegate(this, this._onvalidate);
56            elt.evaluationfunction = this._validationMethodOverride;
57        }
58
59        var clientState = this.get_ClientState();
60        if ((null != clientState) && ("" !== clientState)) {
61            this._ensureCallout();
62            if(this._highlightCssClass) {
63                Sys.UI.DomElement.addCssClass(this._elementToValidate, this._highlightCssClass);
64            }
65            this.show();
66        }
67    },
68
69    _ensureCallout : function() {
70        if (!this._isBuilt) {
71              
72            var elt = this.get_element();
73            var elementToValidate = this._elementToValidate = $get(elt.controltovalidate);
74            var popupTableBody = document.createElement("tbody");
75            var popupTableRow = document.createElement("tr");
76            var calloutCell = document.createElement("td");
77            var calloutTable = document.createElement("table");
78            var calloutTableBody = document.createElement("tbody");
79            var calloutTableRow = document.createElement("tr");
80            var iconCell = document.createElement("td");
81            var closeCell = document.createElement("td");
82            var closeCellInnerDiv = this._closeCellInnerDiv = document.createElement("div");
83            var popupTable = this._popupTable = document.createElement("table");
84            var calloutArrowCell = this._calloutArrowCell = document.createElement("td");
85            var warningIconImage = this._warningIconImage = document.createElement("img");
86            var closeImage = this._closeImage = document.createElement("img");
87            var errorMessageCell = this._errorMessageCell = document.createElement("td");
88            popupTable.id = this.get_id() + "_popupTable";
89            popupTable.cellPadding = 0;
90            popupTable.cellSpacing = 0;
91            popupTable.border = 0;
92            popupTable.width = this.get_width();
93            popupTable.className = this._cssClass + " ajax__validatorcallout_popup_table";
94            popupTableRow.className = "ajax__validatorcallout_popup_table_row";
95            calloutCell.className = "ajax__validatorcallout_callout_cell";
96            calloutTable.cellPadding = 0;
97            calloutTable.cellSpacing = 0;
98            calloutTable.border = 0;
99            calloutTable.className = "ajax__validatorcallout_callout_table";
100            calloutTableRow.className = "ajax__validatorcallout_callout_table_row";
101            if (this._popupPosition == Sys.Extended.UI.ValidatorCalloutPosition.BottomLeft)
102                calloutArrowCell.className = "ajax__validatorcallout_callout_arrow_cell_bottomleftpos";
103            else if (this._popupPosition == Sys.Extended.UI.ValidatorCalloutPosition.BottomRight)
104                calloutArrowCell.className = "ajax__validatorcallout_callout_arrow_cell_bottomrightpos";
105            else if (this._popupPosition == Sys.Extended.UI.ValidatorCalloutPosition.TopLeft)
106                calloutArrowCell.className = "ajax__validatorcallout_callout_arrow_cell_topleftpos";
107            else if (this._popupPosition == Sys.Extended.UI.ValidatorCalloutPosition.TopRight)
108                calloutArrowCell.className = "ajax__validatorcallout_callout_arrow_cell_toprightpos";
109            else if (this._popupPosition == Sys.Extended.UI.ValidatorCalloutPosition.Left)
110                calloutArrowCell.className = "ajax__validatorcallout_callout_arrow_cell_leftpos";
111            else
112                calloutArrowCell.className = "ajax__validatorcallout_callout_arrow_cell";
113            iconCell.className = "ajax__validatorcallout_icon_cell";
114            warningIconImage.border = 0;
115            warningIconImage.src = this.get_warningIconImageUrl();
116            errorMessageCell.className = "ajax__validatorcallout_error_message_cell";
117            errorMessageCell.innerHTML = this._getErrorMessage();
118            closeCell.className = "ajax__validatorcallout_close_button_cell";
119            closeCellInnerDiv.className = "ajax__validatorcallout_innerdiv";
120            closeImage.src = this.get_closeImageUrl();
121            elt.parentNode.appendChild(popupTable);
122            popupTable.appendChild(popupTableBody);
123            popupTableBody.appendChild(popupTableRow);
124            popupTableRow.appendChild(calloutCell);
125            calloutCell.appendChild(calloutTable);
126            calloutTable.appendChild(calloutTableBody);
127            calloutTableBody.appendChild(calloutTableRow);
128            calloutTableRow.appendChild(calloutArrowCell);
129            popupTableRow.appendChild(iconCell);
130            iconCell.appendChild(warningIconImage);
131            popupTableRow.appendChild(errorMessageCell);
132            popupTableRow.appendChild(closeCell);
133            closeCellInnerDiv.appendChild(closeImage);
134            closeCell.appendChild(closeCellInnerDiv);
135            if (this._popupPosition == Sys.Extended.UI.ValidatorCalloutPosition.BottomLeft ||
136            this._popupPosition == Sys.Extended.UI.ValidatorCalloutPosition.BottomRight) {
137                var calloutExtraTableRow = document.createElement("tr");
138                popupTableBody.insertBefore(calloutExtraTableRow, popupTableRow);
139                calloutArrowCell.colSpan = 2;
140                calloutExtraTableRow.appendChild(calloutArrowCell);
141                popupTableRow.appendChild(iconCell);
142                popupTableRow.appendChild(errorMessageCell);
143                popupTableRow.appendChild(closeCell);
144            }
145            else if (this._popupPosition == Sys.Extended.UI.ValidatorCalloutPosition.TopLeft ||
146                this._popupPosition == Sys.Extended.UI.ValidatorCalloutPosition.TopRight) {
147                var calloutExtraTableRow = document.createElement("tr");
148                popupTableBody.appendChild(calloutExtraTableRow);
149                calloutArrowCell.colSpan = 2;
150                calloutExtraTableRow.appendChild(calloutArrowCell);
151                popupTableRow.appendChild(iconCell);
152                popupTableRow.appendChild(errorMessageCell);
153                popupTableRow.appendChild(closeCell);
154            } else if (this._popupPosition == Sys.Extended.UI.ValidatorCalloutPosition.Left) {
155                popupTableRow.appendChild(iconCell);
156                popupTableRow.appendChild(errorMessageCell);
157                popupTableRow.appendChild(closeCell);
158                popupTableRow.appendChild(calloutCell);
159            }
160            else {
161                popupTableRow.appendChild(calloutCell);
162                popupTableRow.appendChild(iconCell);
163                popupTableRow.appendChild(errorMessageCell);
164                popupTableRow.appendChild(closeCell);
165            }
166            var div = document.createElement("div");
167            div.className = "ajax__validatorcallout_innerdiv";
168            calloutArrowCell.appendChild(div);
169            if (this._popupPosition == Sys.Extended.UI.ValidatorCalloutPosition.BottomLeft ||
170                this._popupPosition == Sys.Extended.UI.ValidatorCalloutPosition.BottomRight) {
171                var pixel = document.createElement("div");
172                pixel.style.width = "1px";
173                pixel.className = "arrowpixel";
174                div.appendChild(pixel);
175                for (var i = 1; i < 22; i += 2) {
176                    var line = document.createElement("div");
177                    line.style.width = i.toString() + "px";
178                    div.appendChild(line);
179                }
180            }
181            else if (this._popupPosition == Sys.Extended.UI.ValidatorCalloutPosition.TopLeft ||
182                this._popupPosition == Sys.Extended.UI.ValidatorCalloutPosition.TopRight) {
183                for (var i = 23; i > 0; i -= 2) {
184                    var line = document.createElement("div");
185                    line.style.width = i.toString() + "px";
186                    div.appendChild(line);
187                }
188                var pixel = document.createElement("div");
189                pixel.style.width = "1px";
190                pixel.className = "arrowpixel";
191                div.appendChild(pixel);
192            }
193            else {
194                for (var i = 14; i > 0; i--) {
195                    var line = document.createElement("div");
196                    line.style.width = i.toString() + "px";
197                    div.appendChild(line);
198                }
199            }
200            
201            this._popupBehavior = $create(
202                Sys.Extended.UI.PopupBehavior, 
203                { 
204                    parentElement : elementToValidate
205                }, 
206                { }, 
207                null,
208                this._popupTable);
209            if (this._popupPosition == Sys.Extended.UI.ValidatorCalloutPosition.TopLeft) {
210                this._popupBehavior.set_positioningMode(Sys.Extended.UI.PositioningMode.TopLeft);
211            } else if (this._popupPosition == Sys.Extended.UI.ValidatorCalloutPosition.TopRight) {
212                this._popupBehavior.set_positioningMode(Sys.Extended.UI.PositioningMode.TopRight);
213            } else if (this._popupPosition == Sys.Extended.UI.ValidatorCalloutPosition.BottomLeft) {
214                this._popupBehavior.set_positioningMode(Sys.Extended.UI.PositioningMode.BottomLeft);
215            } else if (this._popupPosition == Sys.Extended.UI.ValidatorCalloutPosition.BottomRight) {
216                this._popupBehavior.set_positioningMode(Sys.Extended.UI.PositioningMode.BottomRight);
217            } else if (this._popupPosition == Sys.Extended.UI.ValidatorCalloutPosition.Right) {
218                this._popupBehavior.set_positioningMode(Sys.Extended.UI.PositioningMode.Right);
219            } else if (this._popupPosition == Sys.Extended.UI.ValidatorCalloutPosition.Left) {
220                this._popupBehavior.set_positioningMode(Sys.Extended.UI.PositioningMode.Left);
221            } else {
222                this._popupBehavior.set_positioningMode(Sys.Extended.UI.PositioningMode.Right);
223            }
224            
225            if (this._onShowJson) {
226                this._popupBehavior.set_onShow(this._onShowJson);
227            }
228            if (this._onHideJson) {
229                this._popupBehavior.set_onHide(this._onHideJson);
230            }
231            
232            $addHandler(this._closeCellInnerDiv, "click", this._closeClickHandler);
233            this._isBuilt = true;
234        }
235    },
236    
237    dispose : function() {
238        
239        if (this._isBuilt) {
240            this.hide();
241            
242            if (this._focusAttached) {
243                $removeHandler(this._elementToValidate, "focus", this._focusHandler);
244                this._focusAttached = false;
245            }
246            $removeHandler(this._closeCellInnerDiv, "click", this._closeClickHandler);
247            
248            this._onShowJson = null;
249            this._onHideJson = null;
250            if (this._popupBehavior) {
251                this._popupBehavior.dispose();
252                this._popupBehavior = null;
253            }
254            if (this._closeBehavior) {
255                this._closeBehavior.dispose();
256                this._closeBehavior = null;
257            }
258            if (this._popupTable) {
259                this._popupTable.parentNode.removeChild(this._popupTable);
260                this._popupTable = null;
261                this._errorMessageCell = null;
262                this._elementToValidate = null;
263                this._calloutArrowCell = null;
264                this._warningIconImage = null;
265                this._closeImage = null;
266                this._closeCellInnerDiv = null;
267            }
268            this._isBuilt = false;
269        }
270        Sys.Extended.UI.ValidatorCalloutBehavior.callBaseMethod(this, 'dispose');
271    },    
272    
273    _getErrorMessage : function() {
274        return this.get_element().errormessage || Sys.Extended.UI.Resources.ValidatorCallout_DefaultErrorMessage;
275    },
276        
277    show : function(force) {        
278        if (force || !this.get_isOpen()) {
279            if(force && Sys.Extended.UI.ValidatorCalloutBehavior._currentCallout) {
280                Sys.Extended.UI.ValidatorCalloutBehavior._currentCallout.hide();
281            }
282            if(Sys.Extended.UI.ValidatorCalloutBehavior._currentCallout != null) {
283                return;
284            }
285            Sys.Extended.UI.ValidatorCalloutBehavior._currentCallout = this;
286            this._errorMessageCell.innerHTML = this._getErrorMessage();
287            this._popupBehavior.show();
288        }
289    },
290    
291    hide : function() {
292        if(Sys.Extended.UI.ValidatorCalloutBehavior._currentCallout == this) {
293            Sys.Extended.UI.ValidatorCalloutBehavior._currentCallout = null;
294        }
295        if (this.get_isOpen()) {
296            this._popupBehavior.hide();
297        }
298    },
299
300    _onfocus : function(e) {
301        if(!this._originalValidationMethod(this.get_element())) {
302            this._ensureCallout();
303             if(this._highlightCssClass) {
304                Sys.UI.DomElement.addCssClass(this._elementToValidate, this._highlightCssClass);
305            }
306            this.show(true);
307            return false;
308        } else {
309            this.hide();
310            return true;
311        }
312    },
313    
314    _oncloseClick : function(e) {
315        this.hide();
316    },
317    
318    _onvalidate : function(val) {
319        if(!this._originalValidationMethod(val)) {
320            this._ensureCallout();
321            if(this._highlightCssClass) {
322                Sys.UI.DomElement.addCssClass(this._elementToValidate, this._highlightCssClass);
323            }
324            if (!this._focusAttached) {
325                $addHandler(this._elementToValidate, "focus", this._focusHandler);
326                this._focusAttached = true;
327            }
328            this.show(false);
329            this._invalid = true;
330            return false;
331        } else {
332            if(this._highlightCssClass && this._invalid) {
333                Sys.UI.DomElement.removeCssClass(this._elementToValidate, this._highlightCssClass);
334            }
335            this._invalid = false;
336            this.hide();
337            return true;
338        }
339    },
340    
341    get_onShow : function() {
342        /// <value type="String" mayBeNull="true">
343        /// Generic OnShow Animation's JSON definition
344        /// </value>
345        return this._popupBehavior ? this._popupBehavior.get_onShow() : this._onShowJson;
346    },
347    set_onShow : function(value) {
348        if (this._popupBehavior) {
349            this._popupBehavior.set_onShow(value);
350        } else {
351            this._onShowJson = value;
352        }
353        this.raisePropertyChanged('onShow');
354    },
355    get_onShowBehavior : function() {
356        /// <value type="Sys.Extended.UI.Animation.GenericAnimationBehavior">
357        /// Generic OnShow Animation's behavior
358        /// </value>
359        return this._popupBehavior ? this._popupBehavior.get_onShowBehavior() : null;
360    },
361    onShow : function() {
362        /// <summary>
363        /// Play the OnShow animation
364        /// </summary>
365        /// <returns />
366        if (this._popupBehavior) {
367            this._popupBehavior.onShow();
368        }
369    },
370        
371    get_onHide : function() {
372        /// <value type="String" mayBeNull="true">
373        /// Generic OnHide Animation's JSON definition
374        /// </value>
375        return this._popupBehavior ? this._popupBehavior.get_onHide() : this._onHideJson;
376    },
377    set_onHide : function(value) {
378        if (this._popupBehavior) {
379            this._popupBehavior.set_onHide(value);
380        } else {
381            this._onHideJson = value;
382        }
383        this.raisePropertyChanged('onHide');
384    },
385    get_onHideBehavior : function() {
386        /// <value type="Sys.Extended.UI.Animation.GenericAnimationBehavior">
387        /// Generic OnHide Animation's behavior
388        /// </value>
389        return this._popupBehavior ? this._popupBehavior.get_onHideBehavior() : null;
390    },
391    onHide : function() {
392        /// <summary>
393        /// Play the OnHide animation
394        /// </summary>
395        /// <returns />
396        if (this._popupBehavior) {
397            this._popupBehavior.onHide();
398        }
399    },
400    
401    get_warningIconImageUrl : function() {
402        return this._warningIconImageUrl;
403    },
404    set_warningIconImageUrl : function(value) {
405        
406        if (this._warningIconImageUrl != value) {
407            this._warningIconImageUrl = value;
408            if (this.get_isInitialized()) {
409                this._warningIconImage.src = value;
410            }
411            this.raisePropertyChanged("warningIconImageUrl");
412        }
413    },
414
415    get_closeImageUrl : function() {
416        return this._closeImageUrl;
417    },
418    set_closeImageUrl : function(value) {
419
420        if (this._closeImageUrl != value) {
421            this._closeImageUrl = value;
422            if (this.get_isInitialized()) {
423                this._closeImage.src = value;
424            }
425            this.raisePropertyChanged("closeImageUrl");
426        }
427    },
428        
429    get_width : function() {
430        return this._width;
431    },
432    set_width : function(value) {
433
434        if (this._width != value) { 
435            this._width = value;
436            if (this.get_isInitialized()) {
437                this._popupTable.style.width = _width;
438            }
439            this.raisePropertyChanged("width");
440        }
441    },
442
443    get_popupPosition: function() {
444        /// <value type="Sys.Extended.UI.ValidatorCalloutPosition">
445        /// Where the popup should be positioned relative to the target control.
446        /// Can be Right (Default), Left, BottomLeft, BottomRight, TopLeft or TopRight.
447        /// </value>
448
449        return this._popupPosition;
450    },
451    set_popupPosition: function(value) {
452        if (this._popupPosition != value) {
453            this._popupPosition = value;
454            this.raisePropertyChanged('popupPosition');
455        }
456    },
457
458    get_cssClass : function() {
459        return this._cssClass;
460    },
461    set_cssClass : function(value) {
462
463        if (this._cssClass != value) {
464            this._cssClass = value;
465            this.raisePropertyChanged("cssClass");
466        }
467    },
468
469    get_highlightCssClass : function() {
470        return this._highlightCssClass;
471    },
472    set_highlightCssClass : function(value) {
473
474        if (this._highlightCssClass != value) {
475            this._highlightCssClass = value;
476            this.raisePropertyChanged("highlightCssClass");
477        }
478    },
479    
480    get_isOpen : function() {
481        return $common.getVisible(this._popupTable);
482    }
483};
484Sys.Extended.UI.ValidatorCalloutBehavior.registerClass('Sys.Extended.UI.ValidatorCalloutBehavior', Sys.Extended.UI.BehaviorBase);
485
486Sys.Extended.UI.ValidatorCalloutPosition = function() {
487    /// <summary>
488    /// Position of the popup relative to the target control
489    /// </summary>
490    /// <field name="BottomLeft" type="Number" integer="true" />
491    /// <field name="BottomRight" type="Number" integer="true" />
492    /// <field name="TopLeft" type="Number" integer="true" />
493    /// <field name="TopRight" type="Number" integer="true" />
494    /// <field name="Right" type="Number" integer="true" />
495    /// <field name="Left" type="Number" integer="true" />
496    throw Error.invalidOperation();
497};
498Sys.Extended.UI.ValidatorCalloutPosition.prototype = {
499    Right: 0,
500    Left: 1,
501    BottomLeft: 2,
502    BottomRight: 3,
503    TopLeft: 4,
504    TopRight: 5
505};
506Sys.Extended.UI.ValidatorCalloutPosition.registerEnum('Sys.Extended.UI.ValidatorCalloutPosition');

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.