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