Permalink
Browse files

remove maskview

  • Loading branch information...
1 parent 0bef467 commit 9bcc1ad466d544c46a4c7bf23220ea1428ae3562 @ofl committed Apr 28, 2012
Showing with 27 additions and 29 deletions.
  1. +9 −13 Resources/ui/TabGroup.js
  2. +4 −0 Resources/ui/red/Window.js
  3. +9 −14 coffee/ui/TabGroup.coffee
  4. +5 −2 coffee/ui/red/Window.coffee
@@ -8,7 +8,7 @@ trace = function(mes) {
mix = (require('helpers/util')).mix;
TabGroup = (function() {
function TabGroup() {
- var index, maskView, menuWindow, offsetWidth, pages, tabGroup, tabs, touchStartX, touchStarted, _addWindowEvent, _catchBubble, _switchWindow, _toggleOpenMenu, _touchHandler;
+ var index, menuWindow, offsetWidth, pages, tabGroup, tabs, touchStartX, touchStarted, _addWindowEvent, _catchBubble, _menuDidClosed, _switchWindow, _toggleOpenMenu, _touchHandler;
trace("start constructor");
pages = [
{
@@ -47,18 +47,11 @@ TabGroup = (function() {
tabs[pages[index].dir].window = new (require("" + dir + "/" + pages[index].dir + "/Window"))(tabs[pages[index].dir]);
menuWindow = new (require("" + dir + "/menu/Window"))();
menuWindow.open();
- maskView = Ti.UI.createView({
- width: Ti.UI.FILL,
- height: Ti.UI.FILL,
- zIndex: 100,
- visible: false
- });
_catchBubble = function(e) {
var nextIndex;
switch (e.btype) {
case 'showMenu':
_toggleOpenMenu();
- maskView.visible = true;
break;
case 'didSelectMenu':
nextIndex = e.boptions.index;
@@ -71,7 +64,7 @@ TabGroup = (function() {
} else {
_switchWindow(nextIndex);
}
- maskView.visible = false;
+ _menuDidClosed();
}
};
_toggleOpenMenu = function() {
@@ -81,6 +74,9 @@ TabGroup = (function() {
left: left
}), function() {
tabGroup.left = left;
+ if (left === 0) {
+ _menuDidClosed();
+ }
});
};
_switchWindow = function(nextIndex) {
@@ -92,7 +88,6 @@ TabGroup = (function() {
};
tabGroup.animate(a, function() {
var d;
- tabs[pages[index].dir].window.remove(maskView);
d = pages[nextIndex].dir;
if (typeof tabs[d] === 'undefined') {
tabs[d] = Ti.UI.createTab($$.tab);
@@ -101,7 +96,6 @@ TabGroup = (function() {
tabGroup.addTab(tabs[d]);
_addWindowEvent(nextIndex);
}
- tabs[d].window.add(maskView);
tabGroup.setActiveTab(tabs[d]);
tabGroup.animate(mix($$.animation, {
left: 0
@@ -137,19 +131,21 @@ TabGroup = (function() {
tabGroup.animate(mix($$.animation, {
left: offsetWidth
}), function() {
- maskView.visible = true;
tabGroup.left = offsetWidth;
});
} else {
tabGroup.animate(mix($$.animation, {
left: 0
}), function() {
- maskView.visible = false;
tabGroup.left = 0;
+ _menuDidClosed();
});
}
}
};
+ _menuDidClosed = function() {
+ tabs[pages[index].dir].window.fireEvent('menuDidClosed');
+ };
_addWindowEvent = function(idx) {
var w;
w = tabs[pages[idx].dir].window;
@@ -43,13 +43,17 @@ Window = (function() {
});
};
menuBtn.addEventListener('click', function(e) {
+ button.touchEnabled = false;
_bubble('showMenu');
});
button.addEventListener('click', function(e) {
var win;
win = new (require("" + dir + "/red2/Window"))(tab);
tab.open(win);
});
+ window.addEventListener('menuDidClosed', function(e) {
+ button.touchEnabled = true;
+ });
window.refresh = refresh;
trace("end constructor");
return window;
@@ -41,13 +41,6 @@ class TabGroup
menuWindow = new (require "#{dir}/menu/Window")()
menuWindow.open()
- maskView = Ti.UI.createView
- width: Ti.UI.FILL
- height: Ti.UI.FILL
- zIndex: 100
- visible: false
-
-
# sh.Shadow tabGroup,
# shadowRadius: 2
# shadowOpacity: 0.6
@@ -60,7 +53,6 @@ class TabGroup
switch e.btype
when 'showMenu'
_toggleOpenMenu()
- maskView.visible = true
when 'didSelectMenu'
nextIndex = e.boptions.index
@@ -72,13 +64,15 @@ class TabGroup
index = nextIndex
else
_switchWindow nextIndex
- maskView.visible = false
+ _menuDidClosed()
return
_toggleOpenMenu = ()->
left = if tabGroup.left < 100 then offsetWidth else 0
tabGroup.animate mix($$.animation, left: left), ()->
- tabGroup.left = left
+ tabGroup.left = left
+ if left is 0
+ _menuDidClosed()
return
return
@@ -89,15 +83,13 @@ class TabGroup
duration: 300
tabGroup.animate a, ()->
- tabs[pages[index].dir].window.remove maskView
d = pages[nextIndex].dir
if typeof tabs[d] is 'undefined'
tabs[d] = Ti.UI.createTab $$.tab
tabs[d].window = new (require "#{dir}/#{pages[nextIndex].dir}/Window")(tabs[d])
tabs[d].window.refresh pages[nextIndex].option
tabGroup.addTab tabs[d]
_addWindowEvent nextIndex
- tabs[d].window.add maskView
tabGroup.setActiveTab tabs[d]
tabGroup.animate mix($$.animation, left: 0), ()->
index = nextIndex
@@ -125,15 +117,18 @@ class TabGroup
touchStarted = false
if tabGroup.left >= 140
tabGroup.animate mix($$.animation, left: offsetWidth), ()->
- maskView.visible = true
tabGroup.left = offsetWidth
return
else
tabGroup.animate mix($$.animation, left: 0), ()->
- maskView.visible = false
tabGroup.left = 0
+ _menuDidClosed()
return
return
+
+ _menuDidClosed = ()->
+ tabs[pages[index].dir].window.fireEvent 'menuDidClosed'
+ return
_addWindowEvent = (idx)->
w = tabs[pages[idx].dir].window
@@ -54,16 +54,19 @@ class Window
# Event Listeners
menuBtn.addEventListener 'click', (e)->
+ button.touchEnabled = false
_bubble 'showMenu'
- # window.touchEnabled = false
- # tab.touchEnabled = false
return
button.addEventListener 'click', (e)->
win = new (require "#{dir}/red2/Window")(tab)
tab.open win
return
+ window.addEventListener 'menuDidClosed', (e) ->
+ button.touchEnabled = true
+ return
+
# Disclose

0 comments on commit 9bcc1ad

Please sign in to comment.