1// Name: RoundedCorners.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.BoxCorners = function() { 8 throw Error.invalidOperation(); 9} 10 11Sys.Extended.UI.BoxCorners.prototype = { 12 None: 0x00, 13 14 TopLeft: 0x01, 15 TopRight: 0x02, 16 BottomRight: 0x04, 17 BottomLeft: 0x08, 18 19 Top: 0x01 | 0x02, 20 Right: 0x02 | 0x04, 21 Bottom: 0x04 | 0x08, 22 Left: 0x08 | 0x01, 23 All: 0x01 | 0x02 | 0x04 | 0x08 24} 25 26Sys.Extended.UI.BoxCorners.registerEnum("Sys.Extended.UI.BoxCorners", true); 27 28Sys.Extended.UI.RoundedCornersBehavior = function(element) { 29 // The RoundedCornersBehavior rounds the corners of its target element 30 // "element" - DOM element associated with the behavior 31 Sys.Extended.UI.RoundedCornersBehavior.initializeBase(this, [element]); 32 33 this._corners = Sys.Extended.UI.BoxCorners.All; 34 this._radius = 5; 35 this._color = null; 36 this._parentDiv = null; 37 this._originalStyle = null; 38 this._borderColor = null; 39 this._isDirty = true; 40} 41 42Sys.Extended.UI.RoundedCornersBehavior.prototype = { 43 initialize: function() { 44 Sys.Extended.UI.RoundedCornersBehavior.callBaseMethod(this, 'initialize'); 45 this.update(); 46 }, 47 48 dispose: function() { 49 this.disposeParentDiv(); 50 Sys.Extended.UI.RoundedCornersBehavior.callBaseMethod(this, 'dispose'); 51 }, 52 53 update: function() { 54 // Create the surrounding div that will have rounded corners 55 var e = this.get_element(); 56 57 if(!e || !this._isDirty || this.get_isUpdating()) 58 return; 59 60 this.disposeParentDiv(); 61 62 // This works with IE and latest versions of Chrome 63 if(e.style.borderRadius != undefined) { 64 e.style.borderRadius = this._radius + "px"; 65 66 // if border color is not none then set 67 // border style to solid and border width to 1px 68 if(this._borderColor) { 69 e.style.border = "solid"; 70 e.style.borderWidth = "1px"; 71 e.style.borderColor = this._borderColor; 72 } 73 else { 74 e.style.border = "none"; 75 e.style.borderWidth = "0"; 76 } 77 78 // if TopLeft corner is unchecked then Top left corner will not be round 79 if(!this.isCornerSet(Sys.Extended.UI.BoxCorners.TopLeft)) 80 e.style.borderTopLeftRadius = "0"; 81 82 // if BottomLeft corner is unchecked then Bottom left corner will not be round 83 if(!this.isCornerSet(Sys.Extended.UI.BoxCorners.BottomLeft)) 84 e.style.borderBottomLeftRadius = "0"; 85 86 // if TopRight corner is unchecked then Top right corner will not be round 87 if(!this.isCornerSet(Sys.Extended.UI.BoxCorners.TopRight)) 88 e.style.borderTopRightRadius = "0"; 89 90 // if BottomRight corner is unchecked then Bottom Right corner will not be round 91 if(!this.isCornerSet(Sys.Extended.UI.BoxCorners.BottomRight)) 92 e.style.borderBottomRightRadius = "0"; 93 } 94 // This works with FireFox 95 else if(e.style.MozBorderRadius != undefined) { 96 e.style.MozBorderRadius = this._radius + "px"; 97 98 // if border color is not none then set 99 // border style to solid and border width to 1px 100 if(this._borderColor) { 101 e.style.border = "solid"; 102 e.style.borderWidth = "1px"; 103 e.style.borderColor = this._borderColor; 104 } else { 105 e.style.border = "none"; 106 e.style.borderWidth = "0"; 107 } 108 109 // if TopLeft corner is unchecked then Top left corner will not be round 110 if(!this.isCornerSet(Sys.Extended.UI.BoxCorners.TopLeft)) 111 e.style.MozBorderRadiusTopleft = "0"; 112 113 // if BottomLeft corner is unchecked then Bottom left corner will not be round 114 if(!this.isCornerSet(Sys.Extended.UI.BoxCorners.BottomLeft)) 115 e.style.MozBorderRadiusBottomleft = "0"; 116 117 // if TopRight corner is unchecked then Top right corner will not be round 118 if(!this.isCornerSet(Sys.Extended.UI.BoxCorners.TopRight)) 119 e.style.MozBorderRadiusTopright = "0"; 120 121 // if BottomRight corner is unchecked then Bottom Right corner will not be round 122 if(!this.isCornerSet(Sys.Extended.UI.BoxCorners.BottomRight)) 123 e.style.MozBorderRadiusBottomright = "0"; 124 125 } 126 // This works with older versions of google Chrome 127 else if(e.style.WebkitBorderRadius != undefined) { 128 e.style.WebkitBorderRadius = this._radius + "px"; 129 130 // if border color is not none then set 131 // border style to solid and border width to 1px 132 if(this._borderColor) { 133 e.style.border = "solid"; 134 e.style.borderWidth = "1px"; 135 e.style.borderColor = this._borderColor; 136 } else { 137 e.style.border = "none"; 138 e.style.borderWidth = "0"; 139 } 140 141 // if TopLeft corner is unchecked then Top left corner will not be round 142 if(!this.isCornerSet(Sys.Extended.UI.BoxCorners.TopLeft)) 143 e.style.WebkitBorderRadiusTopLeft = "0"; 144 145 // if BottomLeft corner is unchecked then Bottom left corner will not be round 146 if(!this.isCornerSet(Sys.Extended.UI.BoxCorners.BottomLeft)) 147 e.style.WebkitBorderRadiusBottomLeft = "0"; 148 149 // if TopRight corner is unchecked then Top right corner will not be round 150 if(!this.isCornerSet(Sys.Extended.UI.BoxCorners.TopRight)) 151 e.style.WebkitBorderRadiusTopRight = "0"; 152 153 // if BottomRight corner is unchecked then Bottom Right corner will not be round 154 if(!this.isCornerSet(Sys.Extended.UI.BoxCorners.BottomRight)) 155 e.style.WebkitBorderRadiusBottomRight = "0"; 156 } 157 // if browser does not support css3 then continue old way to make corners round 158 else {
159 var color = this.getBackgroundColor(), 160 originalWidth = e.offsetWidth, 161 newParent = e.cloneNode(false); 162 163 // move all children into the new div. 164 this.moveChildren(e, newParent); 165 166 // modify the target element to be transparent 167 // and set up the new parent 168 this._originalStyle = e.style.cssText; 169 e.style.backgroundColor = "transparent"; 170 e.style.verticalAlign = "top"; 171 e.style.padding = "0"; 172 e.style.overflow = ""; 173 e.style.className = ""; 174 175 // Don't assume there is a numerical value for height. A height of "auto" is possible. 176 if(e.style.height && e.style.height != "auto") 177 // Increase the height to account for the rounded corners 178 e.style.height = parseInt($common.getCurrentStyle(e, 'height')) + (this._radius * 2) + "px"; 179 else 180 // Note: Do NOT use $common.getCurrentStyle in the check below 181 // because that breaks the work-around 182 if(!e.style.width && (0 < originalWidth)) 183 // The following line works around a problem where IE renders the first 184 // rounded DIV about 6 pixels too high if e doesn't have a width or height 185 e.style.width = originalWidth + "px"; 186 187 // these are properties we don't want cloned down to the new parent 188 newParent.style.position = ""; 189 newParent.style.border = ""; 190 newParent.style.margin = ""; 191 newParent.style.width = "100%"; 192 if((newParent.style.overflow == "") && ($common.getCurrentStyle(e, "overflow") == "visible")) 193 // If the style of the target element has not been set inline, 194 // and has not been set in a stylesheet to something other than "visible" 195 // (which is the default), then set it to "auto", so that any child block elements 196 // do not cause the rounded corner divs to display as separated from the target div 197 newParent.style.overflow = "auto"; 198 199 newParent.id = ""; 200 newParent.removeAttribute("control"); 201 202 if(this._borderColor) { 203 newParent.style.borderTopStyle = "none"; 204 newParent.style.borderBottomStyle = "none"; 205 newParent.style.borderLeftStyle = "solid"; 206 newParent.style.borderRightStyle = "solid"; 207 newParent.style.borderLeftColor = this._borderColor; 208 newParent.style.borderRightColor = this._borderColor; 209 newParent.style.borderLeftWidth = "1px"; 210 newParent.style.borderRightWidth = "1px"; 211 212 if(this._radius == 0) { 213 newParent.style.borderTopStyle = "solid"; 214 newParent.style.borderBottomStyle = "solid"; 215 newParent.style.borderTopColor = this._borderColor; 216 newParent.style.borderBottomColor = this._borderColor; 217 newParent.style.borderTopWidth = "1px"; 218 newParent.style.borderBottomWidth = "1px"; 219 } 220 } else { 221 newParent.style.borderTopStyle = "none"; 222 newParent.style.borderBottomStyle = "none"; 223 newParent.style.borderLeftStyle = "none"; 224 newParent.style.borderRightStyle = "none"; 225 } 226 227 // build a set of steps on each end to fake the corners. 228 // ------- (step 0) 229 // -------- (step n-1) 230 // --------- (step n) 231 // XXXXXXXXX (inner div) 232 // XXXXXXXXX 233 // --------- (bottom step n) 234 // -------- (bottom step n-1) 235 // ------ (bottom step 0) 236 237 var lastDiv = null, 238 radius = this._radius, 239 lines = this._radius, 240 lastDelta = 0; 241 242 for(var i = lines; i > 0; i--) { 243 // figure out how much we'll need to subtract from each item 244 var angle = Math.acos(i / radius),
245 delta = radius - Math.round(Math.sin(angle) * radius); 246 247 // build a 1 pixel tall div 248 // that's delta pixels shorter on each end. 249 250 // add the top one 251 var newDiv = document.createElement("DIV"); 252 newDiv.__roundedDiv = true; 253 newDiv.style.backgroundColor = color; 254 newDiv.style.marginLeft = delta + "px"; 255 newDiv.style.marginRight = (delta - (this._borderColor ? 2 : 0)) + "px"; 256 newDiv.style.height = "1px"; 257 newDiv.style.fontSize = "1px"; // workaround for IE wierdness with 1px divs. 258 newDiv.style.overflow = "hidden"; 259 260 if(this._borderColor) { 261 newDiv.style.borderLeftStyle = "solid"; 262 newDiv.style.borderRightStyle = "solid"; 263 newDiv.style.borderLeftColor = this._borderColor; 264 newDiv.style.borderRightColor = this._borderColor; 265 266 var offset = Math.max(0, lastDelta - delta - 1); 267 newDiv.style.borderLeftWidth = (offset + 1) + "px"; 268 newDiv.style.borderRightWidth = (offset + 1) + "px"; 269 270 if(i == lines) { 271 newDiv.__roundedDivNoBorder = true; 272 newDiv.style.backgroundColor = this._borderColor; 273 } 274 } 275 276 e.insertBefore(newDiv, lastDiv); 277 278 var topDiv = newDiv; 279 280 // add the bottom one one 281 newDiv = newDiv.cloneNode(true); 282 newDiv.__roundedDiv = true; 283 284 e.insertBefore(newDiv, lastDiv); 285 286 var bottomDiv = newDiv; 287 288 lastDiv = newDiv; 289 lastDelta = delta; 290 291 if(!this.isCornerSet(Sys.Extended.UI.BoxCorners.TopLeft)) { 292 topDiv.style.marginLeft = "0"; 293 if(this._borderColor) 294 topDiv.style.borderLeftWidth = "1px"; 295 } 296 if(!this.isCornerSet(Sys.Extended.UI.BoxCorners.TopRight)) { 297 topDiv.style.marginRight = "0"; 298 if(this._borderColor) { 299 topDiv.style.borderRightWidth = "1px"; 300 topDiv.style.marginRight = "-2px"; 301 } 302 } 303 if(!this.isCornerSet(Sys.Extended.UI.BoxCorners.BottomLeft)) { 304 bottomDiv.style.marginLeft = "0"; 305 if(this._borderColor) 306 bottomDiv.style.borderLeftWidth = "1px"; 307 } 308 if(!this.isCornerSet(Sys.Extended.UI.BoxCorners.BottomRight)) { 309 bottomDiv.style.marginRight = "0"; 310 if(this._borderColor) { 311 bottomDiv.style.borderRightWidth = "1px"; 312 bottomDiv.style.marginRight = "-2px"; 313 } 314 } 315 } 316 317 // finally, add the newParent (which has all the original content) 318 // into the div. 319 e.insertBefore(newParent, lastDiv); 320 this._parentDiv = newParent; 321 this._isDirty = false; 322 } 323 }, 324 325 disposeParentDiv: function() { 326 // Dispose the surrounding div with rounded corners 327 328 if(this._parentDiv) { 329 // clean up the divs we added. 330 var e = this.get_element(), 331 children = e.childNodes; 332 333 for(var i = children.length - 1; i >= 0; i--) { 334 var child = children[i]; 335 if(child) { 336 if(child == this._parentDiv) 337 this.moveChildren(child, e); 338 339 try { 340 e.removeChild(child); 341 } catch(e) { 342 // Safari likes to throw NOT_FOUND_ERR (DOMException 8) 343 // but it seems to work fine anyway. 344 } 345 } 346 } 347 348 // restore the original style 349 if(this._originalStyle) { 350 e.style.cssText = this._originalStyle; 351 this._originalStyle = null; 352 } 353 this._parentDiv = null; 354 } 355 }, 356 357 /// <summary> 358 /// Returns the background color of the target element 359 /// </summary> 360 /// <returns type="String">String contains the color of the target element</returns> 361 /// <member name="cM:AjaxControlToolkit.RoundedCornersExtender.getBackgroun
361dColor" /> 362 getBackgroundColor: function() { 363 if(this._color) 364 return this._color; 365 return $common.getCurrentStyle(this.get_element(), 'backgroundColor'); 366 }, 367 368 moveChildren: function(src, dest) { 369 // Move the child nodes from one element to another 370 // "src" - DOM Element 371 // "dest" - DOM Element 372 var moveCount = 0; 373 while(src.hasChildNodes()) { 374 var child = src.childNodes[0]; 375 child = src.removeChild(child); 376 dest.appendChild(child); 377 moveCount++; 378 } 379 return moveCount; 380 }, 381 382 /// <summary> 383 /// Checks whether a flag for this corner has been set 384 /// </summary> 385 /// <param name="corner" type="Sys.Extended.UI.BoxCorners">Corner to check</param> 386 /// <returns type="Boolean">True if the corner has been set; otherwise, false</returns> 387 /// <member name="cM:AjaxControlToolkit.RoundedCornersExtender.isCornerSet" /> 388 isCornerSet: function(corner) { 389 return (this._corners & corner) != Sys.Extended.UI.BoxCorners.None; 390 }, 391 392 /// <summary> 393 /// Sets a corner as one that should be rounded 394 /// </summary> 395 /// <param name="corner" type="Sys.Extended.UI.BoxCorners">Corner to set</param> 396 /// <param name="value" type="Boolean">True to set the value, false to clear it</param> 397 /// <member name="cM:AjaxControlToolkit.RoundedCornersExtender.setCorner" /> 398 setCorner: function(corner, value) { 399 if(value) 400 this.set_corners(this._corners | corner); 401 else 402 this.set_corners(this._corners & ~corner); 403 }, 404 405 /// <summary> 406 /// A string that contains the background color of the rounded corner areas 407 /// </summary> 408 /// <remarks> 409 /// By default, this property gets the background color of the panel that it is attached to 410 /// </remarks> 411 /// <getter>get_color</getter> 412 /// <setter>set_color</setter> 413 /// <member name="cP:AjaxControlToolkit.RoundedCornersExtender.color" /> 414 get_color: function() { 415 return this._color; 416 }, 417 set_color: function(value) { 418 if(value != this._color) { 419 this._color = value; 420 this._isDirty = true; 421 this.update(); 422 this.raisePropertyChanged('color'); 423 } 424 }, 425 426 get_Color: function() { 427 Sys.Extended.Deprecated("get_Color()", "get_color()"); 428 return this.get_color(); 429 }, 430 set_Color: function(value) { 431 Sys.Extended.Deprecated("set_Color(value)", "set_color(value)"); 432 this.set_color(value); 433 }, 434 435 /// <summary> 436 /// An integer value that specifies the radius of the corners (and the height of the added area). The default is 5 437 /// The default is 5 438 /// </summary> 439 /// <getter>get_radius</getter> 440 /// <setter>set_radius</setter> 441 /// <member name="cP:AjaxControlToolkit.RoundedCornersExtender.radius" /> 442 get_radius: function() { 443 return this._radius; 444 }, 445 set_radius: function(value) { 446 if(value != this._radius) { 447 this._radius = value; 448 this._isDirty = true; 449 this.update(); 450 this.raisePropertyChanged('radius'); 451 } 452 }, 453 454 get_Radius: function() { 455 Sys.Extended.Deprecated("get_Radius()", "get_radius()"); 456 return this.get_radius(); 457 }, 458 set_Radius: function(value) { 459 Sys.Extended.Deprecated("set_Radius(value)", "set_radius(value)"); 460 this.set_radius(value); 461 }, 462 463 /// <summary> 464 /// A Sys.Extended.UI.BoxCorners object that specifies which corners should be rounded 465 /// </summary> 466 /// <getter>get_corners</getter> 467 /// <setter>set_corners</setter> 468 /// <member name="cP:AjaxControlToolkit.RoundedCornersExtender.corners" /> 469 get_corners: function() { 470 return this._corners; 471 }, 472 set_corners: function(value) { 473 if(value != this._corners) { 474 this._corners = value; 475 this._isDirty = true; 476 this.update(); 477 this.raisePropertyChanged("corners"); 478 } 479 }, 480 481 get_Corners: function() { 482 Sys.Extended.Deprecated("get_Corners()", "get_corners()"); 483 return this.get_corners(); 484 }, 485 set_Corners: function(value) { 486 Sys.Extended.Deprecated("set_Corners(value)", "set_corners(value)"); 487 this.set_corners(value); 488 }, 489 490 /// <summary> 491 /// A string that contains the color of the border and therefore of the rounded corners 492 /// </summary> 493 /// <getter>get_borderColor</getter> 494 /// <setter>set_borderColor</setter> 495 /// <member name="cP:AjaxControlToolkit.RoundedCornersExtender.borderColor" /> 496 get_borderColor: function() { 497 return this._borderColor; 498 }, 499 set_borderColor: function(value) { 500 if(value != this._borderColor) { 501 this._borderColor = value; 502 this._isDirty = true; 503 this.update(); 504 this.raisePropertyChanged("borderColor"); 505 } 506 }, 507 508 get_BorderColor: function() { 509 Sys.Extended.Deprecated("get_BorderColor()", "get_borderColor()"); 510 return this.get_borderColor(); 511 }, 512 set_BorderColor: function(value) { 513 Sys.Extended.Deprecated("set_BorderColor(value)", "set_borderColor(value)"); 514 this.set_borderColor(value); 515 } 516} 517 518Sys.Extended.UI.RoundedCornersBehavior.registerClass('Sys.Extended.UI.RoundedCornersBehavior', 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.