From 97b844563d8dea3e141cb264e53f7e1280803736 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Wed, 18 Feb 2015 09:03:50 -0800 Subject: [PATCH] [Fixed Position] Add proxy object Add proxy object to represent the selection of the fixed position view itself, WTD-879. --- .../features/layout/src/FixedController.js | 23 ++++++++-------- platform/features/layout/src/FixedProxy.js | 26 +++++++++++++++++++ 2 files changed, 38 insertions(+), 11 deletions(-) create mode 100644 platform/features/layout/src/FixedProxy.js diff --git a/platform/features/layout/src/FixedController.js b/platform/features/layout/src/FixedController.js index 8e9fb5936e..afcf8b312e 100644 --- a/platform/features/layout/src/FixedController.js +++ b/platform/features/layout/src/FixedController.js @@ -1,8 +1,8 @@ /*global define*/ define( - ['./LayoutDrag'], - function (LayoutDrag) { + ['./LayoutDrag', './LayoutSelection', './FixedProxy'], + function (LayoutDrag, LayoutSelection, FixedProxy) { "use strict"; var DEFAULT_DIMENSIONS = [ 2, 1 ], @@ -26,7 +26,8 @@ define( values = {}, cellStyles = [], rawPositions = {}, - positions = {}; + positions = {}, + selection; // Utility function to copy raw positions from configuration, // without writing directly to configuration (to avoid triggering @@ -179,6 +180,14 @@ define( populatePosition(id); } + // Track current selection state + if (Array.isArray($scope.selection)) { + selection = new LayoutSelection( + $scope.selection, + new FixedProxy($scope.configuration) + ); + } + // Position panes when the model field changes $scope.$watch("model.composition", updateComposition); @@ -194,14 +203,6 @@ define( // Initialize styles (position etc.) for cells refreshCellStyles(); - if (Array.isArray($scope.selection)) { - $scope.selection.push({ - add: function () { - window.alert("Placeholder; not yet implemented"); - } - }); - } - return { /** * Get styles for all background cells, as will populate the diff --git a/platform/features/layout/src/FixedProxy.js b/platform/features/layout/src/FixedProxy.js new file mode 100644 index 0000000000..a6c1583cf7 --- /dev/null +++ b/platform/features/layout/src/FixedProxy.js @@ -0,0 +1,26 @@ +/*global define*/ + +define( + [], + function () { + "use strict"; + + /** + * Proxy for configuring a fixed position view via the toolbar. + * @constructor + * @param configuration the view configuration object + */ + function FixedProxy(configuration) { + return { + /** + * Add a new visual element to this view. + */ + add: function (type) { + window.alert("Placeholder. Should add a " + type + "."); + } + }; + } + + return FixedProxy; + } +); \ No newline at end of file