diff options
author | Struan Donald <struan@exo.org.uk> | 2013-07-12 09:47:56 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2013-07-12 11:00:11 +0100 |
commit | 25e3a0c94551b0faac3f16e0598e6f4bdffcf7d8 (patch) | |
tree | f78f68ba8ed39e5b5004e41435aac3e9bbe9c044 /src/js/views/reports.js | |
parent | 4c2206c97250b7f72eb04d13ae886a7fb4f4086a (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/views/reports.js')
-rw-r--r-- | src/js/views/reports.js | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/js/views/reports.js b/src/js/views/reports.js new file mode 100644 index 0000000..4690fb2 --- /dev/null +++ b/src/js/views/reports.js @@ -0,0 +1,61 @@ +(function (FMS, Backbone, _, $) { + _.extend( FMS, { + ReportsView: FMS.FMSView.extend({ + template: 'reports', + id: 'reports', + next: 'home', + contentSelector: '#drafts', + + events: { + 'pagehide': 'destroy', + 'pagebeforeshow': 'beforeDisplay', + 'pageshow': 'afterDisplay', + 'vclick .del_report': 'deleteReport', + 'vclick .use_report': 'useReport', + 'vclick .ui-btn-left': 'onClickButtonPrev', + 'vclick .ui-btn-right': 'onClickButtonNext' + }, + + deleteReport: function(e) { + e.preventDefault(); + var el = $(e.target); + var id = el.parents('li').attr('id'); + var del = FMS.removeDraft( id, true ); + var that = this; + del.done( function() { that.onRemoveDraft(el); } ); + del.fail( function() { that.onRemoveDraft(el); } ); + }, + + setHeight: function(content, height) { + content.css( 'min-height', content + 'px'); + }, + + useReport: function(e) { + e.preventDefault(); + var el = $(e.target); + var id = el.parents('li').attr('id'); + FMS.currentDraft = FMS.allDrafts.get(id); + this.navigate('around'); + }, + + onRemoveDraft: function(el) { + el.parents('li').remove(); + }, + + render: function(){ + if ( !this.template ) { + console.log('no template to render'); + return; + } + template = _.template( tpl.get( this.template ) ); + if ( this.model ) { + this.$el.html(template({ model: this.model.toJSON(), drafts: FMS.allDrafts })); + } else { + this.$el.html(template()); + } + this.afterRender(); + return this; + } + }) + }); +})(FMS, Backbone, _, $); |