| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 var alphaLabel = rangeContainer.createChild("label"); | 52 var alphaLabel = rangeContainer.createChild("label"); |
| 53 alphaLabel.textContent = WebInspector.UIString("\u03B1:"); | 53 alphaLabel.textContent = WebInspector.UIString("\u03B1:"); |
| 54 | 54 |
| 55 this._alphaElement = rangeContainer.createChild("input", "spectrum-range"); | 55 this._alphaElement = rangeContainer.createChild("input", "spectrum-range"); |
| 56 this._alphaElement.setAttribute("type", "range"); | 56 this._alphaElement.setAttribute("type", "range"); |
| 57 this._alphaElement.setAttribute("min", "0"); | 57 this._alphaElement.setAttribute("min", "0"); |
| 58 this._alphaElement.setAttribute("max", "100"); | 58 this._alphaElement.setAttribute("max", "100"); |
| 59 this._alphaElement.addEventListener("input", alphaDrag.bind(this), false); | 59 this._alphaElement.addEventListener("input", alphaDrag.bind(this), false); |
| 60 this._alphaElement.addEventListener("change", alphaDrag.bind(this), false); | 60 this._alphaElement.addEventListener("change", alphaDrag.bind(this), false); |
| 61 | 61 |
| 62 var swatchElement = document.createElement("span"); | 62 var displayContainer = this.element.createChild("div"); |
| 63 swatchElement.className = "swatch"; | 63 var swatchElement = displayContainer.createChild("span", "swatch"); |
| 64 this._swatchInnerElement = swatchElement.createChild("span", "swatch-inner")
; | 64 this._swatchInnerElement = swatchElement.createChild("span", "swatch-inner")
; |
| 65 | |
| 66 var displayContainer = this.element.createChild("div"); | |
| 67 displayContainer.appendChild(swatchElement); | |
| 68 this._displayElement = displayContainer.createChild("span", "source-code spe
ctrum-display-value"); | 65 this._displayElement = displayContainer.createChild("span", "source-code spe
ctrum-display-value"); |
| 69 | 66 |
| 70 WebInspector.Spectrum.draggable(this._sliderElement, hueDrag.bind(this)); | 67 WebInspector.Spectrum.draggable(this._sliderElement, hueDrag.bind(this)); |
| 71 WebInspector.Spectrum.draggable(this._draggerElement, colorDrag.bind(this),
colorDragStart.bind(this)); | 68 WebInspector.Spectrum.draggable(this._draggerElement, colorDrag.bind(this),
colorDragStart.bind(this)); |
| 72 | 69 |
| 73 /** | 70 /** |
| 74 * @param {!Element} element | 71 * @param {!Element} element |
| 75 * @param {number} dragX | 72 * @param {number} dragX |
| 76 * @param {number} dragY | 73 * @param {number} dragY |
| 77 * @this {WebInspector.Spectrum} | 74 * @this {WebInspector.Spectrum} |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 | 423 |
| 427 __proto__: WebInspector.Object.prototype | 424 __proto__: WebInspector.Object.prototype |
| 428 } | 425 } |
| 429 | 426 |
| 430 /** | 427 /** |
| 431 * @constructor | 428 * @constructor |
| 432 * @param {boolean=} readOnly | 429 * @param {boolean=} readOnly |
| 433 */ | 430 */ |
| 434 WebInspector.ColorSwatch = function(readOnly) | 431 WebInspector.ColorSwatch = function(readOnly) |
| 435 { | 432 { |
| 436 this.element = document.createElement("span"); | 433 this.element = document.createElementWithClass("span", "swatch"); |
| 437 this._swatchInnerElement = this.element.createChild("span", "swatch-inner"); | 434 this._swatchInnerElement = this.element.createChild("span", "swatch-inner"); |
| 438 var shiftClickMessage = WebInspector.UIString("Shift-click to change color f
ormat."); | 435 var shiftClickMessage = WebInspector.UIString("Shift-click to change color f
ormat."); |
| 439 this.element.title = readOnly ? shiftClickMessage : String.sprintf("%s\n%s",
WebInspector.UIString("Click to open a colorpicker."), shiftClickMessage); | 436 this.element.title = readOnly ? shiftClickMessage : String.sprintf("%s\n%s",
WebInspector.UIString("Click to open a colorpicker."), shiftClickMessage); |
| 440 this.element.className = "swatch"; | |
| 441 this.element.addEventListener("mousedown", consumeEvent, false); | 437 this.element.addEventListener("mousedown", consumeEvent, false); |
| 442 this.element.addEventListener("dblclick", consumeEvent, false); | 438 this.element.addEventListener("dblclick", consumeEvent, false); |
| 443 } | 439 } |
| 444 | 440 |
| 445 WebInspector.ColorSwatch.prototype = { | 441 WebInspector.ColorSwatch.prototype = { |
| 446 /** | 442 /** |
| 447 * @param {string} colorString | 443 * @param {string} colorString |
| 448 */ | 444 */ |
| 449 setColorString: function(colorString) | 445 setColorString: function(colorString) |
| 450 { | 446 { |
| 451 this._swatchInnerElement.style.backgroundColor = colorString; | 447 this._swatchInnerElement.style.backgroundColor = colorString; |
| 452 } | 448 } |
| 453 } | 449 } |
| OLD | NEW |