summaryrefslogtreecommitdiffstats
path: root/static/js/app.js
diff options
context:
space:
mode:
Diffstat (limited to 'static/js/app.js')
-rw-r--r--static/js/app.js68
1 files changed, 68 insertions, 0 deletions
diff --git a/static/js/app.js b/static/js/app.js
new file mode 100644
index 0000000..1bf422c
--- /dev/null
+++ b/static/js/app.js
@@ -0,0 +1,68 @@
+$(function(){
+
+ //Backbone.emulateJSON = false;
+
+ $('#gallery').dropzone({url: 'upload'});
+
+ var PhotoGallery = {};
+
+ PhotoGallery.Album = Backbone.Model.extend({
+ url: function(){
+ return this.id ? '/albums/' + this.id : '/albums/'
+ },
+ defaults: {
+ name: 'New Album'
+ }
+ });
+
+ PhotoGallery.AlbumAddView = Backbone.View.extend({
+ el: '#dock .popover',
+
+ initialize: function(){
+ $('#new-album').popover('show');
+ $('#album-name').val(this.model.get('name'))
+ $('#album-name').focus();
+ },
+
+ events: {
+ 'keyup #album-name': 'submitAlbum'
+ },
+
+ submitAlbum: function(e){
+ if (e.keyCode == 13) {
+ this.model.set('name', $(e.currentTarget).val());
+ this.model.save({success:function(r){
+ $('#new-album').popover('hide');
+ console.log(r);
+ }});
+ };
+ }
+
+ });
+
+ PhotoGallery.DockView = Backbone.View.extend({
+
+ el: '#dock',
+
+ events: {
+ 'click #new-album': 'addAlbum',
+ },
+
+ initialize: function(){
+ $('#new-album').popover({
+ title: 'New Album',
+ html: true,
+ content: '<input type="text" id="album-name"/>'
+ });
+ },
+
+ addAlbum: function(e){
+ album = new PhotoGallery.Album({})
+ new PhotoGallery.AlbumAddView({model: album});
+ },
+
+ });
+
+ new PhotoGallery.DockView();
+
+});