| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2009 Joseph Pecoraro | 3 * Copyright (C) 2009 Joseph Pecoraro |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 */ | 32 */ |
| 33 Elements.StylesSidebarPane = class extends Elements.ElementsSidebarPane { | 33 Elements.StylesSidebarPane = class extends Elements.ElementsSidebarPane { |
| 34 constructor() { | 34 constructor() { |
| 35 super(); | 35 super(); |
| 36 this.setMinimumSize(96, 26); | 36 this.setMinimumSize(96, 26); |
| 37 | 37 |
| 38 Common.moduleSetting('colorFormat').addChangeListener(this.update.bind(this)
); | 38 Common.moduleSetting('colorFormat').addChangeListener(this.update.bind(this)
); |
| 39 Common.moduleSetting('textEditorIndent').addChangeListener(this.update.bind(
this)); | 39 Common.moduleSetting('textEditorIndent').addChangeListener(this.update.bind(
this)); |
| 40 | 40 |
| 41 this._sectionsContainer = this.element.createChild('div'); | 41 this._sectionsContainer = this.element.createChild('div'); |
| 42 this._swatchPopoverHelper = new UI.SwatchPopoverHelper(); | 42 this._swatchPopoverHelper = new InlineEditor.SwatchPopoverHelper(); |
| 43 this._linkifier = new Components.Linkifier(Elements.StylesSidebarPane._maxLi
nkLength, /* useLinkDecorator */ true); | 43 this._linkifier = new Components.Linkifier(Elements.StylesSidebarPane._maxLi
nkLength, /* useLinkDecorator */ true); |
| 44 | 44 |
| 45 this.element.classList.add('styles-pane'); | 45 this.element.classList.add('styles-pane'); |
| 46 | 46 |
| 47 /** @type {!Array<!Elements.SectionBlock>} */ | 47 /** @type {!Array<!Elements.SectionBlock>} */ |
| 48 this._sectionBlocks = []; | 48 this._sectionBlocks = []; |
| 49 Elements.StylesSidebarPane._instance = this; | 49 Elements.StylesSidebarPane._instance = this; |
| 50 UI.context.addFlavorChangeListener(SDK.DOMNode, this.forceUpdate, this); | 50 UI.context.addFlavorChangeListener(SDK.DOMNode, this.forceUpdate, this); |
| 51 } | 51 } |
| 52 | 52 |
| (...skipping 1806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1859 * @param {string} text | 1859 * @param {string} text |
| 1860 * @return {!Node} | 1860 * @return {!Node} |
| 1861 */ | 1861 */ |
| 1862 _processColor(text) { | 1862 _processColor(text) { |
| 1863 // We can be called with valid non-color values of |text| (like 'none' from
border style) | 1863 // We can be called with valid non-color values of |text| (like 'none' from
border style) |
| 1864 var color = Common.Color.parse(text); | 1864 var color = Common.Color.parse(text); |
| 1865 if (!color) | 1865 if (!color) |
| 1866 return createTextNode(text); | 1866 return createTextNode(text); |
| 1867 | 1867 |
| 1868 if (!this._editable()) { | 1868 if (!this._editable()) { |
| 1869 var swatch = UI.ColorSwatch.create(); | 1869 var swatch = InlineEditor.ColorSwatch.create(); |
| 1870 swatch.setColor(color); | 1870 swatch.setColor(color); |
| 1871 return swatch; | 1871 return swatch; |
| 1872 } | 1872 } |
| 1873 | 1873 |
| 1874 var swatchPopoverHelper = this._parentPane._swatchPopoverHelper; | 1874 var swatchPopoverHelper = this._parentPane._swatchPopoverHelper; |
| 1875 var swatch = UI.ColorSwatch.create(); | 1875 var swatch = InlineEditor.ColorSwatch.create(); |
| 1876 swatch.setColor(color); | 1876 swatch.setColor(color); |
| 1877 swatch.setFormat(Common.Color.detectColorFormat(swatch.color())); | 1877 swatch.setFormat(Common.Color.detectColorFormat(swatch.color())); |
| 1878 var swatchIcon = new Elements.ColorSwatchPopoverIcon(this, swatchPopoverHelp
er, swatch); | 1878 var swatchIcon = new Elements.ColorSwatchPopoverIcon(this, swatchPopoverHelp
er, swatch); |
| 1879 | 1879 |
| 1880 /** | 1880 /** |
| 1881 * @param {?Array<string>} backgroundColors | 1881 * @param {?Array<string>} backgroundColors |
| 1882 */ | 1882 */ |
| 1883 function computedCallback(backgroundColors) { | 1883 function computedCallback(backgroundColors) { |
| 1884 // TODO(aboxhall): distinguish between !backgroundColors (no text) and | 1884 // TODO(aboxhall): distinguish between !backgroundColors (no text) and |
| 1885 // !backgroundColors.length (no computed bg color) | 1885 // !backgroundColors.length (no computed bg color) |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1920 } | 1920 } |
| 1921 | 1921 |
| 1922 /** | 1922 /** |
| 1923 * @param {string} text | 1923 * @param {string} text |
| 1924 * @return {!Node} | 1924 * @return {!Node} |
| 1925 */ | 1925 */ |
| 1926 _processBezier(text) { | 1926 _processBezier(text) { |
| 1927 if (!this._editable() || !Common.Geometry.CubicBezier.parse(text)) | 1927 if (!this._editable() || !Common.Geometry.CubicBezier.parse(text)) |
| 1928 return createTextNode(text); | 1928 return createTextNode(text); |
| 1929 var swatchPopoverHelper = this._parentPane._swatchPopoverHelper; | 1929 var swatchPopoverHelper = this._parentPane._swatchPopoverHelper; |
| 1930 var swatch = UI.BezierSwatch.create(); | 1930 var swatch = InlineEditor.BezierSwatch.create(); |
| 1931 swatch.setBezierText(text); | 1931 swatch.setBezierText(text); |
| 1932 new Elements.BezierPopoverIcon(this, swatchPopoverHelper, swatch); | 1932 new Elements.BezierPopoverIcon(this, swatchPopoverHelper, swatch); |
| 1933 return swatch; | 1933 return swatch; |
| 1934 } | 1934 } |
| 1935 | 1935 |
| 1936 /** | 1936 /** |
| 1937 * @param {string} propertyValue | 1937 * @param {string} propertyValue |
| 1938 * @param {string} propertyName | 1938 * @param {string} propertyName |
| 1939 * @return {!Node} | 1939 * @return {!Node} |
| 1940 */ | 1940 */ |
| 1941 _processShadow(propertyValue, propertyName) { | 1941 _processShadow(propertyValue, propertyName) { |
| 1942 if (!this._editable()) | 1942 if (!this._editable()) |
| 1943 return createTextNode(propertyValue); | 1943 return createTextNode(propertyValue); |
| 1944 var shadows; | 1944 var shadows; |
| 1945 if (propertyName === 'text-shadow') | 1945 if (propertyName === 'text-shadow') |
| 1946 shadows = Common.CSSShadowModel.parseTextShadow(propertyValue); | 1946 shadows = Common.CSSShadowModel.parseTextShadow(propertyValue); |
| 1947 else | 1947 else |
| 1948 shadows = Common.CSSShadowModel.parseBoxShadow(propertyValue); | 1948 shadows = Common.CSSShadowModel.parseBoxShadow(propertyValue); |
| 1949 if (!shadows.length) | 1949 if (!shadows.length) |
| 1950 return createTextNode(propertyValue); | 1950 return createTextNode(propertyValue); |
| 1951 var container = createDocumentFragment(); | 1951 var container = createDocumentFragment(); |
| 1952 var swatchPopoverHelper = this._parentPane._swatchPopoverHelper; | 1952 var swatchPopoverHelper = this._parentPane._swatchPopoverHelper; |
| 1953 for (var i = 0; i < shadows.length; i++) { | 1953 for (var i = 0; i < shadows.length; i++) { |
| 1954 if (i !== 0) | 1954 if (i !== 0) |
| 1955 container.appendChild(createTextNode(', ')); // Add back commas and spa
ces between each shadow. | 1955 container.appendChild(createTextNode(', ')); // Add back commas and spa
ces between each shadow. |
| 1956 // TODO(flandy): editing the property value should use the original value
with all spaces. | 1956 // TODO(flandy): editing the property value should use the original value
with all spaces. |
| 1957 var cssShadowSwatch = UI.CSSShadowSwatch.create(); | 1957 var cssShadowSwatch = InlineEditor.CSSShadowSwatch.create(); |
| 1958 cssShadowSwatch.setCSSShadow(shadows[i]); | 1958 cssShadowSwatch.setCSSShadow(shadows[i]); |
| 1959 new Elements.ShadowSwatchPopoverHelper(this, swatchPopoverHelper, cssShado
wSwatch); | 1959 new Elements.ShadowSwatchPopoverHelper(this, swatchPopoverHelper, cssShado
wSwatch); |
| 1960 var colorSwatch = cssShadowSwatch.colorSwatch(); | 1960 var colorSwatch = cssShadowSwatch.colorSwatch(); |
| 1961 if (colorSwatch) | 1961 if (colorSwatch) |
| 1962 new Elements.ColorSwatchPopoverIcon(this, swatchPopoverHelper, colorSwat
ch); | 1962 new Elements.ColorSwatchPopoverIcon(this, swatchPopoverHelper, colorSwat
ch); |
| 1963 container.appendChild(cssShadowSwatch); | 1963 container.appendChild(cssShadowSwatch); |
| 1964 } | 1964 } |
| 1965 return container; | 1965 return container; |
| 1966 } | 1966 } |
| 1967 | 1967 |
| (...skipping 1112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3080 } | 3080 } |
| 3081 | 3081 |
| 3082 /** | 3082 /** |
| 3083 * @override | 3083 * @override |
| 3084 * @return {!UI.ToolbarItem} | 3084 * @return {!UI.ToolbarItem} |
| 3085 */ | 3085 */ |
| 3086 item() { | 3086 item() { |
| 3087 return this._button; | 3087 return this._button; |
| 3088 } | 3088 } |
| 3089 }; | 3089 }; |
| OLD | NEW |