Permalink
Browse files

Merge branch 'develop'

  • Loading branch information...
2 parents 8c59957 + 3f84ef2 commit 4af0568d2fcde60036124bd83c1114cb38a90a6f Harry Brundage committed Nov 28, 2010
Showing with 543 additions and 256 deletions.
  1. +7 −7 Resources/app.js
  2. +24 −0 Resources/app/controllers/code_history_controller.coffee
  3. +37 −0 Resources/app/controllers/code_history_controller.js
  4. +6 −1 Resources/app/controllers/code_reader_controller.coffee
  5. +6 −1 Resources/app/controllers/code_reader_controller.js
  6. 0 Resources/app/controllers/codes.coffee
  7. +0 −3 Resources/app/controllers/codes.js
  8. +2 −2 Resources/app/controllers/controller.coffee
  9. +12 −1 Resources/app/controllers/controller.js
  10. +22 −21 Resources/app/controllers/main.coffee
  11. +4 −3 Resources/app/controllers/main.js
  12. +1 −1 Resources/app/controllers/splash_controller.coffee
  13. +3 −1 Resources/app/controllers/splash_controller.js
  14. +13 −14 Resources/app/models/accounts/account_set.coffee
  15. +10 −11 Resources/app/models/actions/action.coffee
  16. +12 −14 Resources/app/models/actions/action.js
  17. +1 −1 Resources/app/models/actions/platform/visit_link_action.coffee
  18. +1 −1 Resources/app/models/actions/platform/visit_link_action.js
  19. +7 −1 Resources/app/models/splash.coffee
  20. +5 −0 Resources/app/models/splash.js
  21. +48 −0 Resources/app/models/splash_store.coffee
  22. +63 −0 Resources/app/models/splash_store.js
  23. +1 −2 Resources/app/views/accounts/accounts_table_view_window.coffee
  24. +21 −0 Resources/app/views/code_history/code_history_table_view_window.coffee
  25. +36 −0 Resources/app/views/code_history/code_history_table_view_window.js
  26. +0 −7 Resources/app/views/codes/codes_window.coffee
  27. +0 −21 Resources/app/views/codes/codes_window.js
  28. +0 −30 Resources/app/views/splash/splash_loading_window.js
  29. BIN Resources/images/account_icons/go.png
  30. +20 −35 Resources/test.coffee
  31. +76 −45 Resources/vendor/tiajax.coffee
  32. +104 −32 Resources/vendor/tiajax.js
  33. +1 −1 Resources/vendor/underscore.coffee
View
@@ -80,12 +80,12 @@ Ti.include('app/helpers/icons_helper.js');
// Citrus Specific Abstractions
Ti.include("/app/models/observable.js")
-Ti.include('app/models/object.js');
-Ti.include('app/models/persisted_object.js');
-Ti.include('app/views/generic_window.js');
-Ti.include('app/views/placeholder_window.js');
-Ti.include('app/views/data_collection_window.js');
-Ti.include('app/controllers/controller.js');
+Ti.include('/app/models/object.js');
+Ti.include('/app/models/persisted_object.js');
+Ti.include('/app/views/generic_window.js');
+Ti.include('/app/views/placeholder_window.js');
+Ti.include('/app/views/data_collection_window.js');
+Ti.include('/app/controllers/controller.js');
var root = new Citrus.Object(); // Make sure root gets event listeners
-Ti.include('app/controllers/main.js');
+Ti.include('/app/controllers/main.js');
@@ -0,0 +1,24 @@
+Ti.include('/app/views/code_history/code_history_table_view_window.js')
+Ti.include('/app/models/splash_store.js')
+
+class CodeHistoryController extends Citrus.Controller
+ scans: []
+ page: 0
+
+ constructor: () ->
+ d "Code history controller being created"
+ @window = new Citrus.CodeHistoryTableViewWindow(this)
+ @window.win.addEventListener("focus", (e) => this.focused(e))
+
+ focused: (e) ->
+ d "Code history being shown."
+ if @scans.length == 0
+ this.showNextPage()
+
+ showNextPage: () ->
+ @window.showLoading()
+ @window.hideLoading()
+ # Get scans for page and add to scans array
+ # Add new scans to window
+
+Citrus.CodeHistoryController = CodeHistoryController

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -30,7 +30,12 @@ class CodeReaderController extends Citrus.Controller
success: (data) ->
if data?.barcode?
Titanium.Media.vibrate()
- new Citrus.SplashController(data.barcode, root.accountStore)
+ controller = new Citrus.SplashController(data.barcode, root.accountStore)
+ controller.addEventListener "splash:found", (e) ->
+ root.splashStore.addSplash(e.splash)
+
+ controller.tryToShow()
+
cancel: ->
# alert("Canceled")
error: ->

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
No changes.
@@ -1,3 +0,0 @@
-(function() {
-
-}).call(this);
@@ -1,3 +1,3 @@
-class Controller
+class Controller extends Citrus.Object
-Citrus.Controller = Controller
+Citrus.Controller = Controller

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -4,40 +4,41 @@ Ti.include('app/helpers/icons_helper.js')
# Main controllers
Ti.include('app/controllers/accounts_controller.js')
Ti.include('app/controllers/code_reader_controller.js')
-Ti.include('app/views/codes/codes_window.js')
+Ti.include('app/controllers/code_history_controller.js')
-root.tabGroup = Titanium.UI.createTabGroup({barColor:'#336699'})
-Titanium.UI.setBackgroundColor('#000')
+root.tabGroup = Titanium.UI.createTabGroup
+ barColor:'#336699'
+
+Titanium.UI.setBackgroundColor '#000'
# Code Reader tab group
root.CodeReaderController = new Citrus.CodeReaderController()
-codeReaderTab = Titanium.UI.createTab({
- icon:'images/radar.png',
- title:'Scanner',
- window: root.CodeReaderController.window.win
-})
-
+codeReaderTab = Titanium.UI.createTab
+ icon:'images/radar.png',
+ title:'Scanner',
+ window: root.CodeReaderController.window.win
# Accounts List tab group
root.accountStore = new Citrus.AccountSet()
root.AccountsController = new Citrus.AccountsController(root.accountStore)
-accountsTab = Titanium.UI.createTab({
- icon:'images/id-card.png',
- title:'Accounts',
- window: root.AccountsController.window.win
-})
+accountsTab = Titanium.UI.createTab
+ icon:'images/id-card.png',
+ title:'Accounts',
+ window: root.AccountsController.window.win
# Scanned Codes list tab group
-root.CodesWindow = new Citrus.CodesWindow('Codes','No Codes scanned yet.')
-codesTab = Titanium.UI.createTab({
- icon:'images/clock.png',
- title:'Scanned Codes',
- window: root.CodesWindow.win
-})
+root.splashStore = new Citrus.SplashStore()
+root.CodeHistoryController = new Citrus.CodeHistoryController()
+
+codesTab = Titanium.UI.createTab
+ icon:'images/clock.png'
+ title:'Scanned Codes'
+ window: root.CodeHistoryController.window.win
Titanium.include('test.js')
root.tabGroup.addTab(tab) for tab in [codeReaderTab, accountsTab, codesTab]
root.tabGroup.setActiveTab(accountsTab)
-root.tabGroup.open({transition:Titanium.UI.iPhone.AnimationStyle.FLIP_FROM_LEFT})
+root.tabGroup.open
+ transition:Titanium.UI.iPhone.AnimationStyle.FLIP_FROM_LEFT

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -7,7 +7,6 @@ class SplashController extends Citrus.Controller
@window = new Citrus.SplashWindow(this)
root.tabGroup.activeTab.open @window.win, {animated:true}
- this.tryToShow()
tryToShow: () ->
d("Trying to show "+@codeData)
@@ -17,6 +16,7 @@ class SplashController extends Citrus.Controller
d("Found a splash in the decoded data, with shortcode "+splash.shortcode)
@splash = splash
@splash.actions = this._prepareActions(@splash.actions)
+ this.fireEvent "splash:found", {splash:@splash}
@window.displaySplash(@splash)
, (xhr, status, error) =>
e("Error finding a Citrus splash from the decoded data. Status: "+status)

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -1,55 +1,54 @@
class AccountSet extends Citrus.Object
-
+
constructor: () ->
@accounts = []
-
this.load()
-
+
# Loads the account set from the app properties
load: ->
# Ti.API.debug("Loading accounts from : ")
# Ti.API.debug(Ti.App.Properties.getString("CitrusAccounts"))
-
+
return [] unless Ti.App.Properties.hasProperty(this.key())
try
datas = JSON.parse(Ti.App.Properties.getString(this.key()))
catch e
Ti.API.error("Error parsing account set JSON from properties: ")
Ti.API.error(e)
return false
-
+
datas ?= []
accounts = []
for datum in datas
account = Citrus.PersistedObject.loadFromPersistable(datum)
if account
Ti.API.info("Loaded "+account.type+" from persistable.")
accounts.push account
-
+
@accounts = accounts
return @accounts
-
+
# Persists the account set so the app can be closed. Works by serializing the accounts
# to JSON and then saving in the app properties.
- save: ->
+ save: ->
Ti.API.debug("Saving accounts store.")
persistable_accounts = []
for account in @accounts
persistable_accounts.push(account.persistable())
-
-
+
+
return Ti.App.Properties.setString(this.key(), JSON.stringify(persistable_accounts))
-
+
key: ->
return "CitrusAccounts"
addAccount: (account) ->
Ti.API.debug("Account Added to store.")
@accounts.push account
this.save()
-
+
removeAccount: (account) ->
@accounts = _.without(@accounts, account)
this.save()
-
-Citrus.AccountSet = AccountSet
+
+Citrus.AccountSet = AccountSet
@@ -17,18 +17,17 @@ class Action extends Citrus.Object
actionText: ""
constructor: (attributes) ->
- if (_.keys(attributes).length == (this.constructor.declares.length + Citrus.Action.alwaysDeclared.length))
- @valid = true
- for k, v of attributes
- k = k.camelize(true) # Camel case the underscored lowercase Rails text
- if _.isFunction(this[k])
- @valid = (@valid && this[k].call(v))
- else
- this[k] = v
-
- else
+ unless (_.keys(attributes).length == (this.constructor.declares.length + Citrus.Action.alwaysDeclared.length))
Ti.API.debug("Wrong amount of arguments passed to action constructor!")
- @valid = false
+
+ @valid = true
+ for k, v of attributes
+ k = k.camelize(true) # Camel case the underscored lowercase Rails text
+ if _.isFunction(this[k])
+ @valid = (@valid && this[k].call(v))
+ else
+ this[k] = v
+
readyToRun: () ->
return true

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit 4af0568

Please sign in to comment.