Skip to content

Commit

Permalink
Support managing page stack in sidemenu, not working cos of issue in …
Browse files Browse the repository at this point in the history
  • Loading branch information
HazemKhaled committed Apr 25, 2016
1 parent 2c7b3e9 commit 92abce8
Showing 1 changed file with 54 additions and 2 deletions.
56 changes: 54 additions & 2 deletions WindowStack.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -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();
}
Expand Down Expand Up @@ -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 = [];
Expand Down

0 comments on commit 92abce8

Please sign in to comment.