1// Name: DropShadow.debug.js 2// Assembly: AjaxControlToolkit 3// Version: 17.1.1.0 4// FileVersion: 17.1.1.0 5Type.registerNamespace('Sys.Extended.UI'); 6 7Sys.Extended.UI.DropShadowBehavior = function(element) { 8 // The DropShadowBehavior is used to attach a drop shadow to the element 9 // "element" - DOM Element the behavior is associated with 10 Sys.Extended.UI.DropShadowBehavior.initializeBase(this, [element]); 11 12 // our property values 13 this._opacity = 1.0; 14 this._width = 5; 15 16 // the div we create for the shadow. 17 this._shadowDiv = null; 18 19 // our timer for tracking position 20 this._trackPosition = null; 21 this._trackPositionDelay = 50; 22 this._timer = null; 23 this._tickHandler = null; 24 this._roundedBehavior = null; 25 this._shadowRoundedBehavior = null; 26 27 this._rounded = false; 28 this._radius = 5; 29 30 // our cache of our last size and position for tracking 31 this._lastX = null; 32 this._lastY = null; 33 this._lastW = null; 34 this._lastH = null; 35} 36 37Sys.Extended.UI.DropShadowBehavior.prototype = { 38 39 initialize: function() { 40 Sys.Extended.UI.DropShadowBehavior.callBaseMethod(this, 'initialize'); 41 42 e = this.get_element(); 43 44 // flip the styles position to relative so that we z-order properly. 45 if($common.getCurrentStyle(e, 'position', e.style.position) != "absolute") 46 e.style.position = "relative"; 47 48 // set up our initial state 49 if(this._rounded) 50 this.setupRounded(); 51 52 if(this._trackPosition) 53 this.startTimer(); 54 55 this.setShadow(); 56 }, 57 58 dispose: function() { 59 this.stopTimer(); 60 this.disposeShadowDiv(); 61 62 Sys.Extended.UI.DropShadowBehavior.callBaseMethod(this, 'dispose'); 63 }, 64 65 buildShadowDiv: function() { 66 // Create the div that we'll use as the shadow 67 e = this.get_element(); 68 69 if(!this.get_isInitialized() || !e || !this._width) 70 return; 71 72 // check if browser does not support css3 73 if(e.style.boxShadow == undefined && e.style.MozBoxShadow == undefined && e.style.WebkitBoxShadow == undefined) { 74 var div = document.createElement("DIV"); 75 76 div.style.backgroundColor = "black"; 77 div.style.position = "absolute"; 78 79 if(e.id) 80 div.id = e.id + "_DropShadow"; 81 82 // initialize a control around it, and 83 // set up the opacity behavior and rounding 84 this._shadowDiv = div; 85 86 e.parentNode.appendChild(div); 87 88 if(this._rounded) { 89 this._shadowDiv.style.height = Math.max(0, e.offsetHeight - (2 * this._radius)) + "px"; 90 91 if(!this._shadowRoundedBehavior) 92 this._shadowRoundedBehavior = $create(Sys.Extended.UI.RoundedCornersBehavior, { "Radius": this._radius }, null, null, this._shadowDiv); 93 else 94 this._shadowRoundedBehavior.set_radius(this._radius); 95 } else if(this._shadowRoundedBehavior) { 96 this._shadowRoundedBehavior.set_radius(0); 97 } 98 99 if(this._opacity != 1.0) 100 this.setupOpacity(); 101 102 this.setShadow(false, true); 103 this.updateZIndex(); 104 } 105 }, 106 107 disposeShadowDiv: function() { 108 // Dispose of the div we use as the shadow 109 if(this._shadowDiv) { 110 // on page teardown (or in an update panel, this may already 111 // be gone) 112 if(this._shadowDiv.parentNode) 113 this._shadowDiv.parentNode.removeChild(this._shadowDiv); 114 115 this._shadowDiv = null; 116 } 117 118 if(this._shadowRoundedBehavior) { 119 this._shadowRoundedBehavior.dispose(); 120 this._shadowRoundedBehavior = null; 121 } 122 }, 123 124 onTimerTick: function() { 125 // Timer's tick handler that is used to position the shadow when its target moves 126 this.setShadow(); 127 }, 128 129 startTimer: function() { 130 // Start the timer (and hence start tracking the bounds of the target element) 131 if(!this._timer) { 132 if(!this._tickHandler) 133 this._tickHandler = Function.createDelegate(this, this.onTimerTick); 134 135 this._timer = new Sys.Timer(); 136 this._timer.set_interval(this._trackPositionDelay); 137 this._timer.add_tick(this._tickHandler); 138 this._timer.set_enabled(true); 139 } 140 }, 141 142 stopTimer: function() { 143 // Stop the timer (and hence stop tracking the bounds of the target element) 144 145 // on stop, just clean the thing up completely 146 if(this._timer) { 147 this._timer.remove_tick(this._tickHandler); 148 this._timer.set_enabled(false); 149 this._timer.dispose(); 150 this._timer = null; 151 } 152 }, 153 154 ///<summary> 155 /// Draws shadow around the control. 156 ///</summary> 157 /// <remarks> 158 /// This function does most part of work when positioning and sizing the shadow. 159 /// It caches values to avoid extra work. 160 /// It's called on a timer so we need to keep its weight light. 161 /// </remarks> 162 /// <param name="force" type="Boolean">Whether to force the bounds change.</param> 163 /// <param name="norecurse" type="Boolean">Whether to recurse if we need to recreate the shadow div</param> 164 /// <member name="cM:AjaxControlToolkit.DropShadowExtender.setShadow" /> 165 setShadow: function(force, norecurse) { 166 // This function does the heavy lifting of positioning and sizing the shadow. 167 // It caches values to avoid extra work - it's called on a timer so we need to 168 // keep it light weight. 169 // "force" - whether to force the bounds change 170 // "norecurse" - whether to recurse if we need to recreate the shadow div 171
172 e = this.get_element(); 173 174 if(!this.get_isInitialized() || !e || (!this._width && !force)) 175 return; 176 177 // execute if browser does not support css3 178 if(e.style.boxShadow == undefined && e.style.MozBoxShadow == undefined && e.style.WebkitBoxShadow == undefined) { 179 var existingShadow = this._shadowDiv; 180 if(!existingShadow) 181 this.buildShadowDiv(); 182 183 var location = { x: e.offsetLeft, y: e.offsetTop }; 184 185 if(force || this._lastX != location.x || this._lastY != location.y || !existingShadow) { 186 this._lastX = location.x; 187 this._lastY = location.y; 188 189 var w = this.get_width(); 190 191 location.x += w; 192 location.y += w; 193 194 $common.setLocation(this._shadowDiv, location); 195 } 196 197 var h = e.offsetHeight, 198 w = e.offsetWidth; 199 200 if(force || h != this._lastH || w != this._lastW || !existingShadow) { 201 this._lastW = w; 202 this._lastH = h; 203 204 if(!this._rounded || !existingShadow || norecurse) { 205 this._shadowDiv.style.width = w + "px"; 206 this._shadowDiv.style.height = h + "px"; 207 } else { 208 // recurse if we need to redo the div 209 this.disposeShadowDiv(); 210 this.setShadow(); 211 } 212 } 213 214 if(this._shadowDiv) 215 this._shadowDiv.style.visibility = $common.getCurrentStyle(e, 'visibility'); 216 } else { // create dropshadow effect on div if browser supports css3 217 218 var boxShadowVals; 219 220 //To display effect of opacity set different color 221 // on the basis of selected % of opacity 222 if(this._opacity == ".25") 223 boxShadowVals = this._width + "px " + this._width + "px " + this._width + "px " + "#D3D3D3"; 224 else if(this._opacity == ".5") 225 boxShadowVals = this._width + "px " + this._width + "px " + this._width + "px " + "#778899"; 226 else if(this._opacity == ".75") 227 boxShadowVals = this._width + "px " + this._width + "px " + this._width + "px " + "#808080"; 228 else 229 boxShadowVals = this._width + "px " + this._width + "px " + this._width + "px " + "#000"; 230 231 // this works in IE9 and Chrome latest versions 232 if(e.style.boxShadow != undefined) 233 e.style.boxShadow = boxShadowVals; 234 else if(e.style.MozBoxShadow != undefined) // this works for Mozila Firefox 235 e.style.MozBoxShadow = boxShadowVals; // this works for Chrome older version, Safari 236 else if(e.style.WebkitBoxShadow != undefined) 237 e.style.WebkitBoxShadow = boxShadowVals; 238 } 239 }, 240 241 setupOpacity: function() { 242 // Set the opacity of the shadow div 243 if(this.get_isInitialized() && this._shadowDiv) 244 $common.setElementOpacity(this._shadowDiv, this._opacity); 245 246 }, 247 248 setupRounded: function() { 249 // Demand create and initialize the RoundedCornersBehavior 250 if(!this._roundedBehavior && this._rounded) 251 this._roundedBehavior = $create(Sys.Extended.UI.RoundedCornersBehavior, null, null, null, this.get_element()); 252 253 if(this._roundedBehavior) 254 this._roundedBehavior.set_radius(this._rounded ? this._radius : 0); 255 }, 256 257 updateZIndex: function() { 258 // Update the z-Index so the shadow div remains behind the target element 259 if(!this._shadowDiv) 260 return; 261 262 var e = this.get_element(), 263 targetZIndex = e.style.zIndex, 264 shadowZIndex = this._shadowDiv.style.zIndex; 265 266 if(shadowZIndex && targetZIndex && targetZIndex > shadowZIndex) { 267 return; 268 } else { 269 targetZIndex = Math.max(2, targetZIndex); 270 shadowZIndex = targetZIndex - 1; 271 } 272 273 e.style.zIndex = targetZIndex; 274 this._shadowDiv.style.zIndex = shadowZIndex; 275 }, 276 277 updateRoundedCorners: function() { 278 // Update the RoundedCorndersBehavior and recreate the shadow div so its corners are rounded as well 279 if(this.get_isInitialized()) { 280 this.setupRounded(); 281 this.disposeShadowDiv(); 282 this.setShadow(); 283 } 284 }, 285 286 /// <summary> 287 /// A number that represents the opacity of the drop shadow from 0 (fully transparent) to 1.0 (fully opaque). 288 /// </summary> 289 /// <remarks> 290 /// The default is .5. 291 /// </remarks> 292 /// <getter>get_opacity</getter> 293 /// <setter>set_opacity</setter> 294 /// <member name="cP:AjaxControlToolkit.DropShadowExtender.opacity" /> 295 get_opacity: function() { 296 return this._opacity; 297 }, 298 set_opacity: function(value) { 299 if(this._opacity != value) { 300 this._opacity = value; 301 302 this.setShadow(); 303 this.setupOpacity(); 304 305 this.raisePropertyChanged('opacity'); 306 } 307 }, 308 309 get_Opacity: function() { 310 Sys.Extended.Deprecated("get_Opacity", "get_opacity"); 311 return this.get_opacity(); 312 }, 313 set_Opacity: function(value) {
314 Sys.Extended.Deprecated("set_Opacity", "set_opacity"); 315 this.set_opacity(value); 316 }, 317 318 /// <summary> 319 /// A Boolean value that specifies whether or not corners of the target and drop shadow should be rounded. 320 /// </summary> 321 /// <getter>get_rounded</getter> 322 /// <setter>set_rounded</setter> 323 /// <member name="cP:AjaxControlToolkit.DropShadowExtender.rounded" /> 324 get_rounded: function() { 325 return this._rounded; 326 }, 327 set_rounded: function(value) { 328 if(value != this._rounded) { 329 this._rounded = value; 330 331 this.updateRoundedCorners(); 332 this.raisePropertyChanged('rounded'); 333 } 334 }, 335 336 get_Rounded: function() { 337 Sys.Extended.Deprecated("get_Rounded", "get_rounded"); 338 return this.get_rounded(); 339 }, 340 set_Rounded: function(value) { 341 Sys.Extended.Deprecated("set_Rounded", "set_rounded"); 342 this.set_rounded(value); 343 }, 344 345 /// <summary> 346 /// An integer that specifies the radius of rounded corners in pixels. 347 /// </summary> 348 /// <getter>get_radius</getter> 349 /// <setter>set_radius</setter> 350 /// <member name="cP:AjaxControlToolkit.DropShadowExtender.radius" /> 351 get_radius: function() { 352 return this._radius; 353 }, 354 set_radius: function(value) { 355 if(value != this._radius) { 356 this._radius = value; 357 358 this.updateRoundedCorners(); 359 this.raisePropertyChanged('radius'); 360 } 361 }, 362 363 get_Radius: function() { 364 Sys.Extended.Deprecated("get_Radius", "get_radius"); 365 return this.get_radius(); 366 }, 367 set_Radius: function(value) { 368 Sys.Extended.Deprecated("set_Radius", "set_radius"); 369 this.set_radius(value); 370 }, 371 372 /// <summary> 373 /// An integer that specifies the drop shadow width in pixels. 374 /// </summary> 375 /// <remarks> 376 /// The default is 5. 377 /// </remarks> 378 /// <getter>get_width</getter> 379 /// <setter>set_width</setter> 380 /// <member name="cP:AjaxControlToolkit.DropShadowExtender.width" /> 381 get_width: function() { 382 return this._width; 383 }, 384 set_width: function(value) { 385 if(value != this._width) { 386 this._width = value; 387 388 if(this._shadowDiv) 389 $common.setVisible(this._shadowDiv, value > 0); 390 391 this.setShadow(true); 392 this.raisePropertyChanged('width'); 393 } 394 }, 395 396 get_Width: function() { 397 Sys.Extended.Deprecated("get_Width", "get_width"); 398 return this.get_width(); 399 }, 400 set_Width: function(value) { 401 Sys.Extended.Deprecated("set_Width", "set_width"); 402 this.set_width(value); 403 }, 404 405 /// <summary> 406 /// A number that specifies the length of the timer interval that is used when tracking the targer position. 407 /// </summary> 408 /// <getter>get_trackPositionDelay</getter> 409 /// <setter>set_trackPositionDelay</setter> 410 /// <member name="cP:AjaxControlToolkit.DropShadowExtender.trackPositionDelay" /> 411 get_trackPositionDelay: function() { 412 return this._trackPositionDelay; 413 }, 414 set_trackPositionDelay: function(value) { 415 if(value != this._trackPositionDelay) { 416 this._trackPositionDelay = value; 417 418 if(!e) 419 e = this.get_element(); 420 421 // execute if browser does not support css3 422 if(e.style.boxShadow == undefined && e.style.MozBoxShadow == undefined && e.style.WebkitBoxShadow == undefined) { 423 if(this._trackPosition) { 424 this.stopTimer(); 425 this.startTimer(); 426 } 427 428 this.raisePropertyChanged('trackPositionDelay'); 429 } 430 } 431 }, 432 433 get_TrackPositionDelay: function() { 434 Sys.Extended.Deprecated("get_TrackPositionDelay", "get_trackPositionDelay"); 435 return this.get_trackPositionDelay(); 436 }, 437 set_TrackPositionDelay: function(value) { 438 Sys.Extended.Deprecated("set_TrackPositionDelay", "set_trackPositionDelay"); 439 this.set_trackPositionDelay(value); 440 }, 441 442 /// <summary> 443 /// A Boolean value that specifies whether the drop shadow should track the position of the panel to which it is attached.
444 /// </summary> 445 /// <remarks> 446 /// Set this property to true if the panel is absolutely positioned or if it might move at runtime. The default is false. 447 /// </remarks> 448 /// <getter>get_trackPosition</getter> 449 /// <setter>set_trackPosition</setter> 450 /// <member name="cP:AjaxControlToolkit.DropShadowExtender.trackPosition" /> 451 get_trackPosition: function() { 452 // Whether the drop shadow should track the position of the panel it is attached to. 453 // Use this if the panel is absolutely positioned or will otherwise move. 454 return this._trackPosition; 455 }, 456 set_trackPosition: function(value) { 457 if(value != this._trackPosition) { 458 this._trackPosition = value; 459 460 if(!e) 461 e = this.get_element(); 462 463 // execute if browser does not support css3 464 if(e.style.boxShadow == undefined && e.style.MozBoxShadow == undefined && e.style.WebkitBoxShadow == undefined) { 465 if(this.get_element()) { 466 if(value) 467 this.startTimer(); 468 else 469 this.stopTimer(); 470 } 471 472 this.raisePropertyChanged('trackPosition'); 473 } 474 } 475 }, 476 477 get_TrackPosition: function() { 478 Sys.Extended.Deprecated("get_TrackPosition", "get_trackPosition"); 479 return this.get_trackPosition(); 480 }, 481 set_TrackPosition: function(value) { 482 Sys.Extended.Deprecated("set_TrackPosition", "set_trackPosition"); 483 this.set_trackPosition(value); 484 } 485} 486 487Sys.Extended.UI.DropShadowBehavior.registerClass('Sys.Extended.UI.DropShadowBehavior', Sys.Extended.UI.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.