Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add titanium client

  • Loading branch information...
commit 1210492b7cdafe96a10ce1ebab3090cd6f4fb5bd 1 parent c358051
@jenniferb jenniferb authored
Showing with 106,698 additions and 1 deletion.
  1. +0 −1  .gitignore
  2. +2 −0  mobile/titanium/FMS/.gitignore
  3. +23 −0 mobile/titanium/FMS/.project
  4. +1 −0  mobile/titanium/FMS/CHANGELOG.txt
  5. +219 −0 mobile/titanium/FMS/LICENSE
  6. +1 −0  mobile/titanium/FMS/LICENSE.txt
  7. +18 −0 mobile/titanium/FMS/README
  8. BIN  mobile/titanium/FMS/Resources/FMSdb.sqlite
  9. BIN  mobile/titanium/FMS/Resources/KS_nav_ui.png
  10. BIN  mobile/titanium/FMS/Resources/KS_nav_views.png
  11. BIN  mobile/titanium/FMS/Resources/android/appicon.png
  12. BIN  mobile/titanium/FMS/Resources/android/default.png
  13. BIN  mobile/titanium/FMS/Resources/android/images/res-long-land-hdpi/default.png
  14. BIN  mobile/titanium/FMS/Resources/android/images/res-long-land-ldpi/default.png
  15. BIN  mobile/titanium/FMS/Resources/android/images/res-long-port-hdpi/default.png
  16. BIN  mobile/titanium/FMS/Resources/android/images/res-long-port-ldpi/default.png
  17. BIN  mobile/titanium/FMS/Resources/android/images/res-notlong-land-hdpi/default.png
  18. BIN  mobile/titanium/FMS/Resources/android/images/res-notlong-land-ldpi/default.png
  19. BIN  mobile/titanium/FMS/Resources/android/images/res-notlong-land-mdpi/default.png
  20. BIN  mobile/titanium/FMS/Resources/android/images/res-notlong-port-hdpi/default.png
  21. BIN  mobile/titanium/FMS/Resources/android/images/res-notlong-port-ldpi/default.png
  22. BIN  mobile/titanium/FMS/Resources/android/images/res-notlong-port-mdpi/default.png
  23. +254 −0 mobile/titanium/FMS/Resources/app.js
  24. BIN  mobile/titanium/FMS/Resources/images/BUTT_grn_off.png
  25. BIN  mobile/titanium/FMS/Resources/images/appcelerator_small.png
  26. BIN  mobile/titanium/FMS/Resources/images/disclosure.png
  27. BIN  mobile/titanium/FMS/Resources/images/icon_about.png
  28. BIN  mobile/titanium/FMS/Resources/images/icon_camera.png
  29. BIN  mobile/titanium/FMS/Resources/images/icon_new.png
  30. BIN  mobile/titanium/FMS/Resources/images/icon_settings.png
  31. BIN  mobile/titanium/FMS/Resources/images/icon_view.png
  32. BIN  mobile/titanium/FMS/Resources/images/map-pin-green.png
  33. BIN  mobile/titanium/FMS/Resources/images/map-pin-red.png
  34. BIN  mobile/titanium/FMS/Resources/images/target.png
  35. BIN  mobile/titanium/FMS/Resources/images/target2.png
  36. BIN  mobile/titanium/FMS/Resources/images/target_32.png
  37. +154 −0 mobile/titanium/FMS/Resources/images/where.js
  38. BIN  mobile/titanium/FMS/Resources/iphone/Default-Landscape.png
  39. BIN  mobile/titanium/FMS/Resources/iphone/Default-Portrait.png
  40. BIN  mobile/titanium/FMS/Resources/iphone/Default.png
  41. BIN  mobile/titanium/FMS/Resources/iphone/Default@2x.png
  42. BIN  mobile/titanium/FMS/Resources/iphone/appicon.png
  43. +11 −0 mobile/titanium/FMS/Resources/js/about.js
  44. +43 −0 mobile/titanium/FMS/Resources/js/defs/settings_def.js
  45. +436 −0 mobile/titanium/FMS/Resources/js/fmsapi.js
  46. +147 −0 mobile/titanium/FMS/Resources/js/settings.js
  47. +687 −0 mobile/titanium/FMS/Resources/js/utils/form.js
  48. +62 −0 mobile/titanium/FMS/Resources/js/utils/sliding_edit_view.js
  49. +30 −0 mobile/titanium/FMS/Resources/js/utils/win_wrapper.js
  50. +161 −0 mobile/titanium/FMS/Resources/js/views/addphotoform.js
  51. +216 −0 mobile/titanium/FMS/Resources/js/views/newreportform.js
  52. +117 −0 mobile/titanium/FMS/Resources/js/views/setidform.js
  53. 0  mobile/titanium/FMS/Resources/js/windows/loadingprompt.js
  54. +42 −0 mobile/titanium/FMS/Resources/js/windows/mapprompt.js
  55. +230 −0 mobile/titanium/FMS/Resources/js/windows/nearby2.js
  56. +33 −0 mobile/titanium/FMS/Resources/js/windows/newreport3.js
  57. 0  mobile/titanium/FMS/Resources/js/windows/photochooser.js
  58. +134 −0 mobile/titanium/FMS/Resources/js/windows/setid.js
  59. +103,630 −0 mobile/titanium/FMS/api.jsca
  60. +8 −0 mobile/titanium/FMS/manifest
  61. +39 −0 mobile/titanium/FMS/tiapp.xml
View
1  .gitignore
@@ -1,3 +1,2 @@
*.pyc
-.gitignore
local_settings.py
View
2  mobile/titanium/FMS/.gitignore
@@ -0,0 +1,2 @@
+build.log
+build/**/*
View
23 mobile/titanium/FMS/.project
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>titanium-fms</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>com.appcelerator.titanium.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.aptana.ide.core.unifiedBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>com.appcelerator.titanium.mobile.nature</nature>
+ <nature>com.aptana.projects.webnature</nature>
+ </natures>
+</projectDescription>
View
1  mobile/titanium/FMS/CHANGELOG.txt
@@ -0,0 +1 @@
+Place your change log text here. This file will be incorporated with your app at package time.
View
219 mobile/titanium/FMS/LICENSE
@@ -0,0 +1,219 @@
+Copyright 2009 Appcelerator, Inc.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ (or the full text of the license is below)
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+END OF TERMS AND CONDITIONS
+
+APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+Copyright [yyyy] [name of copyright owner]
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
View
1  mobile/titanium/FMS/LICENSE.txt
@@ -0,0 +1 @@
+Place your license text here. This file will be incorporated with your app at package time.
View
18 mobile/titanium/FMS/README
@@ -0,0 +1,18 @@
+Welcome to your Appcelerator Titanium Mobile Project
+
+This is a blank project. Start by editing your application's app.js to
+make your first mobile project using Titanium.
+
+
+
+----------------------------------
+Stuff our legal folk make us say:
+
+Appcelerator, Appcelerator Titanium and associated marks and logos are
+trademarks of Appcelerator, Inc.
+
+Titanium is Copyright (c) 2009-2010 by Appcelerator, Inc. All Rights Reserved.
+
+Titanium is licensed under the Apache Public License (Version 2). Please
+see the LICENSE file for the full license.
+
View
BIN  mobile/titanium/FMS/Resources/FMSdb.sqlite
Binary file not shown
View
BIN  mobile/titanium/FMS/Resources/KS_nav_ui.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  mobile/titanium/FMS/Resources/KS_nav_views.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  mobile/titanium/FMS/Resources/android/appicon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  mobile/titanium/FMS/Resources/android/default.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  mobile/titanium/FMS/Resources/android/images/res-long-land-hdpi/default.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  mobile/titanium/FMS/Resources/android/images/res-long-land-ldpi/default.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  mobile/titanium/FMS/Resources/android/images/res-long-port-hdpi/default.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  mobile/titanium/FMS/Resources/android/images/res-long-port-ldpi/default.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  mobile/titanium/FMS/Resources/android/images/res-notlong-land-hdpi/default.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  mobile/titanium/FMS/Resources/android/images/res-notlong-land-ldpi/default.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  mobile/titanium/FMS/Resources/android/images/res-notlong-land-mdpi/default.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  mobile/titanium/FMS/Resources/android/images/res-notlong-port-hdpi/default.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  mobile/titanium/FMS/Resources/android/images/res-notlong-port-ldpi/default.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  mobile/titanium/FMS/Resources/android/images/res-notlong-port-mdpi/default.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
254 mobile/titanium/FMS/Resources/app.js
@@ -0,0 +1,254 @@
+Titanium.include('js/fmsapi.js');
+Titanium.include('js/windows/setid.js');
+Titanium.include('js/windows/mapprompt.js');
+
+var isAndroid = (Titanium.Platform.name == 'android');
+var winId = null;
+var isLoading = false;
+
+// this sets the background color of the master UIView (when there are no windows/tab groups on it)
+Titanium.UI.setBackgroundColor('#000');
+
+Titanium.App.Properties.setString('CurrentLocation', '');
+Titanium.App.Properties.setString('LocationData', '');
+Titanium.App.Properties.setString('TargetLocation', '');
+Titanium.App.Properties.setBool('IdSet', false);
+
+var db = Titanium.Database.open('FMSdb.sqlite');
+//db.execute('drop table reports;');
+db.execute('CREATE TABLE IF NOT EXISTS categories (id INTEGER PRIMARY KEY, name VARCHAR(100) NOT NULL, group_name VARCHAR(32) not null, hint_text VARCHAR(250))');
+db.execute('CREATE TABLE IF NOT EXISTS reports (id INTEGER PRIMARY KEY, category integer, title VARCHAR(64) NOT NULL, lat REAL NOT NULL, lon REAL NOT NULL, desc VARCHAR(250), is_fixed INTEGER)');
+db.close();
+
+// create tab group
+var tabGroup = Titanium.UI.createTabGroup();
+
+var winNearby = Titanium.UI.createWindow({
+ url: 'js/windows/nearby2.js',
+ title:'Nearby',
+ backgroundColor:'#fff'
+});
+
+
+var tabViewReports = Titanium.UI.createTab({
+ icon:'images/icon_view.png',
+ title:'Nearby',
+ window: winNearby
+});
+
+var winNewReports = Titanium.UI.createWindow({
+ url: 'js/windows/newreport3.js',
+ title:'New Report',
+ backgroundColor:'#fff'
+});
+
+
+
+var tabNewReport = Titanium.UI.createTab({
+ icon:'images/icon_new.png',
+ title:'New Report',
+ window: winNewReports
+});
+
+
+var winAbout = Titanium.UI.createWindow({
+ url: 'js/about.js',
+ title:'About',
+ backgroundColor:'#fff'
+});
+
+var tabAbout = Titanium.UI.createTab({
+ icon:'images/icon_about.png',
+ title:'About',
+ window:winAbout
+});
+
+var winSettings = Titanium.UI.createWindow({
+ url: 'js/settings.js',
+ title:'Settings',
+ backgroundColor:'#fff'
+});
+
+var tabSettings = Titanium.UI.createTab({
+ icon:'images/icon_settings.png',
+ title:'Settings',
+ window:winSettings
+});
+
+var noConnectionAlert = Titanium.UI.createAlertDialog({
+ title:'No network connection detected.',
+ buttonNames:['Try again.']
+});
+
+function onNetworkEvent(e)
+{
+ if ( ! Titanium.Network.online )
+ {
+ noConnectionAlert.show();
+ }
+};
+
+
+var loadingWindow = Titanium.UI.createWindow({
+ touchEnabled:false,
+ backgroundColor:'#000',
+ height:70,
+ borderRadius:10,
+ width:300,
+ bottom:200,
+ opacity: isAndroid ? 0 : 0.7,
+});
+
+
+var loadingInd = Titanium.UI.createActivityIndicator({
+ textAlign: 'center',
+ height:50,
+ color: '#fff',
+ message: 'Looking up location....',
+ style:Titanium.UI.iPhone.ActivityIndicatorStyle.PLAIN
+});
+
+var promptWin = new MapPrompt();
+
+function showPrompt()
+{
+ Titanium.API.info("NEARBY: showing prompt" );
+ promptWin.open();
+
+ setTimeout(function()
+ {
+ promptWin.close({opacity:0,duration:500});
+ Titanium.API.info("NEARBY: done showing prompt" );
+ },2000);
+
+}
+
+
+loadingWindow.add(loadingInd);
+
+function onLoadingStart( e )
+{
+ isLoading = true;
+ promptWin.close();
+ loadingInd.message = e.text;
+ loadingWindow.open();
+ loadingInd.show();
+ tabGroup.touchEnabled = false;
+}
+
+function onLoadingEnd( e )
+{
+ if( e.text == loadingInd.message )
+ {
+ loadingInd.hide();
+ loadingWindow.close();
+ }
+ isLoading = false;
+ tabGroup.touchEnabled = true;
+
+}
+
+function onRequestTabChange( e )
+{
+ tabGroup.setActiveTab( e.tab );
+}
+
+function onIdSet( e )
+{
+ Titanium.API.info("APP: onIdSet");
+ tabGroup.addTab(tabSettings);
+}
+
+function onFMSError( locationData )
+{
+ Titanium.API.info("APP: on FMS error" );
+
+ tabGroup.setActiveTab( 0 );
+ var alertDialog = Titanium.UI.createAlertDialog({
+ title: 'Oops.',
+ message: locationData.error_text,
+ buttonNames: ['OK']
+ });
+ alertDialog.show();
+}
+
+function onFMSResolveEnd( e )
+{
+ if( e.status != FMS_SUCCESS )
+ {
+ onFMSError(e);
+ if( e.status == FMS_SERVER_ERROR )
+ {
+// Titanium.API.info("APP: exiting app?");
+// Titanium.App.exit();
+ }
+ }
+ else
+ {
+ if( tabGroup.activeTab.window.title == "Nearby")
+ {
+ showPrompt();
+ }
+ }
+}
+
+function onTabFocus( e )
+{
+ Titanium.API.info("APP: onTabFocus index=" + e.index );
+// Titanium.App.fireEvent('app_tab_changed', e);
+ var locationData = FMSApi.getResolvedLocation();
+
+ if( e.index == 0 )
+ {
+ if( ! isLoading )
+ {
+ if ( locationData.status == FMS_SUCCESS )
+ {
+ showPrompt();
+ }
+ }
+ }
+ else
+ {
+ promptWin.close();
+ if( e.index == 1 )
+ {
+ if( locationData.status != null && locationData.status != FMS_SUCCESS )
+ {
+ Titanium.API.info("APP: FMS error detected.");
+ onFMSError( locationData );
+ }
+ }
+ }
+ Titanium.API.info("APP: onTabFocus index=" + e.index + " complete ");
+
+}
+
+//
+// add tabs
+//
+tabGroup.addTab(tabViewReports);
+tabGroup.addTab(tabNewReport);
+tabGroup.addTab(tabAbout);
+
+if( Titanium.App.Properties.getBool('IdSet') )
+{
+ tabGroup.addTab(tabSettings);
+}
+
+Titanium.Network.addEventListener('change',onNetworkEvent);
+noConnectionAlert.addEventListener('click',onNetworkEvent);
+tabGroup.addEventListener('focus', onTabFocus );
+
+
+Titanium.App.addEventListener('app_loading_start',onLoadingStart);
+Titanium.App.addEventListener('app_id_set',onIdSet);
+Titanium.App.addEventListener('app_loading_end',onLoadingEnd);
+Titanium.App.addEventListener('app_request_tabchange',onRequestTabChange);
+Titanium.App.addEventListener('location_resolved',onFMSResolveEnd);
+
+onNetworkEvent(null);
+
+tabGroup.open();
+
+
View
BIN  mobile/titanium/FMS/Resources/images/BUTT_grn_off.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  mobile/titanium/FMS/Resources/images/appcelerator_small.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  mobile/titanium/FMS/Resources/images/disclosure.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  mobile/titanium/FMS/Resources/images/icon_about.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  mobile/titanium/FMS/Resources/images/icon_camera.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  mobile/titanium/FMS/Resources/images/icon_new.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  mobile/titanium/FMS/Resources/images/icon_settings.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  mobile/titanium/FMS/Resources/images/icon_view.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  mobile/titanium/FMS/Resources/images/map-pin-green.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  mobile/titanium/FMS/Resources/images/map-pin-red.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  mobile/titanium/FMS/Resources/images/target.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  mobile/titanium/FMS/Resources/images/target2.png
Diff not rendered
View
BIN  mobile/titanium/FMS/Resources/images/target_32.png
Diff not rendered
View
154 mobile/titanium/FMS/Resources/images/where.js
@@ -0,0 +1,154 @@
+
+var win = Ti.UI.currentWindow;
+var isAndroid = false;
+var locationData = null;
+var mapView = null;
+
+if (Titanium.Platform.name == 'android') {
+ isAndroid = true;
+}
+
+Titanium.include('what.js');
+
+var selectButtonBar = Titanium.UI.createButtonBar({
+ labels:['Use Current Location']
+});
+
+var flexSpace = Titanium.UI.createButton({
+ systemButton:Titanium.UI.iPhone.SystemButton.FLEXIBLE_SPACE
+});
+
+var backButton = Ti.UI.createButton({
+ title:'Back'
+});
+
+backButton.addEventListener('click', function(){
+ win.remove(scrollView);
+ win.add(mapview);
+ win.setToolbar([selectButtonBar]);
+ win.leftNavButton = null;
+});
+
+selectButtonBar.addEventListener('click', function(e)
+{
+ win.setToolbar([]);
+ win.remove(mapview);
+ win.add(scrollView);
+ win.leftNavButton = backButton;
+});
+
+var loadingToolbar = Titanium.UI.createActivityIndicator();
+loadingToolbar.style = Titanium.UI.iPhone.ActivityIndicatorStyle.PLAIN;
+loadingToolbar.font = {fontFamily:'Helvetica Neue', fontSize:15,fontWeight:'bold'};
+loadingToolbar.color = 'white';
+loadingToolbar.message = 'Confirmimg location...';
+
+var promptWin = Titanium.UI.createWindow({
+ height:30,
+ width:250,
+ bottom:70,
+ borderRadius:10,
+ touchEnabled:false,
+
+ orientationModes : [
+ Titanium.UI.PORTRAIT,
+ Titanium.UI.UPSIDE_PORTRAIT,
+ Titanium.UI.LANDSCAPE_LEFT,
+ Titanium.UI.LANDSCAPE_RIGHT
+ ]
+});
+
+var promptView = Titanium.UI.createView({
+ id:'messageview',
+ height:30,
+ width:250,
+ borderRadius:10,
+ backgroundColor:'#000',
+ opacity:0.7,
+ touchEnabled:false
+});
+
+var promptLabel = Titanium.UI.createLabel({
+ id:'messagelabel',
+ text:'Double-tap map to move pin.',
+ color:'#fff',
+ width:250,
+ height:'auto',
+ font:{
+ fontFamily:'Helvetica Neue',
+ fontSize:13
+ },
+ textAlign:'center'
+});
+
+promptWin.add(promptView);
+promptWin.add(promptLabel);
+
+function drawMap(lat, lon)
+{
+ mapview = Titanium.Map.createView({
+ mapType: Titanium.Map.STANDARD_TYPE,
+ region: {latitude:lat, longitude:lon,
+ latitudeDelta:0.01, longitudeDelta:0.01},
+ animate:false,
+ regionFit:true,
+ userLocation:true
+ });
+ win.add(mapview);
+
+ var currentLocation = Titanium.Map.createAnnotation({
+ latitude:lat,
+ longitude:lon,
+ title:"Here",
+ pincolor: isAndroid ? "orange" : Titanium.Map.ANNOTATION_RED,
+ animate:true,
+ myid:1 // CUSTOM ATTRIBUTE THAT IS PASSED INTO EVENT OBJECTS
+ });
+ mapview.addAnnotation(currentLocation);
+
+}
+
+function onResolvingLocation( coords )
+{
+ drawMap( coords.latitude, coords.longitude);
+}
+
+
+function onLocationResolved( e )
+{
+ var locationData = JSON.parse(Titanium.App.Properties.getString('LocationData'));
+ loadingToolbar.hide();
+ Titanium.API.info(JSON.stringify(locationData.categories));
+ setCategoryOptions(locationData.categories);
+ win.setToolbar([selectButtonBar]);
+}
+
+
+
+Titanium.App.addEventListener('resolving_location',onResolvingLocation);
+Titanium.App.addEventListener('location_resolved',onLocationResolved);
+
+var currentLocationString = Titanium.App.Properties.getString('CurrentLocation');
+
+if (currentLocationString == '') {
+ win.setToolbar([loadingToolbar],{animated:true});
+ loadingToolbar.show();
+}
+else {
+ Titanium.API.info(currentLocationString);
+ var currentLocation = JSON.parse(currentLocationString);
+ var locationDataString = Titanium.App.Properties.getString('LocationData');
+ if (locationDataString == '') {
+ drawMap(currentLocation.latitude, currentLocation.longitude);
+ win.setToolbar([loadingToolbar],{animated:true});
+ loadingToolbar.show();
+ }
+ else {
+ var locationData = JSON.parse(locationDataString);
+ drawMap(locationData.lat, locationData.lon);
+ setCategoryOptions(locationData.categories);
+ win.setToolbar([selectButtonBar]);
+ }
+}
+
+
View
BIN  mobile/titanium/FMS/Resources/iphone/Default-Landscape.png
Diff not rendered
View
BIN  mobile/titanium/FMS/Resources/iphone/Default-Portrait.png
Diff not rendered
View
BIN  mobile/titanium/FMS/Resources/iphone/Default.png
Diff not rendered
View
BIN  mobile/titanium/FMS/Resources/iphone/Default@2x.png
Diff not rendered
View
BIN  mobile/titanium/FMS/Resources/iphone/appicon.png
Diff not rendered
View
11 mobile/titanium/FMS/Resources/js/about.js
@@ -0,0 +1,11 @@
+var win = Ti.UI.currentWindow;
+
+var label1 = Titanium.UI.createLabel({
+ color:'#999',
+ text:'I am ABOUT window',
+ font:{fontSize:20,fontFamily:'Helvetica Neue'},
+ textAlign:'center',
+ width:'auto'
+});
+
+win.add(label1);
View
43 mobile/titanium/FMS/Resources/js/defs/settings_def.js
@@ -0,0 +1,43 @@
+
+
+var SETTINGS = [ { id: 'name',
+ label:'Name',
+ keypad: Titanium.UI.KEYBOARD_DEFAULT },
+ { id: 'phone',
+ label:'Phone',
+ keypad: Titanium.UI.KEYBOARD_PHONE_PAD,
+ format : function( e )
+ {
+ val = e.source.value;
+ Titanium.API.info("format phone:" + val );
+ val = val.replace(/^(\d)/,"($1");
+ val = val.replace(/^(\(\d{3})([^\)]) */,"$1) $2");
+ val = val.replace(/^(\(\d{3}\) \d{3})([^-])/,"$1-$2");
+ val = val.replace(/^(\(\d{3}\) \d{3}-\d{4}).*/,"$1");
+ e.source.value = val;
+ },
+ validate : function( val )
+ {
+ var regEx = /^\(\d{3}\) \d{3}-\d{4}$/i;
+ var error = null;
+ if (val.search(regEx) == -1) {
+ error = "Please enter a valid 10 digit phone number.";
+ }
+ return( error );
+ },
+ },
+ {
+ id: 'email',
+ label:'Email',
+ keypad: Titanium.UI.KEYBOARD_EMAIL,
+ validate : function( val )
+ {
+ var emailRegEx = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i;
+ var error = null;
+ if (val.search(emailRegEx) == -1) {
+ error = "Please enter a valid email address.";
+ }
+ return( error );
+ },
+
+ } ];
View
436 mobile/titanium/FMS/Resources/js/fmsapi.js
@@ -0,0 +1,436 @@
+
+DEBUG = true;
+DEBUG_URL = "http://technoutopians.com/";
+FMS_SUCCESS = 0;
+FMS_LOCATION_NOT_SUPPORTED = 1;
+FMS_SERVER_ERROR = 2;
+FMS_LOADING_MSG = 'Looking up location....';
+
+function resolve_status_text(status)
+{
+ switch( status )
+ {
+ case FMS_SUCCESS: return('');
+ case FMS_SERVER_ERROR: return( 'Could not communicate with server at FixMyStreet.ca. Please try again later.')
+ case FMS_LOCATION_NOT_SUPPORTED: return('Location not supported by FixMyStreet.ca')
+ }
+}
+
+function send_status_text(status)
+{
+ switch( status )
+ {
+ case FMS_SUCCESS:
+ var email = Titanium.App.Properties.getString('Email');
+ return('Thanks for submitting your report to FixMyStreet.ca. A confirmation email has been sent to ' + email + '.' );
+ case FMS_SERVER_ERROR: return( 'Could not communicate with server at FixMyStreet.ca. Please try again later.')
+ }
+}
+
+
+function InitLocationData( status, lat, lon )
+{
+ var data = { latitude: lat,
+ longitude: lon,
+ status: status,
+ error_text: resolve_status_text(status) };
+ return( data );
+};
+
+//----------------------------------------------------------------------------------
+// Mock API Used in Debugging
+//----------------------------------------------------------------------------------
+
+
+var DEBUG_LAT = 45.4095879999999994;
+var DEBUG_LON = -75.7102699999999942;
+
+function DebugFMSApi()
+{
+
+ this.resolveCount = 0;
+ this.sendCount = 0;
+ this.reports = [
+ {
+ "service_request_id":20,
+ "service_code": 6,
+ "title": "Tagging - 314 Booth",
+ "lon": -75.7102699999999942,
+ "lat": 45.4065879999999994,
+ "status": true,
+ "desc": "Tagging has appeared on North facing construction barriers at the site at 314 Booth St at Eccles St. \r\n\r\nThe graffiti at 300 Booth is still there on the South wall, facing the barriers mentioned above"
+ },
+ {
+ "service_request_id": 21,
+ "service_code": 9,
+ "title": "Large Pothole (Utility Cut Sinking)",
+ "lon": -75.6870889663999975,
+ "lat": 45.4043333270000034,
+ "status": false,
+ "desc": "The utility road cut in front of 77 2nd Ave is sinking, resulting in a pothole that is approx 3-4 inches at its deepest and runs almost the width of the street. Due to the nature of the cut, when traveling east on 2nd Ave, vehicles actually hit the \"knife\"/step like edge of the road cut. During rain, this pothole catches water and creates a small lake that does not drain. The result is that passing cars splash water approx. 8-10 feet in the air and wet pedestrians on both sides of the road."
+ },
+ {
+ "service_request_id": 22,
+ "service_code": 6,
+ "title": "Tagging - side of 752 Somerset St W",
+ "lon":-75.7081880000000069,
+ "lat": 45.4104239999999990,
+ "status": false,
+ "desc": "Tagging on side of 752 Somerset St W, at the corner of Bell St N. The tagging is on the Bell St side"
+ }
+ ];
+ this.categories = [ { 'service_code': 20, 'service_name' : 'Branches Blocking Signs or Intersection', 'group':'Trees' },
+ { 'service_code':6, 'service_name' :'Graffiti on Private Property', 'group':'Grafitti' },
+ { 'service_code':5, 'service_name' : 'Graffiti On City Property', 'group':'Grafitti' },
+ { 'service_code':7,'service_name':'Graffiti on Utility Boxes/Transformers/Mailboxes', 'group':'Grafitti' },
+ { 'service_code':15, 'service_name': 'Bus Shelter Damaged', 'group':'Roads/Sidewalks/Pathways' },
+{ 'service_code':16, 'service_name': 'Debris/Litter in Bus Shelter', 'group':'Roads/Sidewalks/Pathways' },
+{ 'service_code':11, 'service_name': 'Debris or Litter on Road/Sidewalk/Pathway', 'group':'Roads/Sidewalks/Pathways' },
+{ 'service_code':8, 'service_name': 'Blocked or damaged Catch basin / Manhole', 'group':'Roads/Sidewalks/Pathways' },
+{ 'service_code':9, 'service_name': 'Pothole', 'group':'Roads/Sidewalks/Pathways' },
+{ 'service_code':10, 'service_name': 'Damaged Curb', 'group':'Roads/Sidewalks/Pathways' },
+{ 'service_code':12, 'service_name': 'Blocked or Damaged Culvert', 'group':'Roads/Sidewalks/Pathways' },
+{ 'service_code':13, 'service_name': 'Damaged Guardrails', 'group':'Roads/Sidewalks/Pathways' },
+{ 'service_code':14, 'service_name': 'Full or Overflowing Garbage Cans', 'group':'Roads/Sidewalks/Pathways' },
+{ 'service_code':4, 'service_name': 'Debris or Litter in Park', 'group':'Parks' },
+{ 'service_code':3, 'service_name': 'Lights Malfunctioning in Park', 'group':'Parks' },
+{ 'service_code':1, 'service_name': 'Broken or Damaged Equipment/Play Structures', 'group':'Parks' },
+{ 'service_code':2, 'service_name': 'Full or Overflowing Garbage Cans ', 'group':'Parks' },
+{ 'service_code':17, 'service_name': 'Street Lights Out or Malfunctioning', 'group':'Traffic Signals' },
+{ 'service_code':18, 'service_name': 'Faded/Damaged/Missing Pavement Markings', 'group':'Traffic Signals' },
+{ 'service_code':19, 'service_name': 'Bent/Damaged/Missing Street Signs', 'group':'Traffic Signals' }
+ ];
+
+ var hintText = "Let’s face it – programming on mobile devices is hard: everything’s much more complicated to accomplish than it is on the web or the desktop and, since the platform is fairly new, tools and frameworks are scarce and poorly refined. Plus, if you need your application to run on more than one target OS (iOS, Android, Blackberry) you’re pretty much forced to write a different application for each one of them.";
+ for (var i = 0; i < this.categories.length; i++)
+ {
+ this.categories[i]['description'] = hintText;
+ }
+
+ this.onResolveTimeout = function( lat, lon, callback )
+ {
+ Titanium.API.info("DEBUG FMSAPI: resolving #: " + this.resolveCount );
+ var status = this.resolveCount % 3;
+ var locationData = InitLocationData(status, lat,lon);
+ this.resolveCount = this.resolveCount+ 1;
+ callback( locationData, this.reports, this.categories );
+ }
+
+ this.onSendTimeout = function( callback )
+ {
+ var status = 0;
+ if( this.sendCount % 2 == 0 )
+ {
+ status = FMS_SUCCESS;
+ }
+ else
+ {
+ status = FMS_SERVER_ERROR;
+ }
+ this.sendCount = this.sendCount + 1;
+ callback( status, send_status_text( status ) );
+
+ }
+
+ this.resolveLocation = function( lat, lon, callback )
+ {
+ var instance = this;
+ setTimeout(function()
+ {
+ instance.onResolveTimeout(lat,lon,callback);
+ },5000);
+
+ };
+
+ this.sendReport = function( report_dict, callback )
+ {
+ Titanium.API.info("DEBUG FMSAPI: sending report " + JSON.stringify(report_dict));
+ var instance = this;
+ setTimeout(function()
+ {
+ instance.onSendTimeout( callback );
+ },2000);
+
+ };
+
+};
+
+function ParalellXMLRequest( url, timeout )
+{
+ var that = this;
+ that.status = null;
+ that.data = null;
+ that.xhr = null;
+
+ that.onLoad = function( e )
+ {
+ if( that.xhr.status == 200 )
+ {
+ that.data = that.xhr.responseXML;
+ }
+ else
+ {
+ Titanium.API.info("REAL FMSAPI: http load error " + that.xhr.status + " " + that.xhr.responseText );
+ that.data = that.xhr.responseText;
+ }
+ that.status = that.xhr.status;
+ };
+
+ that.onError = function( e )
+ {
+ Titanium.API.info("REAL FMSAPI: http error " + that.xhr.status );
+ that.data = that.xhr.responseText;
+ that.status = that.xhr.status;
+ };
+
+
+ that.xhr = Ti.Network.createHTTPClient({
+ onload: function(e) { that.onLoad(e); },
+ timeout:timeout,
+ ontimeout : function(e) { that.onError(e); },
+ onerror: function(e) { that.onError(e); },
+ });
+
+ that.xhr.open("GET", url);
+ that.xhr.send();
+
+ return( that );
+
+};
+
+function RealFMSApi( url ) {
+
+ this.url = url;
+
+ this.xmlToJSON = function( xml )
+ {
+
+ if (xml.nodeType == 3)
+ { // text
+ return( xml.text );
+ }
+
+ // Create the return object
+ var obj = {};
+
+ // do children
+ if ( xml.childNodes )
+ {
+ var item;
+ for(var i = 0; i < xml.childNodes.length; i++)
+ {
+ if( i == 0)
+ {
+ item = xml.firstChild;
+ }
+ else
+ {
+ item = item.nextSibling;
+ }
+ //var item = xml.childNodes.item(i);
+ if( item.nodeName == 'text')
+ {
+ return( item.text )
+ }
+ obj[item.nodeName] = this.xmlToJSON(item);
+ }
+ }
+
+ Titanium.API.info("REAL FMSAPI: got json " + JSON.stringify(obj));
+ return( obj );
+ }
+
+
+ this.onResolveTimeout = function( lat, lon, requests, callback )
+ {
+ var json_reports = [];
+ var json_categories = [];
+ var status = FMS_SERVER_ERROR;
+
+ for( key in requests )
+ {
+ if( requests[key].status == 404 && requests[key].data == "lat/lon not supported")
+ {
+ status = FMS_LOCATION_NOT_SUPPORTED;
+ }
+ }
+
+ if( requests.reports.status == 200 && requests.categories.status == 200 )
+ {
+ // parse XML?
+ var reports = requests.reports.data.documentElement.getElementsByTagName("request");
+ if( reports )
+ {
+ Titanium.API.info("REAL FMSAPI: resolved " + reports.item.length + " reports " );
+
+ for ( var i = 0; i < reports.item.length; i++ )
+ {
+ json_reports.push( this.xmlToJSON(reports.item(i)));
+ }
+ }
+ var categories = requests.categories.data.documentElement.getElementsByTagName("service");
+ if( categories )
+ {
+ Titanium.API.info("REAL FMSAPI: resolved " + categories.item.length + " categories " );
+
+ for ( var i = 0; i < categories.item.length; i++ )
+ {
+ xml = categories.item(i);
+ if( xml )
+ {
+ json_categories.push( this.xmlToJSON(xml));
+ }
+ }
+ }
+ status = FMS_SUCCESS;
+ }
+ var locationData = InitLocationData(status, lat, lon);
+ callback( locationData, json_reports, json_categories );
+ }
+
+ this.resolveLocation = function( lat, lon, callback )
+ {
+ var requests = {};
+ var http_timeout = 5000;
+ requests[ 'categories'] = new ParalellXMLRequest( this.url + "open311/v2/services.xml?lat=" + lat + ";lon=" + lon, http_timeout);
+ requests[ 'reports'] = new ParalellXMLRequest(this.url + "open311/v2/requests.xml?lat=" + lat + ";lon=" + lon, http_timeout);
+ var instance = this;
+ setTimeout(function()
+ {
+ instance.onResolveTimeout(lat,lon,requests,callback);
+ },7000);
+
+ };
+
+ this.sendReport = function( report_dict, callback )
+ {
+ Titanium.API.info("REAL FMSAPI: sending report " + JSON.stringify(report_dict));
+ var url = this.url + "reports/";
+
+ var xhr = Ti.Network.createHTTPClient({
+ onload: function(e) {
+ // this.responseText holds the raw text return of the message (used for JSON)
+ // this.responseXML holds any returned XML (used for SOAP web services)
+ // this.responseData holds any returned binary data
+ if( this.status == 200 )
+ {
+ callback( FMS_SUCCESS, send_status_text( FMS_SUCCESS ) );
+ }
+ else
+ {
+ Titanium.API.info("REAL FMSAPI: got error " + this.status + " " + this.responseText);
+ callback( FMS_SERVER_ERROR, send_status_text( FMS_SERVER_ERROR ) );
+ }
+ },
+
+ ontimeout : function(e) {
+ Titanium.API.info("REAL FMSAPI: HTTP timeout " + url );
+ callback( FMS_SERVER_ERROR, send_status_text( FMS_SERVER_ERROR ) );
+ },
+ onerror: function(e) {
+ Titanium.API.info("REAL FMSAPI: HTTP error " + url );
+ callback( FMS_SERVER_ERROR, send_status_text( FMS_SERVER_ERROR ) );
+ },
+ timeout:5000
+ });
+
+ xhr.open("post", url);
+ xhr.send(report_dict);
+ };
+
+};
+
+function ApiWrapper( api ) {
+
+ this.api = api;
+ this.DEBUG = DEBUG;
+
+ this.getResolvedLocation = function()
+ {
+ var locationStr = Titanium.App.Properties.getString('LocationData');
+ if( locationStr == '' )
+ {
+ return( {} );
+ }
+ var locationData = JSON.parse(locationStr);
+ return( locationData );
+ },
+
+
+ this.locationResolvedCallback = function( locationData, reports, categories )
+ {
+ Titanium.API.info("FMSAPI: location resolved " + JSON.stringify(locationData));
+ var db = Titanium.Database.open('FMSdb.sqlite');
+ for (var i = 0; i < categories.length; i++)
+ {
+ db.execute('INSERT OR REPLACE INTO categories (id,name,group_name, hint_text) VALUES (?,?,?,?)',categories[i].service_code,categories[i].service_name,categories[i].group,categories[i].description);
+ }
+
+ for (var i = 0; i < reports.length; i++)
+ {
+ is_fixed = (reports[i].status == 'closed')
+ db.execute('INSERT OR REPLACE INTO reports (id,category,title,desc,lat,lon,is_fixed) VALUES (?,?,?,?,?,?,?)',
+ reports[i].service_request_id,
+ reports[i].service_code,
+ reports[i].title,
+ reports[i].desc,
+ reports[i].lat,
+ reports[i].lon,
+ is_fixed);
+ }
+
+ db.close();
+ Titanium.App.Properties.setString('LocationData', JSON.stringify(locationData ));
+ Titanium.App.fireEvent('app_loading_end', {'text':FMS_LOADING_MSG});
+ Ti.App.fireEvent('location_resolved', locationData );
+
+ }
+
+ this.resolveLocation = function( lat, lon )
+ {
+ var db = Titanium.Database.open('FMSdb.sqlite');
+ var locationString = Titanium.App.Properties.getString('CurrentLocation');
+ if ( locationString != null && locationString != "")
+ {
+ var prevCoords = JSON.parse(locationString);
+ if( prevCoords.latitude == lat && prevCoords.longitude == lon )
+ {
+ return;
+ }
+ }
+
+
+ Titanium.API.info("resolving location" + lat + " " + lon );
+ db.execute('delete from categories;');
+ db.execute('delete from reports;');
+ db.close();
+
+ var coords = { 'latitude':lat, 'longitude':lon };
+ Titanium.App.Properties.setString('CurrentLocation', JSON.stringify(coords ));
+
+ Titanium.App.fireEvent('resolving_location', coords);
+ Titanium.App.fireEvent('app_loading_start', {'text':FMS_LOADING_MSG});
+
+ this.api.resolveLocation(lat,lon, this.locationResolvedCallback );
+
+ };
+
+
+ this.sendReport = function( report_dict, callback )
+ {
+ Titanium.API.info("FMSAPI: sending report " + JSON.stringify(report_dict));
+ var db = Titanium.Database.open('FMSdb.sqlite');
+ var categoryQ = db.execute('SELECT id FROM categories where name=\'' + report_dict['category'] + '\'');
+ while (categoryQ.isValidRow())
+ {
+ report_dict['category'] = categoryQ.fieldByName('id');
+ categoryQ.next();
+ }
+ categoryQ.close();
+ db.close();
+ this.api.sendReport( report_dict, callback );
+ }
+
+};
+
+var FMSApi = new ApiWrapper( new RealFMSApi(DEBUG_URL));
View
147 mobile/titanium/FMS/Resources/js/settings.js
@@ -0,0 +1,147 @@
+Titanium.include('/js/defs/settings_def.js')
+Titanium.include("/js/utils/sliding_edit_view.js");
+
+var win = Ti.UI.currentWindow;
+var isAndroid = (Titanium.Platform.name == 'android');
+var mytabindex = 3;
+var valTextArray = [];
+var rowEdit = -1;
+
+var editWindow = Titanium.UI.createWindow({
+// backgroundColor:'#000',
+// opacity:0.7,
+ title: 'Edit Settings'
+ });
+
+
+
+var editField = Titanium.UI.createTextField({
+ backgroundColor:'#fff',
+ borderColor: '#bbb',
+ borderRadius: 5,
+ color:'#336699',
+ top: 20,
+ width: Titanium.Platform.displayCaps.platformWidth - 20,
+ left: 10,
+ height: 35,
+ font: {fontSize:16,fontWeight:'bold', fontFamily:'Arial'},
+ });
+
+var editCloseButton = Titanium.UI.createButton({
+ title:'Done',
+ height:30,
+ width:150,
+ top: 80,
+});
+
+function onEditWindowOpen()
+{
+ if( ! isAndroid && 'format' in SETTINGS[rowEdit ])
+ {
+ editField.addEventListener( 'change',SETTINGS[ rowEdit ].format );
+ }
+
+ editField.focus();
+}
+
+function closeEditWindow()
+{
+ if( isAndroid && 'format' in SETTINGS[rowEdit] )
+ {
+ // format now.
+ SETTINGS[rowEdit].format( {'source': editField });
+ }
+
+ if( 'validate' in SETTINGS[rowEdit] )
+ {
+ err = SETTINGS[rowEdit].validate( editField.value );
+ if( err )
+ {
+ var alertDialog = Titanium.UI.createAlertDialog({
+ title: 'Oops.',
+ message: err,
+ buttonNames: ['OK']
+ });
+ alertDialog.show();
+ return;
+ }
+ }
+
+ if( ! isAndroid && 'format' in SETTINGS[rowEdit ])
+ {
+ editField.removeEventListener( 'change',SETTINGS[ rowEdit ].format );
+ }
+ valTextArray[rowEdit].text = editField.value;
+ editWindow.close();
+}
+
+editCloseButton.addEventListener('click', closeEditWindow );
+editField.addEventListener('blur',closeEditWindow);
+//editWindow.addEventListener('click',closeEditWindow);
+editWindow.addEventListener('open',onEditWindowOpen);
+editWindow.add(editField);
+editWindow.add(editCloseButton);
+
+function onRowClick(e )
+{
+ Titanium.API.info("settings - onRowClick index=" + e.index);
+ editField.value = valTextArray[e.index].text;
+ editField.keyboardType = SETTINGS[e.index].keypad;
+ rowEdit = e.index;
+ Titanium.UI.currentTab.open(editWindow,{animated:true});
+}
+
+function createRow( setting )
+{
+ var row = Ti.UI.createTableViewRow();
+ row.selectedBackgroundColor = '#fff';
+ row.height = 35;
+// row.className = 'datarow';
+// row.clickName = 'row';
+
+ var label = Ti.UI.createLabel({
+ color:'#576996',
+ font: {fontSize:16,fontWeight:'bold', fontFamily:'Arial'},
+ left:10,
+ top:0,
+ height:35,
+ width:65,
+ clickName:setting.label,
+ text: setting.label
+ });
+
+ row.add(label);
+
+ val = Titanium.App.Properties.getString(setting.label);
+
+ var valText = Ti.UI.createLabel({
+ color:'#336699',
+ font: {fontSize:16,fontWeight:'bold', fontFamily:'Arial'},
+ left:75,
+ top:0,
+ height:35,
+ width:215,
+ textAlign: 'right',
+ clickName: setting.label,
+ text: val
+ });
+ valTextArray.push(valText);
+ row.add(valText);
+ row.addEventListener('click',onRowClick);
+ return( row );
+}
+
+data = [];
+for (var i=0;i< SETTINGS.length;i++)
+{
+ var row = createRow(SETTINGS[i]);
+ data.push(row);
+}
+
+var tableView = Ti.UI.createTableView({
+ data:data,
+ style: Titanium.UI.iPhone.TableViewStyle.GROUPED
+});
+
+
+win.add(tableView);
View
687 mobile/titanium/FMS/Resources/js/utils/form.js
@@ -0,0 +1,687 @@
+/**
+ * @author user
+ */
+
+Titanium.include("/js/utils/sliding_edit_view.js");
+
+var DEFAULT_BORDER_COLOR = '#bbb';
+var DEFAULT_LR_MARGIN = 10;
+
+isAndroid = (Titanium.Platform.name == 'android');
+
+function ItemWrapper( item )
+{
+ this.item = item;
+ this.setLeft = function( left )
+ {
+ this.item.left = left;
+ }
+
+ this.setWidth = function( width )
+ {
+ this.item.width = width;
+ }
+
+ this.setTop = function( top )
+ {
+ this.item.top = top;
+ }
+
+ this.getHeight = function()
+ {
+ return( this.item.height );
+ }
+
+ this.addToView = function ( view )
+ {
+ Titanium.API.info("form: ItemWrapper " + this.item + " top=" + this.item.top + " left=" + this.item.left + "w=" + this.item.width );
+ view.add( this.item );
+ }
+
+ this.addEventListener = function( evtName, fcn )
+ {
+ Titanium.API.info("form: ItemWrapper add event listener " + this.item + " name=" + evtName );
+ this.item.addEventListener(evtName,fcn);
+ };
+
+
+
+};
+
+function Label( labelText )
+{
+ var that = new ItemWrapper( Titanium.UI.createLabel({
+ color:'#fff',
+ text: labelText,
+ height:30 } ));
+
+ that.getText = function()
+ {
+ return( that.item.text );
+ }
+
+ return( that );
+}
+
+function GreenButton( title )
+{
+ var that = new ItemWrapper ( Titanium.UI.createButton({
+ color:'#fff',
+ backgroundImage:'/images/BUTT_grn_off.png',
+ height:57,
+ font:{fontSize:20,fontWeight:'bold',fontFamily:'Helvetica Neue'},
+ title: title
+ }) );
+
+
+ return( that );
+}
+
+function FieldBase( field )
+{
+ var that = new ItemWrapper( field );
+ that.field = that.item;
+ that.validator = null;
+ that.formatter = null;
+
+ that.addFormatter = function( formatFcn )
+ {
+ that.formatter = formatFcn;
+ // on android, format at end
+ if( ! isAndroid )
+ {
+ that.item.addEventListener( 'change', formatFcn );
+ }
+ }
+
+ that.addValidator = function( validateFcn )
+ {
+ that.validator = validateFcn;
+ }
+
+ that.get = function()
+ {
+ return( that.item.value );
+ }
+
+ that.set = function( value )
+ {
+ that.item.value = value;
+ }
+
+ that.blur = function()
+ {
+ // do nothing by default.
+ };
+
+ that.clear = function()
+ {
+ that.item.value = '';
+ that.clearError();
+ }
+
+ that.clearError = function()
+ {
+ // clear error indication.
+ that.item.borderColor = DEFAULT_BORDER_COLOR;
+ that.item.borderWidth = 1;
+ }
+
+ that.showError = function()
+ {
+ that.item.borderColor = '#fbb';
+ that.item.borderWidth = 2;
+ }
+
+ that.validate = function()
+ {
+ var value = that.get();
+
+ // is it blank?
+ if( value == '')
+ {
+ return( 'Field can not be blank.' );
+ }
+
+ // do we have a formatter defined? if so, run it now.
+ if( isAndroid && ( that.formatter ) )
+ {
+ that.formatter( { 'source' : that.field } );
+ }
+
+ // do we have a validator defined?
+ if ( that.validator )
+ {
+ err = that.validator( value );
+ return( err );
+ }
+
+ return ( null );
+ }
+
+ return( that );
+
+}
+
+
+function TextField( keyboard )
+{
+ var that = new FieldBase( Titanium.UI.createTextField({
+ height:35,
+ backgroundColor:'#fff',
+ keyboardType: keyboard,
+ borderWidth: 1,
+ borderColor: '#bbb',
+ borderRadius: 5
+ }) );
+
+ that.blur = function()
+ {
+ that.item.blur();
+ };
+
+ return( that );
+}
+
+
+function TextAreaField( height )
+{
+ var that = new FieldBase( Ti.UI.createTextArea({
+ value: '',
+ height: height,
+ keyboardType: Ti.UI.KEYBOARD_ASCII,
+ color: '#222',
+ borderWidth: 1,
+ borderColor: '#bbb',
+ borderRadius: 5
+ }) );
+
+ that.blur = function()
+ {
+ that.item.blur();
+ };
+
+ return( that );
+}
+
+function RightButtonField()
+{
+ var that = new TextField( Titanium.UI.KEYBOARD_DEFAULT )
+ var tr = Titanium.UI.create2DMatrix();
+ tr = tr.rotate(90);
+ var fieldButton = Titanium.UI.createButton({
+ style:Titanium.UI.iPhone.SystemButton.DISCLOSURE,
+ transform:tr
+ });
+ that.field.rightButton = fieldButton;
+ that.field.rightButtonMode = Titanium.UI.INPUT_BUTTONMODE_ALWAYS;
+
+ that.blur = function()
+ {
+ // that.item.blur();
+ };
+
+ return that;
+}
+
+function CustomHtmlSelectField( id, height, width )
+{
+ var that = new ItemWrapper( Ti.UI.createWebView({
+ width: width,
+ height: height,
+ left: 10 }) );
+
+
+ that.value = '';
+ that.id = id;
+ that.width = width;
+
+ that.blur = function()
+ {
+
+ }
+
+ that.clear = function()
+ {
+ that.value = '';
+ //that.item.reload();
+ that.item.evalJS('document.getElementById(\'' + that.id + '\').value=\'\';');
+ }
+
+ that.get = function()
+ {
+ return( that.value );
+ }
+
+ that.setOptions = function( options )
+ {
+ var html = "<html><body bgcolor='#333' style='width: " + that.width + "px; margin: 0px; padding: 0px;' >";
+ html += "<select id='" + that.id + "' style='width: " + (that.width) + "px; margin: 0px; padding: 0px; font-size: 14px; height: " + that.item.height + ";'>";
+ html += "<option value='' >Please select a category</option>";
+ optgroup = null;
+ for (var i = 0; i < options.length; i++)
+ {
+ var option = options[i];
+ if (option.group != optgroup) {
+ if (optgroup != null) {
+ html += "</optgroup>";
+ }
+ html += "<optgroup label='" + option.group + "'>";
+ optgroup = option.group;
+ };
+ html += "<option value='" + option.value + "'>" + option.name + "</option>";
+ };
+ html += "</select>";
+ html += "</body>";
+ html += "<script type='text/javascript'>";
+ html += "document.getElementById('" + that.id + "').onchange = function(){ Titanium.API.info('about to fire custom event');Titanium.App.fireEvent('custom_select_value',{'value': this.options[this.selectedIndex].text, 'id': '" + that.id + "'}); };";
+ html += "</script>";
+ html += "</html>";
+ that.item.html = html;
+ };
+
+ that.jschange = function( e )
+ {
+ Titanium.API.info("form: on valu change: " + e.value + ' id=' + e.id );
+ if ( e.value != '' && e.id == that.id )
+ {
+ Titanium.API.info("form: setting value to: " + e.value );
+ that.value = e.value;
+ that.item.fireEvent('custom_change', {'source': that, 'value':e.value })
+ }
+ }
+
+ that.validate = function()
+ {
+ // is it blank?
+ if( that.value == '')
+ {
+ return( 'Field can not be blank.' );
+ }
+
+ return ( null );
+ }
+
+ Titanium.App.addEventListener('custom_select_value',that.jschange);
+ return( that );
+};
+
+
+function CustomPickerField( id, hintText )
+{
+ var that = new RightButtonField();
+ that.id = id;
+ that.view = new SlidingEditView( 270, null );
+ that.field.hintText = hintText;
+ that.picker = null;
+ that.changed = false;
+ that.options = [];
+
+ that.addToWin = function( win )
+ {
+ win.add(that.view.view);
+ }
+
+ that.onPickerChange = function(e)
+ {
+ Titanium.API.info("custom picker onPickerChange " + that + " " + e.row.myid );
+ if( that.get() != e.row.myid )
+ {
+ that.set( e.row.myid );
+ that.changed = true;
+ }
+ }
+
+ that.clear = function()
+ {
+ Titanium.API.info("custom picker clear" );
+ that.set( '' );
+ that.clearError();
+ that.changed = false;
+ if( that.picker )
+ {
+ Titanium.API.info("custom picker clear: setting row to 0" );
+ if( that.options.length > 0 )
+ {
+ that.picker.setSelectedRow(0,0);
+ }
+ }
+ Titanium.API.info("custom picker clear: donw" );
+ }
+
+ that.setOptions = function( options )
+ {
+ that.options = options;
+ if( isAndroid )
+ {
+ that.picker = Titanium.UI.createPicker({
+ useSpinner: true,
+ visibleItems: 7,
+ type : Ti.UI.PICKER_TYPE_PLAIN,
+ top: 20,
+ height: 200,
+ selectionIndicator:true, });
+ }
+ else
+ {
+ that.picker = Titanium.UI.createPicker({
+ top:20,
+ selectionIndicator:true,
+ });
+ }
+ var optgroup = '';
+ var rows = [];
+ Titanium.API.info("custom picker setting options " + that );
+
+ for (var i = 0; i < options.length; i++)
+ {
+ var name = options[i].name;
+ var group = options[i].group;
+ if (group != optgroup )
+ {
+ var groupRow = Ti.UI.createPickerRow( {
+ touchEnabled: false,
+ myid: ''
+ });
+
+ var label = Ti.UI.createLabel({
+ text:group,
+ font:{fontSize:16,fontWeight:'bold'},
+ color:'#ff5555',
+ textAlign: 'center',
+ width:'auto',
+ height:'auto'
+ });
+ groupRow.add(label);
+ rows.push(groupRow);
+ optgroup = group;
+ }
+
+ var row = Ti.UI.createPickerRow( { myid: name });
+
+ var label = Ti.UI.createLabel({
+ text:name,
+ font:{fontSize:12},
+ width:'auto',
+ textAlign: 'center',
+ height:'auto'
+ });
+
+ row.add(label);
+ rows.push(row);
+ }
+ that.picker.add(rows);
+ that.picker.addEventListener( 'change', function(e) { that.onPickerChange(e); } );
+ that.view.setField(that.picker);
+
+ };
+
+ that.blur = function()
+ {
+ };
+
+
+ that.view.done.addEventListener('click',function() {
+ that.view.slideOut();
+ if( that.changed )
+ {
+ that.item.fireEvent('custom_change', { 'source': that, 'value': that.get() } );
+ }
+ });
+
+
+ that.field.addEventListener( 'focus', function(e)
+ {
+ Titanium.API.info("custom picker onFocus " + that );
+ e.source.blur();
+ that.view.slideIn();
+ } );
+
+ return( that );
+};
+
+
+function Form( name, width ) {
+ this.name = name;
+ this.width = width;
+ this.fields = {};
+ this.labels = {};
+ this.errors = {};
+ this.items = [];
+ this.isAndroid = (Titanium.Platform.name == 'android');
+
+
+ this.curTop = 10;
+ this.view = null;
+ this.submitButton = null;
+
+ /* resize a row of items. */
+ this.setRowWidth = function( row_items, width )
+ {
+ item_width = Math.round( (width - DEFAULT_LR_MARGIN * (row_items.length + 1) ) / row_items.length );
+
+ for( var j = 0; j < row_items.length; j++ )
+ {
+ row_items[j].setWidth( item_width );
+ row_items[j].setLeft( Math.round( DEFAULT_LR_MARGIN + j * (item_width + DEFAULT_LR_MARGIN) ) );
+ }
+ };
+
+
+ this.setWidth = function( width )
+ {
+ this.width = width;
+
+ for( var i = 0; i < this.items.length; i++ )
+ {
+ if (this.items[i] instanceof Array)
+ {
+ this.setRowWidth( this.items[i], width );
+ } else
+ {
+ this.items[i].setWidth( width - DEFAULT_LR_MARGIN * 2 );
+ }
+ };
+
+ if( this.view )
+ {
+ this.view.width = width;
+ }
+ };
+
+ this.addItem = function( item, padding )
+ {
+ this.items.push(item);
+ if ( item instanceof Array )
+ {
+ for( var i = 0; i < item.length; i++ )
+ {
+ item[i].setTop( this.curTop );
+ }
+ this.setRowWidth( item, this.width );
+ this.curTop = this.curTop + item[0].getHeight() + padding;
+ }
+ else
+ {
+ item.setTop( this.curTop );
+ item.setLeft( DEFAULT_LR_MARGIN );
+ item.setWidth( this.width - DEFAULT_LR_MARGIN * 2 );
+ this.curTop = this.curTop + item.getHeight() + padding;
+ }
+ };
+
+
+ this.addLabel = function( id, labelText )
+ {
+ var label = new Label(labelText);
+ this.labels[ id ] = label;
+ this.addItem(label,-2);
+ return (label );
+ };
+
+ this.addValidator = function( id, validation_fcn )
+ {
+ this.fields[id].addValidator( validation_fcn );
+ }
+
+ this.addFormatter = function ( id, format_fcn )
+ {
+ this.fields[id].addFormatter( format_fcn );
+ }
+
+ this.addField = function( id, field )
+ {
+ this.fields[ id ] = field;
+ this.addItem(field,5);
+ };
+
+ this.addButtonRow = function( textArray )
+ {
+ var buttonArray = [];
+ for( var i = 0; i < textArray.length; i++ )
+ {
+ var button = new GreenButton(textArray[i]);
+ buttonArray.push(button);
+ }
+
+ this.curTop = this.curTop + 10;
+ this.addItem(buttonArray,10);
+ return( buttonArray );
+ };
+
+ this.addSubmitButton= function (text)
+ {
+ this.submitButton = new GreenButton(text);
+ this.addItem(this.submitButton,5);
+ };
+
+ this.addFieldWithLabel = function( id, label, field )
+ {
+ this.addLabel(id, label);
+ this.addField( id, field );
+ return field;
+ }
+
+ this.addTextField = function( id, label, keyboard )
+ {
+ return( this.addFieldWithLabel(id, label, new TextField( keyboard ) ) );
+ };
+
+ this.addRightButtonField = function( id, label )
+ {
+ return( this.addFieldWithLabel(id, label, new RightButtonField() ) );
+ };
+
+ this.addTextArea = function( id, label, height )
+ {
+ return( this.addFieldWithLabel(id, label, new TextAreaField( height ) ) );
+ };
+
+ this.addCustomSelect = function( id, label, height )
+ {
+ return( this.addFieldWithLabel(id, label, new CustomHtmlSelectField( id, height, this.width - DEFAULT_LR_MARGIN*2) ) );
+ };
+
+ this.addCustomPicker = function( id, label, hint )
+ {
+ return( this.addFieldWithLabel(id, label, new CustomPickerField( id, hint ) ) );
+ }
+
+ this.getView = function()
+ {
+ if (this.view == null)
+ {
+ this.view = Ti.UI.createView({
+ top: 10,
+ left: 10,
+ width: this.width,
+ height: this.curTop+10,
+ backgroundColor:'#333',
+ borderRadius:6
+ });
+
+ for( var i = 0; i < this.items.length; i++ )
+ {
+ if ( this.items[i] instanceof Array )
+ {
+ row = this.items[i];
+ for( var j = 0; j < row.length; j++ )
+ {
+ row[j].addToView( this.view );
+ }
+ }
+ else
+ {
+ this.items[i].addToView(this.view);
+ }
+ };
+
+ this.view.addEventListener('click',this.onClick);
+ }
+
+ return( this.view );
+ };
+
+
+ this.validate = function()
+ {
+ var allOK = true;
+ for( var id in this.fields )
+ {
+ var field = this.fields[id];
+ var err = field.validate();
+
+ if( err )
+ {
+ allOK = false;
+ field.showError();
+ this.errors[id] = err;
+ }
+ else
+ {
+ // clear previous errors
+ if( id in this.errors )
+ {
+ field.clearError();
+ delete this.errors[id];
+ }
+ }
+ }
+ return allOK;
+ };
+
+ this.getValues = function()
+ {
+ var values = {};
+ for( var id in this.fields )
+ {
+ values[ id ] = this.fields[id].get();
+ };
+ return values;
+ };
+
+ this.clear = function()
+ {
+ for( var id in this.fields )
+ {
+ this.fields[id].clear();
+ }
+ this.errors = {};
+ }
+
+ var that = this;
+ this.onClick = function(e)
+ {
+ Titanium.API.info("form: onClick");
+ for( var id in that.fields )
+ {
+ Titanium.API.info("form: looking at field " + id);
+ if( that.fields[id].item)
+ {
+ Titanium.API.info("form: blurring field " + id);
+ that.fields[id].blur();
+ }
+ }
+ }
+ return( that );
+};
View
62 mobile/titanium/FMS/Resources/js/utils/sliding_edit_view.js
@@ -0,0 +1,62 @@
+
+/*
+ * View with a single edit field.
+ */
+
+function SlidingEditView( height, field )
+{
+ this.view = Titanium.UI.createView({
+ height:height,
+ bottom:-height,
+ backgroundColor: '#333'
+ });
+
+ this.done = Titanium.UI.createButton({
+ title:'Done',
+ height: 35,
+ });
+
+
+ this.view.add(this.done);
+ this.slideInAnim = Titanium.UI.createAnimation({bottom:0});
+ this.slideOutAnim = Titanium.UI.createAnimation({bottom:-height});
+
+ this.setField = function( field )
+ {
+ if( this.field )
+ {
+ this.view.remove(field);
+ }
+ this.field = field;
+
+ this.view.add(field);
+ this.field.top = 10;
+ this.done.top = this.field.top + this.field.height + 5;
+ };
+
+ this.slideIn = function()
+ {
+ Titanium.API.info("edit window slide in... " + this );
+ this.view.animate(this.slideInAnim);
+ };
+
+ this.slideOut = function()
+ {
+ this.view.animate(this.slideOutAnim);
+ };
+
+ this.addToWin = function( win )
+ {
+ win.add(this.view);
+ }
+
+
+ if( field )
+ {
+ this.setField(field);
+ }
+ else
+ {
+ this.field = null;
+ }
+};
View
30 mobile/titanium/FMS/Resources/js/utils/win_wrapper.js
@@ -0,0 +1,30 @@
+
+function WinWrapper( win )
+{
+ this.win = win;
+
+ this.open = function( params )
+ {
+ this.win.open(params);
+ }
+
+ this.close = function()
+ {
+ this.win.close();
+ }
+
+ this.show = function()
+ {
+ this.win.show();
+ }
+
+ this.hide = function()
+ {
+ this.win.hide();
+ }
+
+ this.addEventListener = function( name, func )
+ {
+ this.win.addEventListener(name,func);
+ }
+};
View
161 mobile/titanium/FMS/Resources/js/views/addphotoform.js
@@ -0,0 +1,161 @@
+
+function AddPhotoForm( width )
+{
+ var that = new Form("Photo",width);
+
+ that.choosePhotoSourceDialog = Ti.UI.createOptionDialog({
+ title: 'Add a Photo'
+ });
+
+
+ that.view = that.getView();
+ that.view.height = 70;
+
+ that.photoLabel = Ti.UI.createLabel({
+ top: 10,
+ left: 70,
+ width: 280,
+ height: 30,
+ color: '#fff',
+ font: {
+ fontSize: 16,
+ fontWeight: 'bold'
+ },
+ text: 'Add a Photo'
+ });
+
+ that.photoLabelDesc = Ti.UI.createLabel({
+ top: 35,
+ left: 70,
+ width: 280,
+ height: 30,
+ color: '#eee',
+ font: {
+ fontSize: 12,
+ fontWeight: 'normal'
+ },
+ text: 'Share a picture of the problem'
+ });
+
+ that.view.add(that.photoLabel);
+ that.view.add(that.photoLabelDesc);
+
+ that.photoView = Ti.UI.createView({
+ top: 10,
+ left: 10,
+ width: 50,
+ height: 50,
+ backgroundColor: '#222',
+ borderRadius: 6
+ });
+
+ that.currentPhotoView = Ti.UI.createImageView({
+ top: 1,
+ left: 1,
+ height: 44,
+ width: 44,
+ borderRadius: 2
+ });
+
+ that.photoButtonBg = Ti.UI.createView({
+ top: 2,
+ left: ((that.photoView.width - 46) / 2),