| 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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 } | 201 } |
| 202 | 202 |
| 203 /** | 203 /** |
| 204 * @param {boolean} show | 204 * @param {boolean} show |
| 205 */ | 205 */ |
| 206 _togglePalettePanel(show) { | 206 _togglePalettePanel(show) { |
| 207 if (this._palettePanelShowing === show) | 207 if (this._palettePanelShowing === show) |
| 208 return; | 208 return; |
| 209 if (show) | 209 if (show) |
| 210 this._updatePalettePanel(); | 210 this._updatePalettePanel(); |
| 211 this._focus(); |
| 211 this._palettePanelShowing = show; | 212 this._palettePanelShowing = show; |
| 212 this.contentElement.classList.toggle('palette-panel-showing', show); | 213 this.contentElement.classList.toggle('palette-panel-showing', show); |
| 213 } | 214 } |
| 214 | 215 |
| 216 _focus() { |
| 217 if (this.isShowing()) |
| 218 this.contentElement.focus(); |
| 219 } |
| 220 |
| 215 /** | 221 /** |
| 216 * @param {string} colorText | 222 * @param {string} colorText |
| 217 * @param {number=} animationDelay | 223 * @param {number=} animationDelay |
| 218 * @return {!Element} | 224 * @return {!Element} |
| 219 */ | 225 */ |
| 220 _createPaletteColor(colorText, animationDelay) { | 226 _createPaletteColor(colorText, animationDelay) { |
| 221 var element = createElementWithClass('div', 'spectrum-palette-color'); | 227 var element = createElementWithClass('div', 'spectrum-palette-color'); |
| 222 element.style.background = String.sprintf('linear-gradient(%s, %s), url(Imag
es/checker.png)', colorText, colorText); | 228 element.style.background = String.sprintf('linear-gradient(%s, %s), url(Imag
es/checker.png)', colorText, colorText); |
| 223 if (animationDelay) | 229 if (animationDelay) |
| 224 element.animate([{opacity: 0}, {opacity: 1}], {duration: 100, delay: anima
tionDelay, fill: 'backwards'}); | 230 element.animate([{opacity: 0}, {opacity: 1}], {duration: 100, delay: anima
tionDelay, fill: 'backwards'}); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 numItems++; | 268 numItems++; |
| 263 if (palette.mutable) { | 269 if (palette.mutable) { |
| 264 this._paletteContainer.appendChild(this._addColorToolbar.element); | 270 this._paletteContainer.appendChild(this._addColorToolbar.element); |
| 265 this._paletteContainer.appendChild(this._deleteIconToolbar.element); | 271 this._paletteContainer.appendChild(this._deleteIconToolbar.element); |
| 266 } else { | 272 } else { |
| 267 this._addColorToolbar.element.remove(); | 273 this._addColorToolbar.element.remove(); |
| 268 this._deleteIconToolbar.element.remove(); | 274 this._deleteIconToolbar.element.remove(); |
| 269 } | 275 } |
| 270 | 276 |
| 271 this._togglePalettePanel(false); | 277 this._togglePalettePanel(false); |
| 278 this._focus(); |
| 272 } | 279 } |
| 273 | 280 |
| 274 /** | 281 /** |
| 275 * @param {!Element} colorElement | 282 * @param {!Element} colorElement |
| 276 * @param {string} colorText | 283 * @param {string} colorText |
| 277 * @param {!Event} event | 284 * @param {!Event} event |
| 278 */ | 285 */ |
| 279 _showLightnessShades(colorElement, colorText, event) { | 286 _showLightnessShades(colorElement, colorText, event) { |
| 280 /** | 287 /** |
| 281 * @param {!Element} element | 288 * @param {!Element} element |
| (...skipping 18 matching lines...) Expand all Loading... |
| 300 this._shadesContainer.style.left = colorElement.offsetLeft + 'px'; | 307 this._shadesContainer.style.left = colorElement.offsetLeft + 'px'; |
| 301 colorElement.classList.add('spectrum-shades-shown'); | 308 colorElement.classList.add('spectrum-shades-shown'); |
| 302 | 309 |
| 303 var shades = Components.Spectrum.MaterialPaletteShades[colorText]; | 310 var shades = Components.Spectrum.MaterialPaletteShades[colorText]; |
| 304 for (var i = shades.length - 1; i >= 0; i--) { | 311 for (var i = shades.length - 1; i >= 0; i--) { |
| 305 var shadeElement = this._createPaletteColor(shades[i], i * 200 / shades.le
ngth + 100); | 312 var shadeElement = this._createPaletteColor(shades[i], i * 200 / shades.le
ngth + 100); |
| 306 shadeElement.addEventListener('mousedown', this._paletteColorSelected.bind
(this, shades[i], false)); | 313 shadeElement.addEventListener('mousedown', this._paletteColorSelected.bind
(this, shades[i], false)); |
| 307 this._shadesContainer.appendChild(shadeElement); | 314 this._shadesContainer.appendChild(shadeElement); |
| 308 } | 315 } |
| 309 | 316 |
| 317 this._shadesContainer.focus(); |
| 310 this._shadesCloseHandler = closeLightnessShades.bind(this, colorElement); | 318 this._shadesCloseHandler = closeLightnessShades.bind(this, colorElement); |
| 311 this._shadesContainer.ownerDocument.addEventListener('mousedown', this._shad
esCloseHandler, true); | 319 this._shadesContainer.ownerDocument.addEventListener('mousedown', this._shad
esCloseHandler, true); |
| 312 } | 320 } |
| 313 | 321 |
| 314 /** | 322 /** |
| 315 * @param {!Event} e | 323 * @param {!Event} e |
| 316 * @return {number} | 324 * @return {number} |
| 317 */ | 325 */ |
| 318 _slotIndexForEvent(e) { | 326 _slotIndexForEvent(e) { |
| 319 var localX = e.pageX - this._paletteContainer.totalOffsetLeft(); | 327 var localX = e.pageX - this._paletteContainer.totalOffsetLeft(); |
| (...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1030 '#607D8B': | 1038 '#607D8B': |
| 1031 ['#ECEFF1', '#CFD8DC', '#B0BEC5', '#90A4AE', '#78909C', '#607D8B', '#546E7
A', '#455A64', '#37474F', '#263238'] | 1039 ['#ECEFF1', '#CFD8DC', '#B0BEC5', '#90A4AE', '#78909C', '#607D8B', '#546E7
A', '#455A64', '#37474F', '#263238'] |
| 1032 }; | 1040 }; |
| 1033 | 1041 |
| 1034 Components.Spectrum.MaterialPalette = { | 1042 Components.Spectrum.MaterialPalette = { |
| 1035 title: 'Material', | 1043 title: 'Material', |
| 1036 mutable: false, | 1044 mutable: false, |
| 1037 matchUserFormat: true, | 1045 matchUserFormat: true, |
| 1038 colors: Object.keys(Components.Spectrum.MaterialPaletteShades) | 1046 colors: Object.keys(Components.Spectrum.MaterialPaletteShades) |
| 1039 }; | 1047 }; |
| OLD | NEW |