PageSourceSearch

https://jfda.jo/ScriptResource.axd?d=euYsJzLPLarE8LiAZwJKcBaMC_v4P…oP9O6z1Nz3qNB5oq__ejQSd7ymw78v50&t=5e95cc64

js jfda.jo collected 2026-09-28 09:36:56 UTC 23,190 bytes, 695 lines download raw bytes

1// Name:        Popup.debug.js
2// Assembly:    AjaxControlToolkit
3// Version:     18.1.0.0
4// FileVersion: 18.1.0.0
5Type.registerNamespace('Sys.Extended.UI');
6
7Sys.Extended.UI.PopupBehavior = function(element) {
8    // The PopupBehavior is used to show/hide an element at a position
9    // relative to another element
10    // "element" - the DOM element the behavior is associated with
11    Sys.Extended.UI.PopupBehavior.initializeBase(this, [element]);
12
13    this._x = 0;
14    this._y = 0;
15    this._positioningMode = Sys.Extended.UI.PositioningMode.Absolute;
16    this._parentElement = null;
17    this._parentElementID = null;
18    this._moveHandler = null;
19    this._firstPopup = true;
20    this._originalParent = null;
21    this._visible = false;
22    this._unselectable = null;
23
24    // Generic animation behaviors that automatically build animations
25    // from JSON descriptions
26    this._onShow = null;
27    this._onHide = null;
28
29    this._onShowEndedHandler = Function.createDelegate(this, this._onShowEnded);
30    this._onHideEndedHandler = Function.createDelegate(this, this._onHideEnded);
31}
32
33Sys.Extended.UI.PopupBehavior.prototype = {
34
35    initialize: function() {
36        Sys.Extended.UI.PopupBehavior.callBaseMethod(this, 'initialize');
37
38        this._hidePopup();
39        this.get_element().style.position = "absolute";
40    },
41
42    dispose: function() {
43        var element = this.get_element();
44
45        if(element) {
46            if(this._visible)
47                this.hide();
48
49            if(this._originalParent) {
50                element.parentNode.removeChild(element);
51                this._originalParent.appendChild(element);
52                this._originalParent = null;
53            }
54
55            // Remove expando properties
56            element._hideWindowedElementsIFrame = null;
57        }
58        this._parentElement = null;
59
60        // Remove the animation ended events and wipe the animations
61        // (we don't need to dispose them because that will happen
62        // automatically in our base dispose)
63        if(this._onShow && this._onShow.get_animation())
64            this._onShow.get_animation().remove_ended(this._onShowEndedHandler);
65
66        this._onShow = null;
67        if(this._onHide && this._onHide.get_animation())
68            this._onHide.get_animation().remove_ended(this._onHideEndedHandler);
69
70        this._onHide = null;
71
72        Sys.Extended.UI.PopupBehavior.callBaseMethod(this, 'dispose');
73    },
74
75    show: function() {
76        // Ignore requests to hide multiple times
77        if(this._visible)
78            return;
79
80        var eventArgs = new Sys.CancelEventArgs();
81        this.raise_showing(eventArgs);
82
83        if(eventArgs.get_cancel())
84            return;
85
86        // Either show the popup or play an animation that does
87        // (note: even if we're animating, we still show and position
88        // the popup before hiding it again and playing the animation
89        // which makes the animation much simpler)
90        this._visible = true;
91        var element = this.get_element();
92        $common.setVisible(element, true);
93        this.setupPopup();
94
95        if(this._onShow) {
96            $common.setVisible(element, false);
97            this.onShow();
98        } else {
99            this.raise_shown(Sys.EventArgs.Empty);
100        }
101    },
102
103    hide: function() {
104        // Ignore requests to hide multiple times
105        if(!this._visible)
106            return;
107
108        var eventArgs = new Sys.CancelEventArgs();
109        this.raise_hiding(eventArgs);
110        if(eventArgs.get_cancel())
111            return;
112
113        // Either hide the popup or play an animation that does
114        this._visible = false;
115        if(this._onHide) {
116            this.onHide();
117        } else {
118            this._hidePopup();
119            this._hideCleanup();
120        }
121    },
122
123    getBounds: function() {
124        // Get the expected bounds of the popup relative to its parent
125        // returns bounds of the popup relative to its parent
126
127        // The actual final position can only be calculated after it is
128        // initially set and we can verify it doesn't bleed off the edge
129        // of the screen.
130        var element = this.get_element();
131
132        // offsetParent (doc element if absolutely positioned or no offsetparent available)
133        var offsetParent = element.offsetParent || document.documentElement;
134
135        // diff = difference in position between element's offsetParent and the element we will attach popup to.
136        // this is basically so we can position the popup in the right spot even though it may not be absolutely positioned
137        var diff;
138        var parentBounds;
139
140        if(this.get_parentElement()) {
141            // we will be positioning the element against the assigned parent
142            parentBounds = $common.getBounds(this.get_parentElement());
143            var offsetParentLocation = $common.getLocation(offsetParent);
144            diff = { x: parentBounds.x - offsetParentLocation.x, y: parentBounds.y - offsetParentLocation.y };
145        } else {
146            // we will be positioning the element against the offset parent by default, since no parent element given
147            parentBounds = $common.getBounds(offsetParent);
148            diff = { x: 0, y: 0 };
149        }
150
151        // width/height of the element, needed for calculations that involve width like centering
152        var width = element.offsetWidth - (element.clientLeft ? element.clientLeft * 2 : 0),
153            height = element.offsetHeight - (element.clientTop ? element.clientTop * 2 : 0);
154
155        // Setting the width causes the element to grow by border+passing every
156        // time.  But not setting it causes strange behavior in safari. Just set it once.
157        if(this._firstpopup) {
158            element.style.width = width + "px";
159            this._firstpopup = false;
160        }
161
162        var position, pos;
163        switch(this._positioningMode) {
164            case Sys.Extended.UI.PositioningMode.Center:
165                pos = {
166                    x: Math.round(parentBounds.width / 2 - width / 2),
167                    y: Math.round(parentBounds.height / 2 - height / 2),
168                    altX: Math.round(parentBounds.width / 2 - width / 2),
169                    altY: Math.round(parentBounds.height / 2 - height / 2)
170                };
171                break;
172            case Sys.Extended.UI.PositioningMode.BottomLeft:
173                pos = {
174                    x: 0,
175                    y: parentBounds.height,
176                    altX: parentBounds.width - width,
177                    altY: 0 - height
178                }
179                break;
180            case Sys.Extended.UI.PositioningMode.BottomRight:
181                pos = {
182                    x: parentBounds.width - width,
183                    y: parentBounds.height,
184                    altX: 0,
185                    altY: 0 - height
186                }
187                break;
188            case Sys.Extended.UI.PositioningMode.TopLeft:
189                pos = {
190                    x: 0,
191                    y: -element.offsetHeight,
192                    altX: parentBounds.width - width,
193                    altY: parentBounds.height
194                }
195                break;
196            case Sys.Extended.UI.PositioningMode.TopRight:
197                pos = {
198                    x: parentBounds.width - width,
199                    y: -element.offsetHeight,
200                    altX: 0,
201                    altY: parentBounds.height
202                }
203                break;
204            case Sys.Extended.UI.PositioningMode.Right:
205                pos = {
206                    x: parentBounds.width,
207                    y: 0,
208                    altX: -element.offsetWidth,
209                    altY: parentBounds.height - height
210                }
211                break;
212            case Sys.Extended.UI.PositioningMode.Left:
213                pos = {
214                    x: -element.offsetWidth,
215                    y: 0,
216                    altX: parentBounds.width,
217                    altY: parentBounds.height - height
218                }
219                break;
220            default:
221                pos = { x: 0, y: 0, altX: 0, altY: 0 };
222        }
223
224        pos.x += this._x + diff.x;
225        pos.altX += this._x + diff.x;
226        pos.y += this._y + diff.y;
227        pos.altY += this._y + diff.y;
228
229        position = this._verifyPosition(pos, width, height, parentBounds);
230
231        return new Sys.UI.Bounds(position.x, position.y, width, height);
232    },
233
234    _verifyPosition: function(pos, elementWidth, elementHeight, parentBounds) {
235        //Checks whether the popup is entirely visible and attempts to change its position to make it entirely visible.
236        var newX = 0, newY = 0;
237        var windowBounds = this._getWindowBounds();
238
239        // Check horizontal positioning
240        if(!((pos.x + elementWidth > windowBounds.x + windowBounds.width) || (pos.x < windowBounds.x))) {
241            newX = pos.x;
242        } else {
243            newX = pos.altX;
244
245            if(pos.altX < windowBounds.x) {
246                if(pos.x > pos.altX)
247                    newX = pos.x;
248            } else if(windowBounds.width + windowBounds.x - pos.altX < elementWidth) {
249                var xDiff = pos.x > pos.altX ? Math.abs(windowBounds.x - pos.x) : (windowBounds.x - pos.x);
250                if(xDiff < elementWidth - windowBounds.width - windowBounds.x + pos.altX)
251                    newX = pos.x;
252            }
253        }
254
255        // Check vertical positioning
256        if(!((pos.y + elementHeight > windowBounds.y + windowBounds.height) || (pos.y < windowBounds.y))) {
257            newY = pos.y;
258        } else {
259            newY = pos.altY;
260
261            if(pos.altY < windowBounds.y) {
262                if(windowBounds.y - pos.altY > elementHeight - windowBounds.height - windowBounds.y + pos.y)
263                    newY = pos.y;
264            } else if(windowBounds.height + windowBounds.y - pos.altY < elementHeight) {
265                if(windowBounds.y - pos.y < elementHeight - windowBounds.height - windowBounds.y + pos.altY)
266                    newY = pos.y;
267            }
268        }
269
270        return { x: newX, y: newY };
271    },
272
273    _getWindowBounds: function() {
274        var bounds = {
275            x: this._getWindowScrollLeft(),
276            y: this._getWindowScrollTop(),
277            width: this._getWindowWidth(),
278            height: this._getWindowHeight()
279        };
280
281        return bounds;
282    },
283
284    _getWindowHeight: function() {
285        var windowHeight = 0;
286
287        if(document.documentElement && document.documentElement.clientHeight)
288            windowHeight = document.documentElement.clientHeight;
289        else if(document.body && document.body.clientHeight)
290            windowHeight = document.body.clientHeight;
291
292        return windowHeight;
293    },
294
295    _getWindowWidth: function() {
296        var windowWidth = 0;
297
298        if(document.documentElement && document.documentElement.clientWidth)
299            windowWidth = document.documentElement.clientWidth;
300        else if(document.body && document.body.clientWidth)
301            windowWidth = document.body.clientWidth;
302
303        return windowWidth;
304    },
305
306    _getWindowScrollTop: function() {
307        var scrollTop = 0;
308
309        if(typeof (window.pageYOffset) == 'number')
310            scrollTop = window.pageYOffset;
311        if(document.body && document.body.scrollTop)
312            scrollTop = document.body.scrollTop;
313        else if(document.documentElement && document.documentElement.scrollTop)
314            scrollTop = document.documentElement.scrollTop;
315
316        return scrollTop;
317    },
318
319    _getWindowScrollLeft: function() {
320        var scrollLeft = 0;
321
322        if(typeof (window.pageXOffset) == 'number')
323            scrollLeft = window.pageXOffset;
324        else if(document.body && document.body.scrollLeft)
325            scrollLeft = document.body.scrollLeft;
326        else if(document.documentElement && document.documentElement.scrollLeft)
327            scrollLeft = document.documentElement.scrollLeft;
328
329        return scrollLeft;
330    },
331
332    adjustPopupPosition: function(bounds) {
333        // Adjust the position of the popup after it's originally bet set
334        // to make sure that it's visible on the page.
335        // "bounds" - original bounds of the parent element
336        var element = this.get_element();
337        if(!bounds)
338            bounds = this.getBounds();
339
340        // Get the new bounds now that we've shown the popup
341        var newPosition = $common.getBounds(element),
342            updateNeeded = false;
343
344        if(newPosition.x < 0) {
345            bounds.x -= newPosition.x;
346            updateNeeded = true;
347        }
348        if(newPosition.y < 0) {
349            bounds.y -= newPosition.y;
350            updateNeeded = true;
351        }
352
353        // If the popup was off the screen, reposition it
354        if(updateNeeded)
355            $common.setLocation(element, bounds);
356    },
357
358    addBackgroundIFrame: function() {
359        // Add an empty IFRAME behind the popup (for IE6 only) so that SELECT, etc., won't
360        // show through the popup.
361
362        // Get the child frame
363        var element = this.get_element();
364        if((Sys.Browser.agent === Sys.Browser.InternetExplorer) && (Sys.Browser.version < 7)) {
365            var childFrame = element._hideWindowedElementsIFrame;
366
367            // Create the child frame if it wasn't found
368            if(!childFrame) {
369                childFrame = document.createElement("iframe");
370                childFrame.src = "javascript:'<html></html>';";
371                childFrame.style.position = "absolute";
372                childFrame.style.display = "none";
373                childFrame.scrolling = "no";
374                childFrame.frameBorder = "0";
375                childFrame.tabIndex = "-1";
376                childFrame.style.filter = "progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)";
377                element.parentNode.insertBefore(childFrame, element);
378                element._hideWindowedElementsIFrame = childFrame;
379                this._moveHandler = Function.createDelegate(this, this._onMove);
380                Sys.UI.DomEvent.addHandler(element, "move", this._moveHandler);
381            }
382
383            // Position the frame exactly behind the element
384            $common.setBounds(childFrame, $common.getBounds(element));
385
386            childFrame.style.left = element.style.left;
387            childFrame.style.top = element.style.top;
388            childFrame.style.display = element.style.display;
389
390            if(element.currentStyle && element.currentStyle.zIndex)
391                childFrame.style.zIndex = element.currentStyle.zIndex;
392            else if(element.style.zIndex)
393                childFrame.style.zIndex = element.style.zIndex;
394        }
395    },
396
397    setupPopup: function() {
398        // Position the popup relative to its parent
399        var element = this.get_element();
400        var bounds = this.getBounds();
401        $common.setLocation(element, bounds);
402
403        // Tweak the position, set the zIndex, and add the background iframe in IE6
404        this.adjustPopupPosition(bounds);
405        element.style.zIndex = Sys.Extended.UI.zIndex.Popup;
406        this.addBackgroundIFrame();
407    },
408
409    _hidePopup: function() {
410        var element = this.get_element();
411        $common.setVisible(element, false);
412        
413        if(element.originalWidth) {
414            element.style.width = element.originalWidth + "px";
415            element.originalWidth = null;
416        }
417    },
418
419    _hideCleanup: function() {
420        // Perform cleanup after hiding the element
421        var element = this.get_element();
422
423        // Remove the tracking handler
424        if(this._moveHandler) {
425            Sys.UI.DomEvent.removeHandler(element, "move", this._moveHandler);
426            this._moveHandler = null;
427        }
428
429        // Hide the child frame
430        if(Sys.Browser.agent === Sys.Browser.InternetExplorer) {
431            var childFrame = element._hideWindowedElementsIFrame;
432            if(childFrame)
433                childFrame.style.display = "none";
434        }
435
436        this.raise_hidden(Sys.EventArgs.Empty);
437    },
438
439    _onMove: function() {
440        // Track the popup's movements so the hidden IFrame (IE6 only) can
441        // be moved along with it
442
443        var element = this.get_element();
444        if(element._hideWindowedElementsIFrame) {
445            element.parentNode.insertBefore(element._hideWindowedElementsIFrame, element);
446            element._hideWindowedElementsIFrame.style.top = element.style.top;
447            element._hideWindowedElementsIFrame.style.left = element.style.left;
448        }
449    },
450
451    get_onShow: function() {
452        // Generic OnShow Animation's JSON definition
453        return this._onShow ? this._onShow.get_json() : null;
454    },
455
456    set_onShow: function(value) {
457        if(!this._onShow) {
458            this._onShow = new Sys.Extended.UI.Animation.GenericAnimationBehavior(this.get_element());
459            this._onShow.initialize();
460        }
461
462        this._onShow.set_json(value);
463        var animation = this._onShow.get_animation();
464
465        if(animation)
466            animation.add_ended(this._onShowEndedHandler);
467
468        this.raisePropertyChanged('onShow');
469    },
470
471    get_onShowBehavior: function() {
472        // Generic OnShow Animation's behavior
473        return this._onShow;
474    },
475
476    onShow: function() {
477        if(this._onShow) {
478            if(this._onHide)
479                this._onHide.quit();
480
481            this._onShow.play();
482        }
483    },
484
485    _onShowEnded: function() {
486        // Make sure the popup is where it belongs
487        this.adjustPopupPosition();
488        this.addBackgroundIFrame();
489
490        this.raise_shown(Sys.EventArgs.Empty);
491    },
492
493    get_onHide: function() {
494        // Generic OnHide Animation's JSON definition
495        return this._onHide ? this._onHide.get_json() : null;
496    },
497
498    set_onHide: function(value) {
499        if(!this._onHide) {
500            this._onHide = new Sys.Extended.UI.Animation.GenericAnimationBehavior(this.get_element());
501            this._onHide.initialize();
502        }
503
504        this._onHide.set_json(value);
505        var animation = this._onHide.get_animation();
506
507        if(animation)
508            animation.add_ended(this._onHideEndedHandler);
509
510        this.raisePropertyChanged('onHide');
511    },
512
513    get_onHideBehavior: function() {
514        // Generic OnHide Animation's behavior
515        return this._onHide;
516    },
517
518    onHide: function() {
519        if(this._onHide) {
520            if(this._onShow)
521                this._onShow.quit();
522
523            this._onHide.play();
524        }
525    },
526
527    _onHideEnded: function() {
528        this._hideCleanup();
529    },
530
531    get_parentElement: function() {
532        if(!this._parentElement && this._parentElementID)
533            this.set_parentElement($get(this._parentElementID));
534
535        return this._parentElement;
536    },
537
538    set_parentElement: function(element) {
539        this._parentElement = element;
540        this.raisePropertyChanged('parentElement');
541    },
542
543    get_parentElementID: function() {
544        if(this._parentElement)
545            return this._parentElement.id
546
547        return this._parentElementID;
548    },
549
550    set_parentElementID: function(elementID) {
551        this._parentElementID = elementID;
552
553        if(this.get_isInitialized())
554            this.set_parentElement($get(elementID));
555    },
556
557    get_positioningMode: function() {
558        return this._positioningMode;
559    },
560
561    set_positioningMode: function(mode) {
562        this._positioningMode = mode;
563        this.raisePropertyChanged('positioningMode');
564    },
565
566    get_x: function() {
567        return this._x;
568    },
569
570    set_x: function(value) {
571        if(value != this._x) {
572            this._x = value;
573
574            // Reposition the popup if it's already showing
575            if(this._visible)
576                this.setupPopup();
577
578            this.raisePropertyChanged('x');
579        }
580    },
581
582    get_y: function() {
583        return this._y;
584    },
585
586    set_y: function(value) {
587        if(value != this._y) {
588            this._y = value;
589
590            // Reposition the popup if it's already showing
591            if(this._visible)
592                this.setupPopup();
593
594            this.raisePropertyChanged('y');
595        }
596    },
597
598    get_visible: function() {
599        return this._visible;
600    },
601
602    add_showing: function(handler) {
603        this.get_events().addHandler('showing', handler);
604    },
605    remove_showing: function(handler) {
606        this.get_events().removeHandler('showing', handler);
607    },
608    raise_showing: function(eventArgs) {
609        var handler = this.get_events().getHandler('showing');
610        if(handler)
611            handler(this, eventArgs);
612    },
613    raiseShowing: function(eventArgs) {
614        Sys.Extended.Deprecated("raiseShowing(eventArgs)", "raise_showing(eventArgs)");
615        this.raise_showing(eventArgs);
616    },
617
618    add_shown: function(handler) {
619        this.get_events().addHandler('shown', handler);
620    },
621    remove_shown: function(handler) {
622        this.get_events().removeHandler('shown', handler);
623    },
624    raise_shown: function(eventArgs) {
625        var handler = this.get_events().getHandler('shown');
626        if(handler)
627            handler(this, eventArgs);
628    },
629    raiseShown: function(eventArgs) {
630        Sys.Extended.Deprecated("raiseShown(eventArgs)", "raise_shown(eventArgs)");
631        this.raise_shown(eventArgs);
632    },
633
634    add_hiding: function(handler) {
635        this.get_events().addHandler('hiding', handler);
636    },
637    remove_hiding: function(handler) {
638        this.get_events().removeHandler('hiding', handler);
639    },
640    raise_hiding: function(eventArgs) {
641        var handler = this.get_events().getHandler('hiding');
642        if(handler)
643            handler(this, eventArgs);
644    },
645    raiseHiding: function(eventArgs) {
646        Sys.Extended.Deprecated("raiseHiding(eventArgs)", "raise_hiding(eventArgs)");
647        this.raise_hiding(eventArgs);
648    },
649
650    add_hidden: function(handler) {
651        this.get_events().addHandler('hidden', handler);
652    },
653    remove_hidden: function(handler) {
654        this.get_events().removeHandler('hidden', handler);
655    },
656    raise_hidden: function(eventArgs) {
657        var handler = this.get_events().getHandler('hidden');
658        if(handler)
659            handler(this, eventArgs);
660    },
661    raiseHidden: function(eventArgs) {
662        Sys.Extended.Deprecated("raiseHidden(eventArgs)", "raise_hidden(eventArgs)");
663        this.raise_hidden(eventArgs);
664    },
665
666    get_unselectable: function()
667    {
668        return this._unselectable;
669    },
670
671    set_unselectable: function(value)
672    {
673        this._unselectable = value;
674        // TODO: _this.setAttribute('unselectable', 'on');
675        this.raisePropertyChanged('unselectable');
676    }
677}
678Sys.Extended.UI.PopupBehavior.registerClass('Sys.Extended.UI.PopupBehavior', Sys.Extended.UI.BehaviorBase);
679
680Sys.Extended.UI.PositioningMode = function() {
681    throw Error.invalidOperation();
682}
683
684Sys.Extended.UI.PositioningMode.prototype = {
685    Absolute: 0,
686    Center: 1,
687    BottomLeft: 2,
688    BottomRight: 3,
689    TopLeft: 4,
690    TopRight: 5,
691    Right: 6,
692    Left: 7
693}
694
695Sys.Extended.UI.PositioningMode.registerEnum('Sys.Extended.UI.PositioningMode');

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.