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 20 matching lines...) Expand all Loading... |
31 * @extends {WebInspector.VBox} | 31 * @extends {WebInspector.VBox} |
32 */ | 32 */ |
33 WebInspector.Spectrum = function() | 33 WebInspector.Spectrum = function() |
34 { | 34 { |
35 WebInspector.VBox.call(this); | 35 WebInspector.VBox.call(this); |
36 this.registerRequiredCSS("spectrum.css"); | 36 this.registerRequiredCSS("spectrum.css"); |
37 | 37 |
38 this.element.classList.add("spectrum-container"); | 38 this.element.classList.add("spectrum-container"); |
39 this.element.tabIndex = 0; | 39 this.element.tabIndex = 0; |
40 | 40 |
41 var topElement = this.element.createChild("div", "spectrum-top"); | 41 this._draggerElement = this.element.createChild("div", "spectrum-color"); |
42 topElement.createChild("div", "spectrum-fill"); | |
43 | |
44 var topInnerElement = topElement.createChild("div", "spectrum-top-inner fill
"); | |
45 this._draggerElement = topInnerElement.createChild("div", "spectrum-color"); | |
46 this._dragHelperElement = this._draggerElement.createChild("div", "spectrum-
sat fill").createChild("div", "spectrum-val fill").createChild("div", "spectrum-
dragger"); | 42 this._dragHelperElement = this._draggerElement.createChild("div", "spectrum-
sat fill").createChild("div", "spectrum-val fill").createChild("div", "spectrum-
dragger"); |
47 | 43 |
48 this._sliderElement = topInnerElement.createChild("div", "spectrum-hue"); | 44 this._sliderElement = this.element.createChild("div", "spectrum-hue"); |
49 this.slideHelper = this._sliderElement.createChild("div", "spectrum-slider")
; | 45 this.slideHelper = this._sliderElement.createChild("div", "spectrum-slider")
; |
50 | 46 |
51 var rangeContainer = this.element.createChild("div", "spectrum-range-contain
er"); | 47 var rangeContainer = this.element.createChild("div", "spectrum-range-contain
er"); |
52 var alphaLabel = rangeContainer.createChild("label"); | 48 var alphaLabel = rangeContainer.createChild("label"); |
53 alphaLabel.textContent = WebInspector.UIString("\u03B1:"); | 49 alphaLabel.textContent = WebInspector.UIString("\u03B1:"); |
54 | 50 |
55 this._alphaElement = rangeContainer.createChild("input", "spectrum-range"); | 51 this._alphaElement = rangeContainer.createChild("input", "spectrum-range"); |
56 this._alphaElement.setAttribute("type", "range"); | 52 this._alphaElement.setAttribute("type", "range"); |
57 this._alphaElement.setAttribute("min", "0"); | 53 this._alphaElement.setAttribute("min", "0"); |
58 this._alphaElement.setAttribute("max", "100"); | 54 this._alphaElement.setAttribute("max", "100"); |
59 this._alphaElement.addEventListener("input", alphaDrag.bind(this), false); | 55 this._alphaElement.addEventListener("input", alphaDrag.bind(this), false); |
60 this._alphaElement.addEventListener("change", alphaDrag.bind(this), false); | 56 this._alphaElement.addEventListener("change", alphaDrag.bind(this), false); |
61 | 57 |
62 var displayContainer = this.element.createChild("div"); | 58 var displayContainer = this.element.createChild("div", "spectrum-text"); |
63 var swatchElement = displayContainer.createChild("span", "swatch"); | 59 var swatchElement = displayContainer.createChild("span", "swatch"); |
64 this._swatchInnerElement = swatchElement.createChild("span", "swatch-inner")
; | 60 this._swatchInnerElement = swatchElement.createChild("span", "swatch-inner")
; |
65 this._displayElement = displayContainer.createChild("span", "source-code spe
ctrum-display-value"); | 61 this._displayElement = displayContainer.createChild("span", "source-code spe
ctrum-display-value"); |
66 | 62 |
67 WebInspector.Spectrum.draggable(this._sliderElement, hueDrag.bind(this)); | 63 WebInspector.Spectrum.draggable(this._sliderElement, hueDrag.bind(this)); |
68 WebInspector.Spectrum.draggable(this._draggerElement, colorDrag.bind(this),
colorDragStart.bind(this)); | 64 WebInspector.Spectrum.draggable(this._draggerElement, colorDrag.bind(this),
colorDragStart.bind(this)); |
69 | 65 |
70 /** | 66 /** |
71 * @param {!Element} element | 67 * @param {!Element} element |
72 * @param {number} dragX | 68 * @param {number} dragX |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 | 436 |
441 WebInspector.ColorSwatch.prototype = { | 437 WebInspector.ColorSwatch.prototype = { |
442 /** | 438 /** |
443 * @param {string} colorString | 439 * @param {string} colorString |
444 */ | 440 */ |
445 setColorString: function(colorString) | 441 setColorString: function(colorString) |
446 { | 442 { |
447 this._swatchInnerElement.style.backgroundColor = colorString; | 443 this._swatchInnerElement.style.backgroundColor = colorString; |
448 } | 444 } |
449 } | 445 } |
OLD | NEW |