1// Name: PopupControl.PopupControlBehavior.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 path="../ExtenderBase/BaseScripts.js" /> 11/// <reference path="../Common/Common.js" /> 12/// <reference path="../DynamicPopulate/DynamicPopulateBehavior.js" /> 13/// <reference path="../Animation/Animations.js" /> 14/// <reference path="../Animation/AnimationBehavior.js" /> 15/// <reference path="../PopupExtender/PopupBehavior.js" /> 16 17(function() { 18var scriptName = "ExtendedPopupBehavior"; 19 20function execute() { 21 22Type.registerNamespace('Sys.Extended.UI'); 23 24Sys.Extended.UI.PopupControlBehavior = function(element) { 25 /// <summary> 26 /// The PopupControlBehavior opens a popup window next to the target element 27 /// </summary> 28 /// <param name="element" type="Sys.UI.DomElement" domElement="true"> 29 /// DOM element associated with the behavior 30 /// </param> 31 Sys.Extended.UI.PopupControlBehavior.initializeBase(this, [element]); 32 33 this._popupControlID = null; 34 this._commitProperty = null; 35 this._commitScript = null; 36 this._position = null; 37 this._offsetX = 0; 38 this._offsetY = 0; 39 this._extenderControlID = null; 40 41 this._popupElement = null; 42 this._popupBehavior = null; 43 this._popupVisible = false; 44 this._focusHandler = null; 45 this._popupKeyDownHandler = null; 46 this._popupClickHandler = null; 47 this._bodyClickHandler = null; 48 this._onShowJson = null; 49 this._onHideJson = null; 50}; 51 Sys.Extended.UI.PopupControlBehavior.prototype = { 52 initialize : function() { 53 /// <summary> 54 /// Initialize the behavior 55 /// </summary> 56 Sys.Extended.UI.PopupControlBehavior.callBaseMethod(this, 'initialize'); 57 58 var e = this.get_element(); 59 this._popupElement = $get(this._popupControlID); 60 61 this._popupBehavior = $create(Sys.Extended.UI.PopupBehavior, { 'id':this.get_id()+'PopupBehavior', 'parentElement':e }, null, null, this._popupElement); 62 63 if (this._onShowJson) { 64 this._popupBehavior.set_onShow(this._onShowJson); 65 } 66 if (this._onHideJson) { 67 this._popupBehavior.set_onHide(this._onHideJson); 68 } 69 70 this._focusHandler = Function.createDelegate(this, this._onFocus); 71 this._popupClickHandler = Function.createDelegate(this, this._onPopupClick); 72 this._bodyClickHandler = Function.createDelegate(this, this._onBodyClick); 73 this._popupKeyDownHandler = Function.createDelegate(this, this._onPopupKeyDown); 74 75 $addHandler(e, 'focus', this._focusHandler); 76 $addHandler(e, 'click', this._focusHandler); // So that a dismissed popup can be more easily re-popped 77 $addHandler(document.body, 'click', this._bodyClickHandler); 78 $addHandler(this._popupElement, 'click', this._popupClickHandler); 79 $addHandler(this._popupElement, 'keydown', this._popupKeyDownHandler); 80 81 this.registerPartialUpdateEvents(); 82 83 if(Sys.Extended.UI.PopupControlBehavior.__VisiblePopup && (this.get_id() == Sys.Extended.UI.PopupControlBehavior.__VisiblePopup.get_id())) { 84 this._onFocus(null); 85 } 86 }, 87 88 dispose : function() { 89 /// <summary> 90 /// Dispose the behavior 91 /// </summary> 92 93 var e = this.get_element(); 94 95 this._onShowJson = null; 96 this._onHideJson = null; 97 98 if (this._popupBehavior) { 99 this._popupBehavior.dispose(); 100 this._popupBehavior = null; 101 } 102 if (this._focusHandler) { 103 $removeHandler(e, 'focus', this._focusHandler); 104 $removeHandler(e, 'click', this._focusHandler); 105 this._focusHandler = null; 106 } 107 if (this._bodyClickHandler) { 108 $removeHandler(document.body, 'click', this._bodyClickHandler); 109 this._bodyClickHandler = null; 110 } 111 if (this._popupClickHandler) { 112 $removeHandler(this._popupElement, 'click', this._popupClickHandler); 113 this._popupClickHandler = null; 114 }
115 if (this._popupKeyDownHandler) { 116 $removeHandler(this._popupElement, 'keydown', this._popupKeyDownHandler); 117 this._popupKeyDownHandler = null; 118 } 119 Sys.Extended.UI.PopupControlBehavior.callBaseMethod(this, 'dispose'); 120 }, 121 122 showPopup : function() { 123 /// <summary> 124 /// Display the popup 125 /// </summary> 126 127 var old = Sys.Extended.UI.PopupControlBehavior.__VisiblePopup; 128 if (old && old._popupBehavior) { 129 old.hidePopup(); 130 } 131 132 Sys.Extended.UI.PopupControlBehavior.callBaseMethod(this, 'populate'); 133 134 this._popupBehavior.set_x(this._getLeftOffset()); 135 this._popupBehavior.set_y(this._getTopOffset()); 136 this._popupBehavior.show(); 137 138 this._popupVisible = true; 139 Sys.Extended.UI.PopupControlBehavior.__VisiblePopup = this; 140 }, 141 142 hidePopup : function() { 143 /// <summary> 144 /// Hide the popup 145 /// </summary> 146 147 this._popupBehavior.hide(); 148 this._popupVisible = false; 149 Sys.Extended.UI.PopupControlBehavior.__VisiblePopup = null; 150 }, 151 152 _onFocus : function(e) { 153 /// <summary> 154 /// Show the popup when its control is focused 155 /// </summary> 156 /// <param name="e" type="Sys.UI.DomEvent" mayBeNull="true"> 157 /// Event info 158 /// </param> 159 160 if (!this._popupVisible) { 161 this.showPopup(); 162 } 163 if (e) { 164 e.stopPropagation(); 165 } 166 }, 167 168 _onPopupKeyDown : function(e) { 169 /// <summary> 170 /// Handle key presses in the popup element 171 /// </summary> 172 /// <param name="e" type="Sys.UI.DomEvent"> 173 /// Event info 174 /// </param> 175 176 if (this._popupVisible && e.keyCode == 27 /* Escape */) { 177 this.get_element().focus(); 178 } 179 }, 180 181 _onPopupClick : function(e) { 182 /// <summary> 183 /// Click handler for the popup 184 /// </summary> 185 /// <param name="e" type="Sys.UI.DomEvent"> 186 /// Event info 187 /// </param> 188 e.stopPropagation(); 189 }, 190 191 _onBodyClick : function() { 192 /// <summary> 193 /// Handler for the HTML body tag's click event 194 /// </summary> 195 196 if (this._popupVisible) { 197 this.hidePopup(); 198 } 199 }, 200 201 _close : function(result) { 202 /// <summary> 203 /// Close the popup 204 /// </summary> 205 /// <param name="result" type="String"> 206 /// Result obtained from committing the popup 207 /// </param> 208 209 var e = this.get_element(); 210 211 if (null != result) { 212 if ('$$CANCEL$$' != result) { 213 if (this._commitProperty) { 214 e[this._commitProperty] = result; 215 } else if ('text' == e.type) { 216 e.value = result; 217 } else { 218 Sys.Debug.assert(false, String.format(Sys.Extended.UI.Resources.PopupControl_NoDefaultProperty, e.id, e.type)); 219 } 220 if (this._commitScript) { 221 eval(this._commitScript); 222 } 223 } 224 225 this.hidePopup(); 226 } 227 }, 228 229 _partialUpdateEndRequest : function(sender, endRequestEventArgs) { 230 /// <summary> 231 /// Handler for UpdatePanel partial postback notifications 232 /// </summary> 233 /// <param name="sender" type="Object"> 234 /// Sender 235 /// </param> 236 /// <param name="endRequestEventArgs" type="Sys.WebForms.EndRequestEventArgs"> 237 /// Event arguments 238 /// </param> 239 Sys.Extended.UI.PopupControlBehavior.callBaseMethod(this, '_partialUpdateEndRequest', [sender, endRequestEventArgs]); 240 241 if (this.get_element()) { 242 var result = endRequestEventArgs.get_dataItems()[this.get_element().id]; 243 244 if ((undefined === result) && 245 Sys.Extended.UI.PopupControlBehavior.__VisiblePopup && 246 (this.get_id() == Sys.Extended.UI.PopupControlBehavior.__VisiblePopup.get_id())) { 247 result = endRequestEventArgs.get_dataItems()["_PopupControl_Proxy_ID_"]; 248 } 249 250 if (undefined !== result) { 251 this._close(result); 252 } 253 } 254 }, 255 256 _onPopulated : function(sender, eventArgs) { 257 /// <summary> 258 /// Handler for DynamicPopulate completion 259 /// </summary> 260 /// <param name="sender" type="Object"> 261 /// Sender 262 /// </param> 263 /// <param name="eventArgs" type="Sys.EventArgs"> 264 /// Event arguments 265 /// </param> 266 Sys.Extended.UI.PopupControlBehavior.callBaseMethod(this, '_onPopulated', [sender, eventArgs]); 267 268 if (this._popupVisible) { 269 this._popupBehavior.show(); 270 } 271 }, 272 273 _getLeftOffset : function() { 274 /// <summary> 275 /// Get the left offset for the popup 276 /// </summary> 277 /// <returns type="Number" integer="true"> 278 /// Left offset for the popup 279 /// </returns> 280 281 if (Sys.Extended.UI.PopupControlPopupPosition.Left == this._position) {
282 return (-1 * this.get_element().offsetWidth) + this._offsetX; 283 } else if (Sys.Extended.UI.PopupControlPopupPosition.Right == this._position) { 284 return this.get_element().offsetWidth + this._offsetX; 285 } else { 286 return this._offsetX; 287 } 288 }, 289 290 _getTopOffset : function() { 291 /// <summary> 292 /// Get the top offset for the popup 293 /// </summary> 294 /// <returns type="Number" integer="true"> 295 /// Top offset for the popup 296 /// </returns> 297 298 var yoffSet; 299 if(Sys.Extended.UI.PopupControlPopupPosition.Top == this._position) { 300 yoffSet = (-1 * this.get_element().offsetHeight) + this._offsetY; 301 } else if (Sys.Extended.UI.PopupControlPopupPosition.Bottom == this._position) { 302 yoffSet = this.get_element().offsetHeight + this._offsetY; 303 } else { 304 yoffSet = this._offsetY; 305 } 306 307 return yoffSet; 308 }, 309 310 get_onShow : function() { 311 /// <value type="String" mayBeNull="true"> 312 /// Generic OnShow Animation's JSON definition 313 /// </value> 314 return this._popupBehavior ? this._popupBehavior.get_onShow() : this._onShowJson; 315 }, 316 set_onShow : function(value) { 317 if (this._popupBehavior) { 318 this._popupBehavior.set_onShow(value); 319 } else { 320 this._onShowJson = value; 321 } 322 this.raisePropertyChanged('onShow'); 323 }, 324 get_onShowBehavior : function() { 325 /// <value type="Sys.Extended.UI.Animation.GenericAnimationBehavior"> 326 /// Generic OnShow Animation's behavior 327 /// </value> 328 return this._popupBehavior ? this._popupBehavior.get_onShowBehavior() : null; 329 }, 330 onShow : function() { 331 /// <summary> 332 /// Play the OnShow animation 333 /// </summary> 334 /// <returns /> 335 if (this._popupBehavior) { 336 this._popupBehavior.onShow(); 337 } 338 }, 339 340 get_onHide : function() { 341 /// <value type="String" mayBeNull="true"> 342 /// Generic OnHide Animation's JSON definition 343 /// </value> 344 return this._popupBehavior ? this._popupBehavior.get_onHide() : this._onHideJson; 345 }, 346 set_onHide : function(value) { 347 if (this._popupBehavior) { 348 this._popupBehavior.set_onHide(value); 349 } else { 350 this._onHideJson = value; 351 } 352 this.raisePropertyChanged('onHide'); 353 }, 354 get_onHideBehavior : function() { 355 /// <value type="Sys.Extended.UI.Animation.GenericAnimationBehavior"> 356 /// Generic OnHide Animation's behavior 357 /// </value> 358 return this._popupBehavior ? this._popupBehavior.get_onHideBehavior() : null; 359 }, 360 onHide : function() { 361 /// <summary> 362 /// Play the OnHide animation 363 /// </summary> 364 /// <returns /> 365 if (this._popupBehavior) { 366 this._popupBehavior.onHide(); 367 } 368 }, 369 370 get_PopupControlID : function() { 371 /// <value type="String"> 372 /// The ID of the control to display 373 /// </value> 374 return this._popupControlID; 375 }, 376 set_PopupControlID : function(value) { 377 if (this._popupControlID != value) { 378 this._popupControlID = value; 379 this.raisePropertyChanged('PopupControlID'); 380 } 381 }, 382 383 get_CommitProperty : function() { 384 /// <value type="String" mayBeNull="true" optional="true"> 385 /// The property on the control being extended that should be set with the result of the popup 386 /// </value> 387 return this._commitProperty; 388 }, 389 set_CommitProperty : function(value) { 390 if (this._commitProperty != value) { 391 this._commitProperty = value; 392 this.raisePropertyChanged('CommitProperty'); 393 } 394 }, 395 396 get_CommitScript : function() { 397 /// <value type="String" mayBeNull="true" optional="true"> 398 /// Additional script to run after setting the result of the popup 399 /// </value> 400 return this._commitScript; 401 }, 402 set_CommitScript : function(value) { 403 if (this._commitScript != value) { 404 this._commitScript = value; 405 this.raisePropertyChanged('CommitScript'); 406 } 407 }, 408 409 get_Position : function() { 410 /// <value type="Sys.Extended.UI.PopupControlPopupPosition"> 411 /// Where the popup should be positioned relative to the target control. (Left, Right, Top, Bottom, Center) 412 /// </value> 413 return this._position; 414 }, 415 set_Position : function(value) { 416 if (this._position != value) { 417 this._position = value; 418 this.raisePropertyChanged('Position'); 419 } 420 }, 421 422 get_ExtenderControlID : function() { 423 /// <value type="String"> 424 /// ID of the extender control 425 /// </value> 426 return this._extenderControlID; 427 }, 428 set_ExtenderControlID : function(value) { 429 if (this._extenderControlID != value) { 430 this._extenderControlID = value; 431 this.raisePropertyChanged('ExtenderControlID'); 432 } 433 }, 434 435 get_OffsetX : function() { 436 /// <value type="Number" integer="true"> 437 /// The number of pixels to horizontally offset the Popup from its default position 438 /// </value> 439 return this._offsetX; 440 }, 441 set_OffsetX : function(value) { 442 if (this._offsetX != value) { 443 this._offsetX = value; 444 this.raisePropertyChanged('OffsetX'); 445 } 446 }, 447 448 get_OffsetY : function() { 449 /// <value type="Number" integer="true"> 450 /// The number of pixels to vertically offset the Popup from its default position 451 /// </value> 452 return this._offsetY; 453 }, 454 set_OffsetY : function(value) { 455 if (this._offsetY != value) { 456 this._offsetY = value; 457 this.raisePropertyChanged('OffsetY'); 458 } 459 }, 460 461 get_PopupVisible : function() { 462 /// <value type="Boolean"> 463 /// Whether the popup control is currently visible 464 /// </value> 465 return this._popupVisible; 466 }, 467 468 add_showing : function(handler) { 469 /// <summary> 470 /// Add an event handler for the showing event 471 /// </summary> 472 /// <param name="handler" type="Function" mayBeNull="false"> 473 /// Event handler 474 /// </param> 475 /// <returns /> 476 477 if (this._popupBehavior) { 478 this._popupBehavior.add_showing(handler); 479 } 480 }, 481 remove_showing : function(handler) { 482 /// <summary> 483 /// Remove an event handler from the showing event 484 /// </summary> 485 /// <param name="handler" type="Function" mayBeNull="false"> 486 /// Event handler 487 /// </param> 488 /// <returns /> 489 490 if (this._popupBehavior) { 491 this._popupBehavior.remove_showing(handler); 492 } 493 }, 494 raiseShowing : function(eventArgs) { 495 /// <summary> 496 /// Raise the showing event 497 /// </summary> 498 /// <param name="eventArgs" type="Sys.CancelEventArgs" mayBeNull="false"> 499 /// Event arguments for the showing event 500 /// </param> 501 /// <returns /> 502 503 if (this._popupBehavior) { 504 this._popupBehavior.raiseShowing(eventArgs); 505 } 506 }, 507 508 add_shown : function(handler) { 509 /// <summary> 510 /// Add an event handler for the shown event 511 /// </summary> 512 /// <param name="handler" type="Function" mayBeNull="false"> 513 /// Event handler 514 /// </param> 515 /// <returns /> 516 517 if (this._popupBehavior) { 518 this._popupBehavior.add_shown(handler); 519 } 520 }, 521 remove_shown : function(handler) { 522 /// <summary> 523 /// Remove an event handler from the shown event 524 /// </summary> 525 /// <param name="handler" type="Function" mayBeNull="false"> 526 /// Event handler 527 /// </param> 528 /// <returns /> 529 530 if (this._popupBehavior) { 531 this._popupBehavior.remove_shown(handler); 532 } 533 }, 534 raiseShown : function(eventArgs) { 535 /// <summary> 536 /// Raise the shown event 537 /// </summary> 538 /// <param name="eventArgs" type="Sys.EventArgs" mayBeNull="false"> 539 /// Event arguments for the shown event 540 /// </param> 541 /// <returns /> 542 543 if (this._popupBehavior) { 544 this._popupBehavior.raiseShown(eventArgs); 545 } 546 }, 547 548 add_hiding : function(handler) { 549 /// <summary> 550 /// Add an event handler for the hiding event 551 /// </summary> 552 /// <param name="handler" type="Function" mayBeNull="false"> 553 /// Event handler 554 /// </param> 555 /// <returns /> 556 557 if (this._popupBehavior) { 558 this._popupBehavior.add_hiding(handler); 559 } 560 }, 561 remove_hiding : function(handler) { 562 /// <summary> 563 /// Remove an event handler from the hiding event 564 /// </summary> 565 /// <param name="handler" type="Function" mayBeNull="false"> 566 /// Event handler 567 /// </param> 568 /// <returns /> 569 570 if (this._popupBehavior) { 571 this._popupBehavior.remove_hiding(handler); 572 } 573 }, 574 raiseHiding : function(eventArgs) { 575 /// <summary> 576 /// Raise the hiding event 577 /// </summary> 578 /// <param name="eventArgs" type="Sys.CancelEventArgs" mayBeNull="false"> 579 /// Event arguments for the hiding event 580 /// </param> 581 /// <returns /> 582 583 if (this._popupBehavior) { 584 this._popupBehavior.raiseHiding(eventArgs); 585 } 586 }, 587 588 add_hidden : function(handler) { 589 /// <summary> 590 /// Add an event handler for the hidden event 591 /// </summary> 592 /// <param name="handler" type="Function" mayBeNull="false"> 593 /// Event handler 594 /// </param> 595 /// <returns /> 596 597 if (this._popupBehavior) { 598 this._popupBehavior.add_hidden(handler); 599 } 600 }, 601 remove_hidden : function(handler) { 602 /// <summary> 603 /// Remove an event handler from the hidden event 604 /// </summary> 605 /// <param name="handler" type="Function" mayBeNull="false"> 606 /// Event handler 607 /// </param> 608 /// <returns /> 609 610 if (this._popupBehavior) { 611 this._popupBehavior.remove_hidden(handler); 612 } 613 }, 614 raiseHidden : function(eventArgs) { 615 /// <summary> 616 /// Raise the hidden event 617 /// </summary> 618 /// <param name="eventArgs" type="Sys.EventArgs" mayBeNull="false"> 619 /// Event arguments for the hidden event 620 /// </param> 621 /// <returns /> 622 623 if (this._popupBehavior) { 624 this._popupBehavior.raiseHidden(eventArgs); 625 } 626 } 627}; 628 Sys.Extended.UI.PopupControlBehavior.registerClass('Sys.Extended.UI.PopupControlBehavior', Sys.Extended.UI.DynamicPopulateBehaviorBase); 629Sys.registerComponent(Sys.Extended.UI.PopupControlBehavior, { name: "popupBehavior" }); 630 631Sys.Extended.UI.PopupControlBehavior.__VisiblePopup = null; 632 633 634Sys.Extended.UI.PopupControlPopupPosition = function() { 635 /// <summary> 636 /// Position of the popup relative to the target control 637 /// </summary> 638 /// <field name="Center" type="Number" integer="true" /> 639 /// <field name="Top" type="Number" integer="true" /> 640 /// <field name="Left" type="Number" integer="true" /> 641 /// <field name="Bottom" type="Number" integer="true" /> 642 /// <field name="Right" type="Number" integer="true" />
643 throw Error.invalidOperation(); 644}; 645 Sys.Extended.UI.PopupControlPopupPosition.prototype = { 646 Center : 0, 647 Top : 1, 648 Left : 2, 649 Bottom : 3, 650 Right : 4 651}; 652 Sys.Extended.UI.PopupControlPopupPosition.registerEnum("Sys.Extended.UI.PopupControlPopupPosition", false); 653 654} // execute 655 656if (window.Sys && Sys.loader) { 657 Sys.loader.registerScript(scriptName, ["ExtendedDynamicPopulate", "ExtendedPopup", "ExtendedAnimationBehavior"], execute); 658} 659else { 660 execute(); 661} 662 663})();
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.