diff --git a/Resources/app/controllers/splash_controller.coffee b/Resources/app/controllers/splash_controller.coffee index bfab39d..eee3644 100644 --- a/Resources/app/controllers/splash_controller.coffee +++ b/Resources/app/controllers/splash_controller.coffee @@ -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 @@ -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) => diff --git a/Resources/app/controllers/splash_controller.js b/Resources/app/controllers/splash_controller.js index 13b1c3d..0d6c0d8 100644 --- a/Resources/app/controllers/splash_controller.js +++ b/Resources/app/controllers/splash_controller.js @@ -67,15 +67,15 @@ SplashController.prototype.takeAccountlessActionFromRow = function(row, e) { var action; action = row.action; - return action.run(_.bind(this._actionSuccess, this, row), _bind(this._actionFailure, this, row)); + return action.run(_.bind(this._actionSuccess, this, row), _.bind(this._actionFailure, this, row)); }; - SplashController.prototype.takeActionFromRow = function(row, e) { + SplashController.prototype.takeAccountBasedActionFromRow = function(row, e) { var accounts, action, all_index, cancel_index, opts, runAction; action = row.action; accounts = this.possibleAccountsForAction(action); runAction = __bind(function(account) { row.displayInProgress(); - return action.run(account, _.bind(this._actionSuccess, this, row), _bind(this._actionFailure, this, row)); + return action.run(account, _.bind(this._actionSuccess, this, row), _.bind(this._actionFailure, this, row)); }, this); if (accounts.length > 1) { opts = _.map(accounts, function(account) { @@ -98,7 +98,6 @@ if (e.index === cancel_index) { return Titanium.API.debug("Account select dialog was canceled."); } else if (e.index === all_index) { - Titanium.API.debug("Running on all accounts"); _result = []; _ref = accounts; for (_i = 0, _len = _ref.length; _i < _len; _i++) { account = _ref[_i]; @@ -107,23 +106,23 @@ return _result; } else { account = accounts[e.index]; - if (typeof account !== "undefined" && account !== null) { - Titanium.API.debug("Running on account " + account.screenName); - return runAction(account); - } + return (typeof account !== "undefined" && account !== null) ? runAction(account) : null; } }, this)); return this.dialog.show(); } else { - d("running on " + accounts[0]); runAction(accounts[0]); return true; } }; SplashController.prototype.isActionTakeable = function(action) { - return _.any(this.store.accounts, __bind(function(account) { - return this._canAccountRunAction(account, action); - }, this)); + if (action.requiresAccount()) { + return _.any(this.store.accounts, __bind(function(account) { + return this._canAccountRunAction(account, action); + }, this)); + } else { + return action.readyToRun(); + } }; SplashController.prototype.possibleAccountsForAction = function(action) { return _.select(this.store.accounts, __bind(function(account) { diff --git a/Resources/app/models/actions/action.coffee b/Resources/app/models/actions/action.coffee index 90540db..71a5616 100644 --- a/Resources/app/models/actions/action.coffee +++ b/Resources/app/models/actions/action.coffee @@ -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)) @@ -56,8 +55,11 @@ class AccountBasedAction extends Action success() Citrus.Action = Action +Citrus.AccountBasedAction = AccountBasedAction +Citrus.AccountlessAction = AccountlessAction Citrus.Actions = { + Platform: {} Twitter: {} Facebook: {} LinkedIn: {} diff --git a/Resources/app/models/actions/action.js b/Resources/app/models/actions/action.js index 49921ba..3b50285 100644 --- a/Resources/app/models/actions/action.js +++ b/Resources/app/models/actions/action.js @@ -16,7 +16,6 @@ for (k in _ref) { if (!__hasProp.call(_ref, k)) continue; v = _ref[k]; - d("Trying to set k => " + k.camelize(true) + " to " + v); k = k.camelize(true); if (_.isFunction(this[k])) { this.valid = (this.valid && this[k].call(v)); @@ -72,7 +71,10 @@ return success(); }; Citrus.Action = Action; + Citrus.AccountBasedAction = AccountBasedAction; + Citrus.AccountlessAction = AccountlessAction; Citrus.Actions = { + Platform: {}, Twitter: {}, Facebook: {}, LinkedIn: {}, diff --git a/Resources/app/models/actions/foursquare/check_in_action.coffee b/Resources/app/models/actions/foursquare/check_in_action.coffee index e69de29..cd9326d 100644 --- a/Resources/app/models/actions/foursquare/check_in_action.coffee +++ b/Resources/app/models/actions/foursquare/check_in_action.coffee @@ -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 diff --git a/Resources/app/models/actions/foursquare/check_in_action.js b/Resources/app/models/actions/foursquare/check_in_action.js index f5e757a..fa3314c 100644 --- a/Resources/app/models/actions/foursquare/check_in_action.js +++ b/Resources/app/models/actions/foursquare/check_in_action.js @@ -1,3 +1,22 @@ (function() { - + var CheckInAction; + var __extends = function(child, parent) { + var ctor = function(){}; + ctor.prototype = parent.prototype; + child.prototype = new ctor(); + child.prototype.constructor = child; + if (typeof parent.extended === "function") parent.extended(child); + child.__super__ = parent.prototype; + }; + CheckInAction = function() { + return Citrus.FoursquareAction.apply(this, arguments); + }; + __extends(CheckInAction, Citrus.FoursquareAction); + CheckInAction.declares = ["placeId"]; + CheckInAction.prototype.type = "FoursquareCheckInAction"; + CheckInAction.prototype.buttonText = "Check In"; + CheckInAction.prototype.action = function(account, success, failure) { + return success(); + }; + Citrus.Actions.Foursquare.CheckInAction = CheckInAction; }).call(this); diff --git a/Resources/app/models/actions/platform/visit_link_action.coffee b/Resources/app/models/actions/platform/visit_link_action.coffee index e69de29..cb3d4a2 100644 --- a/Resources/app/models/actions/platform/visit_link_action.coffee +++ b/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 diff --git a/Resources/app/models/actions/platform/visit_link_action.js b/Resources/app/models/actions/platform/visit_link_action.js index f5e757a..dbf3c61 100644 --- a/Resources/app/models/actions/platform/visit_link_action.js +++ b/Resources/app/models/actions/platform/visit_link_action.js @@ -1,3 +1,22 @@ (function() { - + var VisitLinkAction; + var __extends = function(child, parent) { + var ctor = function(){}; + ctor.prototype = parent.prototype; + child.prototype = new ctor(); + child.prototype.constructor = child; + if (typeof parent.extended === "function") parent.extended(child); + child.__super__ = parent.prototype; + }; + VisitLinkAction = function() { + return Citrus.PlatformAction.apply(this, arguments); + }; + __extends(VisitLinkAction, Citrus.PlatformAction); + VisitLinkAction.declares = ["url"]; + VisitLinkAction.prototype.type = "PlatformVisitLinkAction"; + VisitLinkAction.prototype.buttonText = "Safari"; + VisitLinkAction.prototype.action = function(success, failure) { + return Titanium.Platform.openURL(this.url); + }; + Citrus.Actions.Platform.VisitLinkAction = VisitLinkAction; }).call(this); diff --git a/Resources/app/views/accounts/accounts_table_view_window.coffee b/Resources/app/views/accounts/accounts_table_view_window.coffee index 71b0ffa..011627a 100644 --- a/Resources/app/views/accounts/accounts_table_view_window.coffee +++ b/Resources/app/views/accounts/accounts_table_view_window.coffee @@ -6,23 +6,23 @@ 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 = { @@ -30,26 +30,26 @@ class AccountsTableViewWindow extends Citrus.GenericWindow 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) @@ -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) -> @@ -71,4 +73,4 @@ class AccountsTableViewWindow extends Citrus.GenericWindow else return false -Citrus.AccountsTableViewWindow = AccountsTableViewWindow \ No newline at end of file +Citrus.AccountsTableViewWindow = AccountsTableViewWindow diff --git a/Resources/app/views/accounts/accounts_table_view_window.js b/Resources/app/views/accounts/accounts_table_view_window.js index 9c0c764..e458bf4 100644 --- a/Resources/app/views/accounts/accounts_table_view_window.js +++ b/Resources/app/views/accounts/accounts_table_view_window.js @@ -82,6 +82,8 @@ AccountsTableViewWindow.prototype._addAccountToTable = function(account) { var row; row = this._getTableRowFromAccount(account); + d("Adding row to the table"); + d(row); return this.table.appendRow(row, { animated: true }); diff --git a/Resources/app/views/splash/splash_info_table_view_row.coffee b/Resources/app/views/splash/splash_info_table_view_row.coffee index 3a34cca..d7e1d66 100644 --- a/Resources/app/views/splash/splash_info_table_view_row.coffee +++ b/Resources/app/views/splash/splash_info_table_view_row.coffee @@ -1,21 +1,23 @@ 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 @@ -23,7 +25,7 @@ class SplashInfoTableViewRow extends Citrus.Object color:'#000' text: splash.name font:{fontSize:30, fontWeight:'bold'} - top:5 + top:4 left:text_offset height:'auto' width:'auto' @@ -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' @@ -56,4 +58,4 @@ class SplashInfoTableViewRow extends Citrus.Object # @row.add(realName) Citrus.SplashInfoTableViewRow = SplashInfoTableViewRow - \ No newline at end of file + diff --git a/Resources/app/views/splash/splash_info_table_view_row.js b/Resources/app/views/splash/splash_info_table_view_row.js index febf447..54f89e8 100644 --- a/Resources/app/views/splash/splash_info_table_view_row.js +++ b/Resources/app/views/splash/splash_info_table_view_row.js @@ -11,22 +11,21 @@ SplashInfoTableViewRow = function(splash) { var _ref, description, photo, text_offset, title; this.row = Titanium.UI.createTableViewRow({ - height: 80, - className: "codeInfoRow" + className: "codeInfoRow", + height: "auto" }); this.splash = splash; this.row.object = this; if (typeof (_ref = splash.photo) !== "undefined" && _ref !== null) { - 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 }); + this.row.add(photo); } else { text_offset = 5; } @@ -37,7 +36,7 @@ fontSize: 30, fontWeight: 'bold' }, - top: 5, + top: 4, left: text_offset, height: 'auto', width: 'auto' @@ -45,12 +44,12 @@ this.row.add(title); 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'