| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Brian Grinstead All rights reserved. | 2 * Copyright (C) 2011 Brian Grinstead All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 color: function() | 223 color: function() |
| 224 { | 224 { |
| 225 return WebInspector.Color.fromHSVA(this._hsv); | 225 return WebInspector.Color.fromHSVA(this._hsv); |
| 226 }, | 226 }, |
| 227 | 227 |
| 228 _colorString: function() | 228 _colorString: function() |
| 229 { | 229 { |
| 230 var cf = WebInspector.Color.Format; | 230 var cf = WebInspector.Color.Format; |
| 231 var format = this._originalFormat; | 231 var format = this._originalFormat; |
| 232 var color = this.color(); | 232 var color = this.color(); |
| 233 var originalFormatString = color.toString(this._originalFormat); | 233 var originalFormatString = color.asString(this._originalFormat); |
| 234 if (originalFormatString) | 234 if (originalFormatString) |
| 235 return originalFormatString; | 235 return originalFormatString; |
| 236 | 236 |
| 237 if (color.hasAlpha()) { | 237 if (color.hasAlpha()) { |
| 238 // Everything except HSL(A) should be returned as RGBA if transparen
cy is involved. | 238 // Everything except HSL(A) should be returned as RGBA if transparen
cy is involved. |
| 239 if (format === cf.HSLA || format === cf.HSL) | 239 if (format === cf.HSLA || format === cf.HSL) |
| 240 return color.toString(cf.HSLA); | 240 return color.asString(cf.HSLA); |
| 241 else | 241 else |
| 242 return color.toString(cf.RGBA); | 242 return color.asString(cf.RGBA); |
| 243 } | 243 } |
| 244 | 244 |
| 245 if (format === cf.ShortHEX) | 245 if (format === cf.ShortHEX) |
| 246 return color.toString(cf.HEX); | 246 return color.asString(cf.HEX); |
| 247 console.assert(format === cf.Nickname); | 247 console.assert(format === cf.Nickname); |
| 248 return color.toString(cf.RGB); | 248 return color.asString(cf.RGB); |
| 249 }, | 249 }, |
| 250 | 250 |
| 251 | 251 |
| 252 set displayText(text) | 252 set displayText(text) |
| 253 { | 253 { |
| 254 this._displayElement.textContent = text; | 254 this._displayElement.textContent = text; |
| 255 }, | 255 }, |
| 256 | 256 |
| 257 _onchange: function() | 257 _onchange: function() |
| 258 { | 258 { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 281 var slideY = this.slideHeight - ((h * this.slideHeight) + this.slideHelp
erHeight); | 281 var slideY = this.slideHeight - ((h * this.slideHeight) + this.slideHelp
erHeight); |
| 282 this.slideHelper.style.top = slideY + "px"; | 282 this.slideHelper.style.top = slideY + "px"; |
| 283 | 283 |
| 284 this._alphaElement.value = this._hsv[3] * 100; | 284 this._alphaElement.value = this._hsv[3] * 100; |
| 285 }, | 285 }, |
| 286 | 286 |
| 287 _updateUI: function() | 287 _updateUI: function() |
| 288 { | 288 { |
| 289 this._updateHelperLocations(); | 289 this._updateHelperLocations(); |
| 290 | 290 |
| 291 this._draggerElement.style.backgroundColor = /** @type {string} */ (WebI
nspector.Color.fromHSVA([this._hsv[0], 1, 1, 1]).toString(WebInspector.Color.For
mat.RGB)); | 291 this._draggerElement.style.backgroundColor = /** @type {string} */ (WebI
nspector.Color.fromHSVA([this._hsv[0], 1, 1, 1]).asString(WebInspector.Color.For
mat.RGB)); |
| 292 this._swatchInnerElement.style.backgroundColor = /** @type {string} */ (
this.color().toString(WebInspector.Color.Format.RGBA)); | 292 this._swatchInnerElement.style.backgroundColor = /** @type {string} */ (
this.color().asString(WebInspector.Color.Format.RGBA)); |
| 293 | 293 |
| 294 this._alphaElement.value = this._hsv[3] * 100; | 294 this._alphaElement.value = this._hsv[3] * 100; |
| 295 }, | 295 }, |
| 296 | 296 |
| 297 wasShown: function() | 297 wasShown: function() |
| 298 { | 298 { |
| 299 this.slideHeight = this._sliderElement.offsetHeight; | 299 this.slideHeight = this._sliderElement.offsetHeight; |
| 300 this.dragWidth = this._draggerElement.offsetWidth; | 300 this.dragWidth = this._draggerElement.offsetWidth; |
| 301 this.dragHeight = this._draggerElement.offsetHeight; | 301 this.dragHeight = this._draggerElement.offsetHeight; |
| 302 this._dragHelperElementHeight = this._dragHelperElement.offsetHeight / 2
; | 302 this._dragHelperElementHeight = this._dragHelperElement.offsetHeight / 2
; |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 | 455 |
| 456 WebInspector.ColorSwatch.prototype = { | 456 WebInspector.ColorSwatch.prototype = { |
| 457 /** | 457 /** |
| 458 * @param {string} colorString | 458 * @param {string} colorString |
| 459 */ | 459 */ |
| 460 setColorString: function(colorString) | 460 setColorString: function(colorString) |
| 461 { | 461 { |
| 462 this._swatchInnerElement.style.backgroundColor = colorString; | 462 this._swatchInnerElement.style.backgroundColor = colorString; |
| 463 } | 463 } |
| 464 } | 464 } |
| OLD | NEW |