Skip to content

Instantly share code, notes, and snippets.

@ryugoo
Created June 27, 2012 04:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryugoo/3001535 to your computer and use it in GitHub Desktop.
Save ryugoo/3001535 to your computer and use it in GitHub Desktop.
Titanium Mobile 用のうすーーーい TabGroup Wrapper
class AppTabGroup
constructor: (glb = globals) ->
@tabGroup = Ti.UI.createTabGroup()
@tabGroup.addEventListener "focus", (e) ->
glb.currentTab = e.tab
return
getTabGroup: () ->
return @tabGroup
appendTab: (param) ->
tab = Ti.UI.createTab param
@tabGroup[param.tabId] = tab if param.tabId? and typeof param.tabId is "string"
@tabGroup.addTab if param.tabId then @tabGroup[param.tabId] else tab
return
open: (defaultTab = 0) ->
@tabGroup.setActiveTab defaultTab
@tabGroup.open()
return
# Modularization
module.exports = AppTabGroup
@ryugoo
Copy link
Author

ryugoo commented Jun 27, 2012

How to use (CoffeeScript)

AppTabGroup = require "AppTabGroup"
tabGroup = new AppTabGroup()
tabGroup.appendTab
    tabId: "tab0" # [String] Tab ID parameter
    title: "Tab"
    window: Ti.UI.createWindow
        title: "Window"
        backgroundColor: "#FFFFFF"
tabGroup.open(0) # [Number] Default tab index (0 start)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment