aboutsummaryrefslogtreecommitdiffstats
path: root/src/js/models/draft.js
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2013-07-12 09:47:56 +0100
committerStruan Donald <struan@exo.org.uk>2013-07-12 11:00:11 +0100
commit25e3a0c94551b0faac3f16e0598e6f4bdffcf7d8 (patch)
treef78f68ba8ed39e5b5004e41435aac3e9bbe9c044 /src/js/models/draft.js
parent4c2206c97250b7f72eb04d13ae886a7fb4f4086a (diff)
instead of using js to inject the correct cordova js file in to
index.html restructure things so that the common files are a level down and the platofrm specific ones are directly placed in the relevant project. This both makes for less fuss and also avoids the error with Android < v3 instantiating cordova twice. Note that the iOS common assets are included by a build script rather than a symlink as symlinking doesn't seem to agree with Xcode
Diffstat (limited to 'src/js/models/draft.js')
-rw-r--r--src/js/models/draft.js58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/js/models/draft.js b/src/js/models/draft.js
new file mode 100644
index 0000000..ec6cff6
--- /dev/null
+++ b/src/js/models/draft.js
@@ -0,0 +1,58 @@
+(function(FMS, Backbone, _, $, moment) {
+ _.extend( FMS, {
+ Draft: Backbone.Model.extend({
+ localStorage: new Backbone.LocalStorage(CONFIG.NAMESPACE + '-drafts'),
+
+ defaults: {
+ lat: 0,
+ lon: 0,
+ title: '',
+ details: '',
+ may_show_name: '',
+ category: '',
+ phone: '',
+ pc: '',
+ file: '',
+ created: moment.utc()
+ },
+
+ description: function() {
+ var desc = '';
+ if ( this.get('title') ) {
+ desc += this.get('title');
+ } else {
+ desc += 'Untitled draft';
+ }
+ desc += '<br><small>' + moment.utc( this.get('created') ).fromNow() + '</small>';
+
+ return desc;
+ },
+
+ isPartial: function() {
+ if (
+ this.get('title') ||
+ this.get('details') ||
+ this.get('category') ||
+ this.get('file')
+ ) {
+ return true;
+ }
+
+ return false;
+ },
+
+ createdDate: function() {
+ return moment.utc( this.get('created') ).format( 'H:mm Do MMM' );
+ }
+ })
+ });
+})(FMS, Backbone, _, $, moment);
+
+(function(FMS, Backbone, _, $) {
+ _.extend( FMS, {
+ Drafts: Backbone.Collection.extend({
+ model: FMS.Draft,
+ localStorage: new Backbone.LocalStorage(CONFIG.NAMESPACE + '-drafts')
+ })
+ });
+})(FMS, Backbone, _, $);