From 92abce817a3d25e1cb9e55d63d2706faf736f81f Mon Sep 17 00:00:00 2001 From: Hazem Khaled Date: Mon, 25 Apr 2016 12:59:31 +0200 Subject: [PATCH] Support managing page stack in sidemenu, not working cos of issue in Napp https://github.com/viezel/NappDrawer/issues/188 --- WindowStack.js | 56 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 2 deletions(-) diff --git a/WindowStack.js b/WindowStack.js index 1a58fee..e39a972 100644 --- a/WindowStack.js +++ b/WindowStack.js @@ -19,6 +19,30 @@ function WindowStack() { */ this.apiName = 'ti-window-stack'; + /** + * Constant to open the window into the center of the drawer + * @type {Number} + */ + this.CENTER_WINDOW = 101; + + /** + * Constant to open the window into the right of the drawer + * @type {Number} + */ + this.RIGHT_WINDOW = 102; + + /** + * Constant to open the window into the left of the drawer + * @type {Number} + */ + this.LEFT_WINDOW = 103; + + /** + * Which side to open new window in the drawer, center is default + * @type {NUMBER} + */ + this.targetInDrawer = this.CENTER_WINDOW; + /** * Set external created NavigationWindow * @param {Ti.UI.NavigationWindow} _navigationWindow NavigationWindow to set @@ -27,6 +51,16 @@ function WindowStack() { navigationWindow = _navigationWindow; }; + /** + * targetInDrawer setter + * @param {NUMBER} targetInDrawer WindowStack.CENTER_WINDOW, WindowStack.RIGHT_WINDOW or WindowStack.LEFT_WINDOW + */ + this.setTargetInDrawer = function (targetInDrawer) { + if ([that.CENTER_WINDOW, that.RIGHT_WINDOW, that.LEFT_WINDOW].indexOf(targetInDrawer) !== -1){ + this.targetInDrawer = targetInDrawer; + } + }; + /** * Open window into the stack, you can pass instance from nl.fokkezb.drawer to open this * window into drawer center window. @@ -47,7 +81,16 @@ function WindowStack() { }); if (drawer) { - drawer.setCenterWindow(navigationWindow); + // Open the window in center, right or left? + var openIn = 'setCenterWindow'; + if (that.targetInDrawer === that.RIGHT_WINDOW) { + openIn = 'setRightWindow'; + } else if (that.targetInDrawer === that.LEFT_WINDOW) { + openIn = 'setLeftWindow'; + } + + // Open the window into the drawer + drawer[openIn](navigationWindow); } else { navigationWindow.open(); } @@ -90,7 +133,16 @@ function WindowStack() { Ti.API.warn('Maybe we still do not have activity to update the menu, it works now by the way'); } - drawer.setCenterWindow(_window); + // Open the window in center, right or left? + var openIn = 'setCenterWindow'; + if (that.targetInDrawer === that.RIGHT_WINDOW) { + openIn = 'setRightWindow'; + } else if (that.targetInDrawer === that.LEFT_WINDOW) { + openIn = 'setLeftWindow'; + } + + // Open the window into the drawer + drawer[openIn](_window); // Reset our local stack refrance windows = [];