From 740db8da75695130c14e5f27d6ce27c94713a57a Mon Sep 17 00:00:00 2001 From: Pegah Sarram Date: Wed, 13 Sep 2017 12:08:52 -0700 Subject: [PATCH] [Fixed Position] Add tests and fix checkstyle error. Fixes #1496 --- platform/features/fixed/bundle.js | 65 +------------------ .../features/layout/src/FixedController.js | 3 +- .../layout/src/elements/ElementFactory.js | 3 +- .../features/layout/src/elements/TextProxy.js | 4 ++ .../layout/test/elements/TextProxySpec.js | 8 +++ 5 files changed, 17 insertions(+), 66 deletions(-) diff --git a/platform/features/fixed/bundle.js b/platform/features/fixed/bundle.js index 5288578373..3f8e1ced07 100644 --- a/platform/features/fixed/bundle.js +++ b/platform/features/fixed/bundle.js @@ -152,68 +152,9 @@ define([ "title": "Text size", "description": "Set text size", "control": "select", - "options": [ - { - "value": "9px", - "name": "9 px" - }, - { - "value": "10px", - "name": "10 px" - }, - { - "value": "11px", - "name": "11 px" - }, - { - "value": "12px", - "name": "12 px" - }, - { - "value": "13px", - "name": "13 px" - }, - { - "value": "14px", - "name": "14 px" - }, - { - "value": "15px", - "name": "15 px" - }, - { - "value": "16px", - "name": "16 px" - }, - { - "value": "20px", - "name": "20 px" - }, - { - "value": "24px", - "name": "24 px" - }, - { - "value": "30px", - "name": "30 px" - }, - { - "value": "36px", - "name": "36 px" - }, - { - "value": "48px", - "name": "48 px" - }, - { - "value": "72px", - "name": "72 px" - }, - { - "value": "96px", - "name": "96 px" - } - ] + "options": [9, 10, 11, 12, 13, 14, 15, 16, 20, 24, 30, 36, 48, 72, 96].map(function (size) { + return { "name": size + " px", "value": size + "px" }; + }) } ] }, diff --git a/platform/features/layout/src/FixedController.js b/platform/features/layout/src/FixedController.js index d2db36bc1f..de3c5a32f6 100644 --- a/platform/features/layout/src/FixedController.js +++ b/platform/features/layout/src/FixedController.js @@ -256,8 +256,7 @@ define( titled: true, width: DEFAULT_DIMENSIONS[0], height: DEFAULT_DIMENSIONS[1], - useGrid: true, - size: "14px" + useGrid: true }); //Re-initialize objects, and subscribe to new object diff --git a/platform/features/layout/src/elements/ElementFactory.js b/platform/features/layout/src/elements/ElementFactory.js index 8567773576..8f4e0b09e2 100644 --- a/platform/features/layout/src/elements/ElementFactory.js +++ b/platform/features/layout/src/elements/ElementFactory.js @@ -42,8 +42,7 @@ define( }, "fixed.text": { fill: "transparent", - stroke: "transparent", - size: "13px" + stroke: "transparent" } }, DIALOGS = { diff --git a/platform/features/layout/src/elements/TextProxy.js b/platform/features/layout/src/elements/TextProxy.js index 8fee025170..a055ad3853 100644 --- a/platform/features/layout/src/elements/TextProxy.js +++ b/platform/features/layout/src/elements/TextProxy.js @@ -67,6 +67,10 @@ define( */ proxy.size = new AccessorMutator(element, 'size'); + if (proxy.size() === undefined) { + proxy.size("13px"); + } + return proxy; } diff --git a/platform/features/layout/test/elements/TextProxySpec.js b/platform/features/layout/test/elements/TextProxySpec.js index 2dd7340771..494ee76bda 100644 --- a/platform/features/layout/test/elements/TextProxySpec.js +++ b/platform/features/layout/test/elements/TextProxySpec.js @@ -57,6 +57,14 @@ define( expect(proxy.size('12px')).toEqual('12px'); expect(proxy.size()).toEqual('12px'); }); + + it("defaults to 13px for unspecified text size", function () { + testElement = {x: 1, y: 2}; + proxy = new TextProxy(testElement, 0, [testElement]); + + expect(proxy.size()).toEqual('13px'); + }); + }); } );