Skip to content

Commit

Permalink
General clean up, fixed a bunch of stuff. Wish I could amend pushed c…
Browse files Browse the repository at this point in the history
…ommits.
  • Loading branch information
Harry Brundage committed Nov 8, 2010
1 parent cf626cd commit 0067969
Show file tree
Hide file tree
Showing 12 changed files with 124 additions and 59 deletions.
18 changes: 9 additions & 9 deletions Resources/app/controllers/splash_controller.coffee
Expand Up @@ -50,17 +50,17 @@ class SplashController extends Citrus.Controller

takeAccountlessActionFromRow: (row, e) ->
action = row.action
action.run(_.bind(this._actionSuccess, this, row), _bind(this._actionFailure, this, row))
action.run(_.bind(this._actionSuccess, this, row), _.bind(this._actionFailure, this, row))

# Gets passed the row object wrapper and the click event for a button in the list of actions.
# Runs the action on the available accounts.
takeActionFromRow: (row, e) ->
takeAccountBasedActionFromRow: (row, e) ->
action = row.action
accounts = this.possibleAccountsForAction(action)

runAction = (account) =>
row.displayInProgress()
action.run(account, _.bind(this._actionSuccess, this, row), _bind(this._actionFailure, this, row))
action.run(account, _.bind(this._actionSuccess, this, row), _.bind(this._actionFailure, this, row))

if accounts.length > 1
# Create a selection popup with options for accounts
Expand All @@ -84,29 +84,29 @@ class SplashController extends Citrus.Controller
# Dialog was canceled, do nothing.
else if e.index == all_index
# All accounts.
Titanium.API.debug("Running on all accounts")
for account in accounts
runAction(account)
else
# Account at index e.index - 2
account = accounts[e.index]
if account?
Titanium.API.debug("Running on account "+account.screenName)
runAction(account)

@dialog.show() # Show the selection dialog
else
# Only one account
d("running on "+accounts[0])
runAction(accounts[0])
return true


# Boolean return if an action can be taken by any of the accounts available
isActionTakeable: (action) ->
_.any @store.accounts, (account) =>
return this._canAccountRunAction(account, action)

if action.requiresAccount()
_.any @store.accounts, (account) =>
return this._canAccountRunAction(account, action)
else
return action.readyToRun()

# List of accounts that can take an action
possibleAccountsForAction: (action) ->
_.select @store.accounts, (account) =>
Expand Down
23 changes: 11 additions & 12 deletions Resources/app/controllers/splash_controller.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Resources/app/models/actions/action.coffee
Expand Up @@ -9,7 +9,6 @@ class Action extends Citrus.Object
if (_.keys(attributes).length == (this.constructor.declares.length + Citrus.Action.alwaysDeclared.length))
@valid = true
for k, v of attributes
d("Trying to set k => "+k.camelize(true)+" to "+v)
k = k.camelize(true) # Camel case the underscored lowercase Rails text
if _.isFunction(this[k])
@valid = (@valid && this[k].call(v))
Expand Down Expand Up @@ -56,8 +55,11 @@ class AccountBasedAction extends Action
success()

Citrus.Action = Action
Citrus.AccountBasedAction = AccountBasedAction
Citrus.AccountlessAction = AccountlessAction

Citrus.Actions = {
Platform: {}
Twitter: {}
Facebook: {}
LinkedIn: {}
Expand Down
4 changes: 3 additions & 1 deletion Resources/app/models/actions/action.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

@@ -0,0 +1,9 @@
class CheckInAction extends Citrus.FoursquareAction
@declares: ["placeId"]
type: "FoursquareCheckInAction"
buttonText: "Check In"

action: (account, success, failure) ->
success()

Citrus.Actions.Foursquare.CheckInAction = CheckInAction
21 changes: 20 additions & 1 deletion Resources/app/models/actions/foursquare/check_in_action.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions Resources/app/models/actions/platform/visit_link_action.coffee
@@ -0,0 +1,10 @@
class VisitLinkAction extends Citrus.PlatformAction
@declares: ["url"]

type: "PlatformVisitLinkAction"
buttonText: "Safari"

action: (success, failure) ->
Titanium.Platform.openURL(@url)

Citrus.Actions.Platform.VisitLinkAction = VisitLinkAction
21 changes: 20 additions & 1 deletion Resources/app/models/actions/platform/visit_link_action.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 15 additions & 13 deletions Resources/app/views/accounts/accounts_table_view_window.coffee
Expand Up @@ -6,50 +6,50 @@ class AccountsTableViewWindow extends Citrus.GenericWindow
@addButton = Titanium.UI.createButton({
systemButton:Titanium.UI.iPhone.SystemButton.ADD,
})

@addButton.addEventListener 'click', =>
controller.addNewAccount()

rows = for a in initialAccounts
a.displayed = true
this._getTableRowFromAccount(a)

@table = Titanium.UI.createTableView({
data: rows
rowHeight: 60
editable: true
})

@win.add(@table)
@win.rightNavButton = @addButton

@loading_indicator = Titanium.UI.createActivityIndicator()
@loading_indicator.style = Titanium.UI.iPhone.ActivityIndicatorStyle.PLAIN
@loading_indicator.font = {
fontFamily: 'Helvetica Neue'
fontSize: 15
fontWeight: 'bold'
}

@loading_indicator.color = 'white'
@loading_indicator.message = 'Loading...'

@table.addEventListener "delete", (e) ->
if e.row.wrapper?
e.row.wrapper.account.fireEvent("state:deleted", e)

showLoading: ->
@win.setToolbar([@loading_indicator],{animated:true})
@loading_indicator.show()
setTimeout( =>
setTimeout( =>
this.hideLoading()
, 3000)

hideLoading: ->
@loading_indicator.hide();
@loading_indicator.hide()
@win.setToolbar(null,{animated:true})
# Adds and registers a displayable account

# Adds and registers a displayable account
displayAccount: (account) ->
account.displayed = true
this._addAccountToTable(account)
Expand All @@ -60,6 +60,8 @@ class AccountsTableViewWindow extends Citrus.GenericWindow
# Adds a displayable account to the tableview
_addAccountToTable: (account) ->
row = this._getTableRowFromAccount(account)
d("Adding row to the table")
d(row)
@table.appendRow(row, {animated:true})

_getTableRowFromAccount: (account) ->
Expand All @@ -71,4 +73,4 @@ class AccountsTableViewWindow extends Citrus.GenericWindow
else
return false

Citrus.AccountsTableViewWindow = AccountsTableViewWindow
Citrus.AccountsTableViewWindow = AccountsTableViewWindow
2 changes: 2 additions & 0 deletions Resources/app/views/accounts/accounts_table_view_window.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 11 additions & 9 deletions Resources/app/views/splash/splash_info_table_view_row.coffee
@@ -1,29 +1,31 @@
class SplashInfoTableViewRow extends Citrus.Object
constructor: (splash) ->
@row = Titanium.UI.createTableViewRow {
height: 80
className: "codeInfoRow"
height: "auto"
}

@splash = splash
@row.object = this

if splash.photo?
text_offset = 70
text_offset = 74
photo = Ti.UI.createImageView {
image: splash.photo
size: {height: 60, width: 60}
top: 5
left: 5
height: 60
width: 60
top: 4
left: 7
}
@row.add(photo)
else
text_offset = 5

title = Ti.UI.createLabel {
color:'#000'
text: splash.name
font:{fontSize:30, fontWeight:'bold'}
top:5
top:4
left:text_offset
height:'auto'
width:'auto'
Expand All @@ -33,9 +35,9 @@ class SplashInfoTableViewRow extends Citrus.Object

description = Ti.UI.createLabel {
color:'#000'
text: splash.description
text: splash.text
font:{fontSize:20, fontWeight:'bold'}
top:45
top:40
left: text_offset
height:'auto'
width:'auto'
Expand All @@ -56,4 +58,4 @@ class SplashInfoTableViewRow extends Citrus.Object
# @row.add(realName)

Citrus.SplashInfoTableViewRow = SplashInfoTableViewRow


0 comments on commit 0067969

Please sign in to comment.