aboutsummaryrefslogtreecommitdiffstats
path: root/www/js/models/draft.js
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2014-10-03 15:07:08 +0100
committerDave Arter <davea@mysociety.org>2015-08-28 14:27:15 +0100
commita69d425c0e5c004145ac1ab70e2f7f9fc329b54c (patch)
tree8eb7ff0ff7aaa0fce8bc7214ec6e15b694fddbdc /www/js/models/draft.js
parent8fd15b58733c51d7f001f9eac66b7d03830ec0b4 (diff)
update Android to Cordova 3.6
Required due to security issue Remove Android directory as no longer required, move src -> www to match standard layout, update .gitignore to avoid including the standard platform files, update README based on Steve's zurich one
Diffstat (limited to 'www/js/models/draft.js')
-rw-r--r--www/js/models/draft.js58
1 files changed, 58 insertions, 0 deletions
diff --git a/www/js/models/draft.js b/www/js/models/draft.js
new file mode 100644
index 0000000..ec6cff6
--- /dev/null
+++ b/www/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, _, $);