1// Name: HoverMenu.HoverMenuBehavior.debug.js 2// Assembly: AjaxControlToolkit 3// Version: 3.5.7.1213 4// FileVersion: 3.5.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="../HoverExtender/HoverBehavior.js" /> 14/// <reference path="../Animation/Animations.js" /> 15/// <reference path="../Animation/AnimationBehavior.js" /> 16/// <reference path="../PopupExtender/PopupBehavior.js" /> 17 18(function() { 19var scriptName = "ExtendedHoverMenu"; 20 21function execute() { 22 23Type.registerNamespace('Sys.Extended.UI'); 24 25Sys.Extended.UI.HoverMenuBehavior = function(element) { 26 /// <summary> 27 /// The HoverMenuBehavior is used to display a popup whenever the target is hovered over 28 /// </summary> 29 /// <param name="element" type="Sys.UI.DomElement" domElement="true"> 30 /// DOM element the behavior is associated with 31 /// </param> 32 Sys.Extended.UI.HoverMenuBehavior.initializeBase(this, [element]); 33 34 this._hoverBehavior = null; 35 this._popupBehavior = null; 36 37 this._mouseEnterHandler = null; 38 this._mouseLeaveHandler = null; 39 this._unhoverHandler = null; 40 this._hoverHandler = null; 41 42 this._inHover = null; 43 this._oldClass = null; 44 this._popupElement = null; 45 this._onShowJson = null; 46 this._onHideJson = null; 47 48 this._popupElement = null; 49 this._hoverCssClass = null; 50 this._offsetX = 0; 51 this._offsetY = 0; 52 this._popDelay = 100; 53 this._hoverDelay = 0; 54 this._popupPosition = null; 55} 56Sys.Extended.UI.HoverMenuBehavior.prototype = { 57 initialize : function() { 58 /// <summary> 59 /// Initialize the behavior 60 /// </summary> 61 Sys.Extended.UI.HoverMenuBehavior.callBaseMethod(this, 'initialize'); 62 63 this._hoverHandler = Function.createDelegate(this, this._onHover); 64 this._unhoverHandler = Function.createDelegate(this, this._onUnhover); 65 this._mouseEnterHandler = Function.createDelegate(this, this._onmouseover); 66 this._mouseLeaveHandler = Function.createDelegate(this, this._onmouseout); 67 68 var e = this.get_element(); 69 $addHandler(e, "mouseover", this._mouseEnterHandler); 70 $addHandler(e, "mouseout", this._mouseLeaveHandler); 71 72 if (this._popupElement) { 73 this._popupBehavior = $create(Sys.Extended.UI.PopupBehavior, { "id":this.get_id()+"_PopupBehavior" }, null, null, this._popupElement); 74 if (this._popupPosition) { 75 this._popupBehavior.set_positioningMode(Sys.Extended.UI.HoverMenuPopupPosition.Absolute); 76 } else { 77 this._popupBehavior.set_positioningMode(Sys.Extended.UI.HoverMenuPopupPosition.Center); 78 } 79 80 if (this._onShowJson) { 81 this._popupBehavior.set_onShow(this._onShowJson); 82 } 83 if (this._onHideJson) { 84 this._popupBehavior.set_onHide(this._onHideJson); 85 } 86 87 this._hoverBehavior = $create(Sys.Extended.UI.HoverBehavior, { "id":this.get_id()+"_HoverBehavior", "hoverDelay":this._hoverDelay, "unhoverDelay":this._popDelay, "hoverElement":this._popupElement }, null, null, e); 88 this._hoverBehavior.add_hover(this._hoverHandler); 89 this._hoverBehavior.add_unhover(this._unhoverHandler); 90 } 91 }, 92 93 dispose : function() { 94 /// <summary> 95 /// Dispose the behavior 96 /// </summary> 97 98 this._onShowJson = null; 99 this._onHideJson = null; 100 if (this._popupBehavior) { 101 this._popupBehavior.dispose(); 102 this._popupBehavior = null; 103 } 104 if (this._popupElement) { 105 this._popupElement = null; 106 } 107 if (this._mouseEnterHandler) {
108 $removeHandler(this.get_element(), "mouseover", this._mouseEnterHandler); 109 } 110 if (this._mouseLeaveHandler) { 111 $removeHandler(this.get_element(), "mouseout", this._mouseLeaveHandler); 112 } 113 if (this._hoverBehavior) { 114 if (this._hoverHandler) { 115 this._hoverBehavior.remove_hover(this._hoverHandler); 116 this._hoverHandler = null; 117 } 118 if (this._unhoverHandler) { 119 this._hoverBehavior.remove_hover(this._unhoverHandler); 120 this._unhoverHandler = null; 121 } 122 this._hoverBehavior.dispose(); 123 this._hoverBehavior = null; 124 } 125 Sys.Extended.UI.HoverMenuBehavior.callBaseMethod(this, 'dispose'); 126 }, 127 128 _getLeftOffset : function() { 129 /// <summary> 130 /// Get the left offset of the popup 131 /// </summary> 132 /// <returns type="Number" integer="true"> 133 /// Left offset of the popup (in pixels) 134 /// </returns> 135 136 var defaultLeft = $common.getLocation(this.get_element()).x; 137 var offsetLeft = $common.getLocation(this.get_popupElement().offsetParent).x; 138 var delta = 0; 139 140 switch(this._popupPosition) { 141 case Sys.Extended.UI.HoverMenuPopupPosition.Left: 142 delta = (-1 * this._popupElement.offsetWidth); 143 break; 144 case Sys.Extended.UI.HoverMenuPopupPosition.Right: 145 delta = this.get_element().offsetWidth; 146 break; 147 } 148 return delta + defaultLeft - offsetLeft + this._offsetX; 149 150 }, 151 152 _getTopOffset : function() { 153 /// <summary> 154 /// Get the top offset of the popup 155 /// </summary> 156 /// <returns type="Number" integer="true"> 157 /// Left offset of the popup (in pixels) 158 /// </returns> 159 160 var defaultTop = $common.getLocation(this.get_element()).y; 161 var offsetTop = $common.getLocation(this.get_popupElement().offsetParent).y; 162 var delta = 0; 163 164 switch(this._popupPosition) { 165 case Sys.Extended.UI.HoverMenuPopupPosition.Top: 166 delta = (-1 * this._popupElement.offsetHeight); 167 break; 168 case Sys.Extended.UI.HoverMenuPopupPosition.Bottom: 169 delta = this.get_element().offsetHeight; 170 break; 171 } 172 return defaultTop - offsetTop + delta + this._offsetY; 173 }, 174 175 _onHover : function() { 176 /// <summary> 177 /// Display the popup when the target is hovered over 178 /// </summary> 179 180 if (this._inHover) return; 181 182 var eventArgs = new Sys.CancelEventArgs(); 183 this.raiseShowing(eventArgs); 184 if (eventArgs.get_cancel()) { 185 return; 186 } 187 188 this._inHover = true; 189 this.populate(); 190 191 this._popupBehavior.show(); 192 if ($common.getCurrentStyle(this._popupElement, 'display') == 'none') { 193 this._popupElement.style.display = 'block'; 194 } 195 this._popupBehavior.set_x(this._getLeftOffset()); 196 this._popupBehavior.set_y(this._getTopOffset()); 197 198 this.raiseShown(Sys.EventArgs.Empty); 199 }, 200 201 _onUnhover : function() { 202 /// <summary> 203 /// Hide the popup when the target is no longer hovered 204 /// </summary> 205 206 var eventArgs = new Sys.CancelEventArgs(); 207 this.raiseHiding(eventArgs); 208 if (eventArgs.get_cancel()) { 209 return; 210 } 211 212 this._inHover = false; 213 this._resetCssClass(); 214 this._popupBehavior.hide(); 215 216 this.raiseHidden(Sys.EventArgs.Empty); 217 }, 218 219 _onmouseover : function() { 220 /// <summary> 221 /// Handler to change the CSS class when hovered over 222 /// </summary> 223 224 var e = this.get_element(); 225 if (this._hoverCssClass && e.className != this._hoverCssClass) { 226 this._oldClass = e.className; 227 e.className = this._hoverCssClass; 228 } 229 }, 230 231 _onmouseout : function() { 232 /// <summary> 233 /// Handler to reset the CSS class when no longer hovering 234 /// </summary> 235 this._resetCssClass(); 236 }, 237 238 _resetCssClass : function() { 239 /// <summary> 240 /// Reset the CSS class if we changed it while hovering 241 /// </summary> 242
243 var e = this.get_element(); 244 if (!this._inHover && this._hoverCssClass && e.className == this._hoverCssClass) { 245 e.className = this._oldClass; 246 } 247 }, 248 249 get_onShow : function() { 250 /// <value type="String" mayBeNull="true"> 251 /// Generic OnShow Animation's JSON definition 252 /// </value> 253 return this._popupBehavior ? this._popupBehavior.get_onShow() : this._onShowJson; 254 }, 255 set_onShow : function(value) { 256 if (this._popupBehavior) { 257 this._popupBehavior.set_onShow(value) 258 } else { 259 this._onShowJson = value; 260 } 261 this.raisePropertyChanged('onShow'); 262 }, 263 get_onShowBehavior : function() { 264 /// <value type="Sys.Extended.UI.Animation.GenericAnimationBehavior"> 265 /// Generic OnShow Animation's behavior 266 /// </value> 267 return this._popupBehavior ? this._popupBehavior.get_onShowBehavior() : null; 268 }, 269 onShow : function() { 270 /// <summary> 271 /// Play the OnShow animation 272 /// </summary> 273 /// <returns /> 274 if (this._popupBehavior) { 275 this._popupBehavior.onShow(); 276 } 277 }, 278 279 get_onHide : function() { 280 /// <value type="String" mayBeNull="true"> 281 /// Generic OnHide Animation's JSON definition 282 /// </value> 283 return this._popupBehavior ? this._popupBehavior.get_onHide() : this._onHideJson; 284 }, 285 set_onHide : function(value) { 286 if (this._popupBehavior) { 287 this._popupBehavior.set_onHide(value) 288 } else { 289 this._onHideJson = value; 290 } 291 this.raisePropertyChanged('onHide'); 292 }, 293 get_onHideBehavior : function() { 294 /// <value type="Sys.Extended.UI.Animation.GenericAnimationBehavior"> 295 /// Generic OnHide Animation's behavior 296 /// </value> 297 return this._popupBehavior ? this._popupBehavior.get_onHideBehavior() : null; 298 }, 299 onHide : function() { 300 /// <summary> 301 /// Play the OnHide animation 302 /// </summary> 303 /// <returns /> 304 if (this._popupBehavior) { 305 this._popupBehavior.onHide(); 306 } 307 }, 308 309 get_popupElement : function() { 310 /// <value type="Sys.UI.DomElement" domElement="true"> 311 /// Popup that is displayed when hovering 312 /// </value> 313 return this._popupElement; 314 }, 315 set_popupElement : function(value) { 316 if (this._popupElement != value) { 317 this._popupElement = value; 318 if (this.get_isInitialized() && this._hoverBehavior) { 319 this._hoverBehavior.set_hoverElement(this._popupElement); 320 } 321 this.raisePropertyChanged('popupElement'); 322 } 323 }, 324 325 get_HoverCssClass : function() { 326 /// <value type="String"> 327 /// CSS class used when hovering 328 /// </value> 329 return this._hoverCssClass; 330 }, 331 set_HoverCssClass : function(value) { 332 if (this._hoverCssClass != value) { 333 this._hoverCssClass = value; 334 this.raisePropertyChanged('HoverCssClass'); 335 } 336 }, 337 338 get_OffsetX : function() { 339 /// <value type="Number" integer="true"> 340 /// The number of pixels to offset the popup from it's default position horizontally 341 /// </value> 342 return this._offsetX; 343 }, 344 set_OffsetX : function(value) { 345 if (this._offsetX != value) { 346 this._offsetX = value; 347 this.raisePropertyChanged('OffsetX'); 348 } 349 }, 350 351 get_OffsetY : function() { 352 /// <value type="Number" integer="true"> 353 /// The number of pixels to offset the popup from it's default position vertically 354 /// </value> 355 return this._offsetY; 356 }, 357 set_OffsetY : function(value) { 358 if (this._offsetY != value) { 359 this._offsetY = value; 360 this.raisePropertyChanged('OffsetY'); 361 } 362 }, 363 364 get_PopupPosition : function() { 365 /// <value type="Sys.Extended.UI.HoverMenuPopupPosition"> 366 /// Where the popup should be positioned relative to the target control. 367 /// Can be Left (Default), Right, Top, Bottom, Center.
368 /// </value> 369 return this._popupPosition; 370 }, 371 set_PopupPosition : function(value) { 372 if (this._popupPosition != value) { 373 this._popupPosition = value; 374 this.raisePropertyChanged('PopupPosition'); 375 } 376 }, 377 378 get_PopDelay : function() { 379 /// <value type="Number"> 380 /// The time delay from when the mouse enters the target to when the popup is shown, in milliseconds. Default is 100. 381 /// </value> 382 return this._popDelay; 383 }, 384 set_PopDelay : function(value) { 385 if (this._popDelay != value) { 386 this._popDelay = value; 387 this.raisePropertyChanged('PopDelay'); 388 } 389 }, 390 391 get_HoverDelay: function() { 392 /// <value type="Number"> 393 /// The time delay after the mouse enters the target and before the popup is shown, in milliseconds. Default is 0. 394 /// </value> 395 return this._hoverDelay; 396 }, 397 set_HoverDelay: function(value) { 398 if (this._hoverDelay != value) { 399 this._hoverDelay = value; 400 this.raisePropertyChanged('HoverDelay'); 401 } 402 }, 403 404 add_showing : function(handler) { 405 /// <summary> 406 /// Add an event handler for the showing event 407 /// </summary> 408 /// <param name="handler" type="Function" mayBeNull="false"> 409 /// Event handler 410 /// </param> 411 /// <returns /> 412 this.get_events().addHandler('showing', handler); 413 }, 414 remove_showing : function(handler) { 415 /// <summary> 416 /// Remove an event handler from the showing event 417 /// </summary> 418 /// <param name="handler" type="Function" mayBeNull="false"> 419 /// Event handler 420 /// </param> 421 /// <returns /> 422 this.get_events().removeHandler('showing', handler); 423 }, 424 raiseShowing : function(eventArgs) { 425 /// <summary> 426 /// Raise the showing event 427 /// </summary> 428 /// <param name="eventArgs" type="Sys.CancelEventArgs" mayBeNull="false"> 429 /// Event arguments for the showing event 430 /// </param> 431 /// <returns /> 432 433 var handler = this.get_events().getHandler('showing'); 434 if (handler) { 435 handler(this, eventArgs); 436 } 437 }, 438 439 add_shown : function(handler) { 440 /// <summary> 441 /// Add an event handler for the shown event 442 /// </summary> 443 /// <param name="handler" type="Function" mayBeNull="false"> 444 /// Event handler 445 /// </param> 446 /// <returns /> 447 this.get_events().addHandler('shown', handler); 448 }, 449 remove_shown : function(handler) { 450 /// <summary> 451 /// Remove an event handler from the shown event 452 /// </summary> 453 /// <param name="handler" type="Function" mayBeNull="false"> 454 /// Event handler 455 /// </param> 456 /// <returns /> 457 this.get_events().removeHandler('shown', handler); 458 }, 459 raiseShown : function(eventArgs) { 460 /// <summary> 461 /// Raise the shown event 462 /// </summary> 463 /// <param name="eventArgs" type="Sys.EventArgs" mayBeNull="false"> 464 /// Event arguments for the shown event 465 /// </param> 466 /// <returns /> 467 468 var handler = this.get_events().getHandler('shown'); 469 if (handler) { 470 handler(this, eventArgs); 471 } 472 }, 473 474 add_hiding : function(handler) { 475 /// <summary> 476 /// Add an event handler for the hiding event 477 /// </summary> 478 /// <param name="handler" type="Function" mayBeNull="false"> 479 /// Event handler 480 /// </param> 481 /// <returns /> 482 this.get_events().addHandler('hiding', handler); 483 }, 484 remove_hiding : function(handler) { 485 /// <summary> 486 /// Remove an event handler from the hiding event 487 /// </summary> 488 /// <param name="handler" type="Function" mayBeNull="false"> 489 /// Event handler 490 /// </param> 491 /// <returns /> 492 this.get_events().removeHandler('hiding', handler); 493 }, 494 raiseHiding : function(eventArgs) { 495 /// <summary> 496 /// Raise the hiding event 497 /// </summary> 498 /// <param name="eventArgs" type="Sys.CancelEventArgs" mayBeNull="false"> 499 /// Event arguments for the hiding event 500 /// </param> 501 /// <returns /> 502 503 var handler = this.get_events().getHandler('hiding'); 504 if (handler) { 505 handler(this, eventArgs); 506 } 507 }, 508 509 add_hidden : function(handler) { 510 /// <summary> 511 /// Add an event handler for the hidden event 512 /// </summary> 513 /// <param name="handler" type="Function" mayBeNull="false"> 514 /// Event handler 515 /// </param> 516 /// <returns /> 517 this.get_events().addHandler('hidden', handler); 518 }, 519 remove_hidden : function(handler) { 520 /// <summary> 521 /// Remove an event handler from the hidden event 522 /// </summary> 523 /// <param name="handler" type="Function" mayBeNull="false"> 524 /// Event handler 525 /// </param> 526 /// <returns /> 527 this.get_events().removeHandler('hidden', handler); 528 }, 529 raiseHidden : function(eventArgs) { 530 /// <summary> 531 /// Raise the hidden event 532 /// </summary> 533 /// <param name="eventArgs" type="Sys.EventArgs" mayBeNull="false"> 534 /// Event arguments for the hidden event 535 /// </param> 536 /// <returns /> 537 538 var handler = this.get_events().getHandler('hidden'); 539 if (handler) { 540 handler(this, eventArgs); 541 } 542 } 543} 544Sys.Extended.UI.HoverMenuBehavior.registerClass('Sys.Extended.UI.HoverMenuBehavior', Sys.Extended.UI.DynamicPopulateBehaviorBase); 545Sys.registerComponent(Sys.Extended.UI.HoverMenuBehavior, { name: "hoverMenu" }); 546 547Sys.Extended.UI.HoverMenuPopupPosition = function() { 548 /// <summary> 549 /// Where the popup should be positioned relative to the target control 550 /// </summary> 551 /// <field name="Center" type="Number" integer="true" /> 552 /// <field name="Top" type="Number" integer="true" /> 553 /// <field name="Left" type="Number" integer="true" /> 554 /// <field name="Bottom" type="Number" integer="true" /> 555 /// <field name="Right" type="Number" integer="true" />
556 throw Error.invalidOperation(); 557} 558Sys.Extended.UI.HoverMenuPopupPosition.prototype = { 559 Center: 0, 560 Top: 1, 561 Left: 2, 562 Bottom: 3, 563 Right: 4 564} 565Sys.Extended.UI.HoverMenuPopupPosition.registerEnum('Sys.Extended.UI.HoverMenuPopupPosition'); 566 567} // execute 568 569if (window.Sys && Sys.loader) { 570 Sys.loader.registerScript(scriptName, ["ExtendedDynamicPopulate", "ExtendedHover", "ExtendedAnimationBehavior", "ExtendedPopup"], execute); 571} 572else { 573 execute(); 574} 575 576})();
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.