diff --git a/platform/features/layout/bundle.json b/platform/features/layout/bundle.json index ba27f5e1c9..dabe340036 100644 --- a/platform/features/layout/bundle.json +++ b/platform/features/layout/bundle.json @@ -98,6 +98,28 @@ "glyph": "\u1D1B", "mandatory": true, "control": "color" + }, + { + "property": "url", + "glyph": "", + "control": "dialog", + "title": "Image Properties", + "dialog": { + "control": "textfield", + "name": "Image URL", + "required": true + } + }, + { + "property": "text", + "glyph": "", + "control": "dialog", + "title": "Text Properties", + "dialog": { + "control": "textfield", + "name": "Text", + "required": true + } } ] }, diff --git a/platform/features/layout/src/elements/ImageProxy.js b/platform/features/layout/src/elements/ImageProxy.js new file mode 100644 index 0000000000..56810eb4ea --- /dev/null +++ b/platform/features/layout/src/elements/ImageProxy.js @@ -0,0 +1,35 @@ +/*global define*/ + +define( + ['./ElementProxy', './AccessorMutator'], + function (ElementProxy, AccessorMutator) { + 'use strict'; + + /** + * Selection proxy for Image elements in a fixed position view. + * + * Note that arguments here are meant to match those expected + * by `Array.prototype.map` + * + * @constructor + * @param element the fixed position element, as stored in its + * configuration + * @param index the element's index within its array + * @param {Array} elements the full array of elements + */ + function ImageProxy(element, index, elements) { + var proxy = new ElementProxy(element, index, elements); + + /** + * Get and/or set the displayed text of this element. + * @param {string} [text] the new text (if setting) + * @returns {string} the text + */ + proxy.url = new AccessorMutator(element, 'url'); + + return proxy; + } + + return ImageProxy; + } +); \ No newline at end of file diff --git a/platform/features/layout/src/elements/TextProxy.js b/platform/features/layout/src/elements/TextProxy.js index a1da84399c..ebc3413b79 100644 --- a/platform/features/layout/src/elements/TextProxy.js +++ b/platform/features/layout/src/elements/TextProxy.js @@ -27,6 +27,13 @@ define( */ proxy.color = new AccessorMutator(element, 'color'); + /** + * Get and/or set the displayed text of this element. + * @param {string} [text] the new text (if setting) + * @returns {string} the text + */ + proxy.text = new AccessorMutator(element, 'text'); + return proxy; } diff --git a/platform/features/layout/test/elements/ImageProxySpec.js b/platform/features/layout/test/elements/ImageProxySpec.js new file mode 100644 index 0000000000..6d74759a0e --- /dev/null +++ b/platform/features/layout/test/elements/ImageProxySpec.js @@ -0,0 +1,37 @@ +/*global define,describe,it,expect,beforeEach,jasmine*/ + +define( + ['../../src/elements/ImageProxy'], + function (ImageProxy) { + "use strict"; + + describe("A fixed position image proxy", function () { + var testElement, + testElements, + proxy; + + beforeEach(function () { + testElement = { + x: 1, + y: 2, + width: 42, + height: 24, + url: "http://www.nasa.gov" + }; + testElements = [ {}, {}, testElement, {} ]; + proxy = new ImageProxy( + testElement, + testElements.indexOf(testElement), + testElements + ); + }); + + it("provides getter/setter for image URL", function () { + expect(proxy.url()).toEqual("http://www.nasa.gov"); + expect(proxy.url("http://www.nasa.gov/some.jpg")) + .toEqual("http://www.nasa.gov/some.jpg"); + expect(proxy.url()).toEqual("http://www.nasa.gov/some.jpg"); + }); + }); + } +);