From e0359790e8fc5d53e3e512564d57ba38226f29bd Mon Sep 17 00:00:00 2001 From: Ryan Schroeder Date: Tue, 28 Jan 2014 13:22:26 -0600 Subject: [PATCH 1/2] added init-size attribute to allow for setting initial pane size. To prevent conflicts, the tag is only allowed on the first pane, not the second. --- js/splitter.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/js/splitter.js b/js/splitter.js index fb9a577..8efd52d 100644 --- a/js/splitter.js +++ b/js/splitter.js @@ -29,6 +29,16 @@ angular.module('bgDirectives', []) pane1.elem.after(handler); + if (! isNaN(pane1.initSize)) { + handler.css('left', pane1.initSize + 'px'); + pane1.elem.css('width', pane1.initSize + 'px'); + pane2.elem.css('left', pane1.initSize + 'px'); + } + if (! isNaN(pane2.initSize)) { + throw new Error("second pane cannot have init-size: " + + "it is implied by the initSize on the first pane."); + } + element.bind('mousemove', function (ev) { if (!drag) return; @@ -79,7 +89,8 @@ angular.module('bgDirectives', []) replace: true, transclude: true, scope: { - minSize: '=' + minSize: '=', + initSize: '=' }, template: '
', link: function(scope, element, attrs, bgSplitterCtrl) { From 3aa07fe2637336f93b3b4798cb7946ec4f9065c7 Mon Sep 17 00:00:00 2001 From: Ryan Schroeder Date: Tue, 28 Jan 2014 15:08:00 -0600 Subject: [PATCH 2/2] forgot to account for horizontal vs vertical --- js/splitter.js | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/js/splitter.js b/js/splitter.js index 8efd52d..903dd23 100644 --- a/js/splitter.js +++ b/js/splitter.js @@ -28,15 +28,27 @@ angular.module('bgDirectives', []) var drag = false; pane1.elem.after(handler); + + var initPane1 = (!isNaN(pane1.initSize)); + var initPane2 = (!isNaN(pane2.initSize)); + var initLOrT; + var initWOrH; - if (! isNaN(pane1.initSize)) { - handler.css('left', pane1.initSize + 'px'); - pane1.elem.css('width', pane1.initSize + 'px'); - pane2.elem.css('left', pane1.initSize + 'px'); + if (vertical) { + initLOrT = 'top'; + initWOrH = 'height'; + } else { + initLOrT = 'left'; + initWOrH = 'width'; } - if (! isNaN(pane2.initSize)) { - throw new Error("second pane cannot have init-size: " - + "it is implied by the initSize on the first pane."); + + if (initPane2) { + throw new Error("second pane cannot have init-size attribute"); + } + if (initPane1) { + handler.css( initLOrT, pane1.initSize + 'px'); + pane1.elem.css(initWOrH, pane1.initSize + 'px'); + pane2.elem.css(initLOrT, pane1.initSize + 'px'); } element.bind('mousemove', function (ev) {