mix-rails-albums 0.15.0 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (23) hide show
  1. data/app/assets/javascripts/backbone/models/photo.js.coffee +33 -1
  2. data/app/assets/javascripts/backbone/routers/photos_router.js.coffee +3 -3
  3. data/app/assets/javascripts/backbone/templates/photos/thumbnail.hamlc.erb +5 -3
  4. data/app/assets/javascripts/backbone/views/photos/thumbnail_view.js.coffee +18 -10
  5. data/app/assets/javascripts/backbone/views/photos/upload_index_view.js.coffee +1 -0
  6. data/app/assets/javascripts/photos/upload.js.coffee.erb +19 -16
  7. data/app/assets/javascripts/views/fileview.js +0 -1
  8. data/app/controllers/admix/photos_controller.rb +6 -3
  9. data/app/models/album.rb +1 -3
  10. data/app/uploaders/albums/image_uploader.rb +1 -1
  11. data/lib/mix-rails-albums/version.rb +1 -1
  12. metadata +57 -68
  13. data/app/assets/javascripts/backbone/templates/photos/edit.jst.ejs +0 -20
  14. data/app/assets/javascripts/backbone/templates/photos/index.jst.ejs +0 -15
  15. data/app/assets/javascripts/backbone/templates/photos/modal.hamlc.erb +0 -14
  16. data/app/assets/javascripts/backbone/templates/photos/new.jst.ejs +0 -20
  17. data/app/assets/javascripts/backbone/templates/photos/photo.jst.ejs +0 -6
  18. data/app/assets/javascripts/backbone/templates/photos/show.jst.ejs +0 -12
  19. data/app/assets/javascripts/backbone/views/photos/edit_view.js.coffee +0 -24
  20. data/app/assets/javascripts/backbone/views/photos/index_view.js.coffee +0 -20
  21. data/app/assets/javascripts/backbone/views/photos/new_view.js.coffee +0 -37
  22. data/app/assets/javascripts/backbone/views/photos/photo_view.js.coffee +0 -19
  23. data/app/assets/javascripts/backbone/views/photos/show_view.js.coffee +0 -8
@@ -11,7 +11,7 @@ class Application.Models.Photo extends Backbone.Model
11
11
 
12
12
  onAdd: ->
13
13
  xhr = new XMLHttpRequest()
14
- xhr.open "POST", @url
14
+ xhr.open "POST", @url()
15
15
  datas = new FormData()
16
16
  datas.append "image", @get("image")
17
17
  xhr.upload.addEventListener "progress", (e) =>
@@ -25,6 +25,7 @@ class Application.Models.Photo extends Backbone.Model
25
25
  @trigger "uploadCompleted"
26
26
  if xhr.responseText
27
27
  responseObject = JSON.parse(xhr.responseText)
28
+ console.log responseObject
28
29
  @set responseObject
29
30
  else
30
31
  console.log "Não foi possível enviar o arquivo"
@@ -37,3 +38,34 @@ class Application.Collections.PhotosCollection extends Backbone.Collection
37
38
  model: Application.Models.Photo
38
39
  url: '/photos'
39
40
 
41
+ setFromFiles: (files) ->
42
+ @reset()
43
+ i = 0
44
+ while f = files[i]
45
+ reader = new FileReader()
46
+ reader.onload = ((theFile, theId) =>
47
+ (e) ->
48
+ photo = new Application.Models.Photo()
49
+ photo.set id: theId
50
+ photo.set filename: theFile.name
51
+ photo.set image: e.target.result
52
+ @add photo
53
+ )(f)
54
+ reader.readAsDataURL f, i
55
+ i++
56
+
57
+ addFromFiles: (files) ->
58
+ i = 0
59
+ while f = files[i]
60
+ reader = new FileReader()
61
+ reader.onload = ((theFile, theId) =>
62
+ (e) ->
63
+ photo = new Application.Models.Photo()
64
+ photo.set id: theId
65
+ photo.set filename: theFile.name
66
+ photo.set image: e.target.result
67
+ @add photo
68
+ )(f)
69
+ reader.readAsDataURL f, i
70
+ i++
71
+
@@ -32,6 +32,6 @@ class Application.Routers.PhotosRouter extends Backbone.Router
32
32
 
33
33
  edit: (id) ->
34
34
  photo = @photos.get(id)
35
-
36
- @view = new Application.Views.Photos.EditView(model: photo)
37
- $("#upload-container").html(@view.render().el)
35
+ console.log 'Editando a foto!' + photo
36
+ #@view = new Application.Views.Photos.EditView(model: photo)
37
+ #$("#upload-container").html(@view.render().el)
@@ -5,12 +5,14 @@
5
5
  .loading-file
6
6
  - if @image.url
7
7
  %a.photo-link{href: "#"}
8
- %img{src: ROOT_PATH + @image.thumb.url}
8
+ %img{src: ROOT_PATH + @image.medium.url}
9
9
  - else
10
10
  %img{src: "http://placehold.it/130x90&text=Carregando"}
11
11
  -if (@progress != null && @progress < 100)
12
12
  %div{class: (@progress < 100) ? 'progress progress-striped active' : 'progress'}
13
13
  .bar{style: "width:#{@progress}%;"}
14
14
  .caption
15
- %a.file-action.destroy{href: "#"}
16
- <%= image_tag "albums/delete.png" %>
15
+ %a.file-action.btn.destroy{href: "#", tooltip: 'Excluir'}
16
+ <%= image_tag "admix/icons/delete.png" %>
17
+ %a.file-action.btn.edit{href: "#", tooltip: 'Editar'}
18
+ <%= image_tag "admix/icons/picture_edit.png" %>
@@ -5,26 +5,34 @@ class Application.Views.Photos.PhotoView extends Backbone.View
5
5
 
6
6
  events:
7
7
  "click .destroy" : "destroy"
8
- "click .photo-link": "photo_link",
8
+ "click .edit": "edit",
9
9
 
10
10
  tagName: "li"
11
- className: 'span2'
11
+ className: 'span4'
12
12
 
13
13
  initialize: ->
14
14
  @model.on "change", @render, this
15
15
  @model.on "uploadCompleted", @removeProgressBar, this
16
+ self = @
17
+ $(@el).find('a[tooltip]').livequery ->
18
+ $(this).qtip
19
+ content: $(this).attr("tooltip") # Use the tooltip attribute of the element for the content
20
+ #style: "dark" # Give it a crea mstyle to make it stand out
21
+ style:
22
+ classes: "qtip-bootstrap qtip-#{self.model.get('id')}"
16
23
 
17
24
  removeProgressBar: ->
18
25
  @$el.find(".progress").fadeOut() unless @$el is undefined
19
26
 
20
- destroy: () ->
21
- @model.destroy()
22
- this.remove()
23
-
24
- return false
25
-
26
- photo_link: () ->
27
-
27
+ destroy: ->
28
+ if confirm('Tem certeza que deseja deletar?')
29
+ @model.destroy()
30
+ this.remove()
31
+ $(".qtip-#{@model.get('id')}").remove()
32
+ false
33
+ edit: () ->
34
+ Backbone.history.navigate("#/#{@model.id}/edit")
35
+ false
28
36
  render: ->
29
37
  @$el.html(@template(@model.toJSON() ))
30
38
  return this
@@ -7,6 +7,7 @@ class Application.Views.Photos.UploadIndexView extends Backbone.View
7
7
 
8
8
  initialize: () ->
9
9
  @options.photos.bind('reset', @addAll)
10
+ @options.photos.bind('add', @addOne)
10
11
 
11
12
  addAll: () =>
12
13
  @options.photos.each(@addOne)
@@ -4,21 +4,24 @@
4
4
  <% url = Rails.application.routes.url_helpers %>
5
5
  $ ->
6
6
  $.getJSON RESOURCE_PATH,(json) ->
7
- new Application.Routers.PhotosRouter(collectionUrl: RESOURCE_PATH, photos: json)
7
+ window.photos_router = new Application.Routers.PhotosRouter(collectionUrl: RESOURCE_PATH, photos: json)
8
8
  Backbone.history.start()
9
9
 
10
- $("#uploader").change (el) ->
11
- files = el.currentTarget.files
12
- i = 0
13
- while i < files.length
14
- photo = new Application.Models.Photo(
15
- image: files[i]
16
- name: files[i].name
17
- )
18
- photo.url = fileList.url
19
- fileList.add photo
20
- setTimeout (->
21
- fileList.add photo
22
- ), 1000
23
- i++
24
- fileListView.render()
10
+ $("#uploader").livequery ->
11
+ $(@).change (el) ->
12
+ #photos_router.addFromFiles(el.currentTarget.files)
13
+ files = el.currentTarget.files
14
+ console.log "Files count: #{files.length}"
15
+ i = 0
16
+ while i < files.length
17
+
18
+ photo = new Application.Models.Photo(
19
+ image: files[i]
20
+ name: files[i].name
21
+ )
22
+ ((photo) ->
23
+ setTimeout ->
24
+ photos_router.photos.add photo
25
+ , 1000
26
+ )(photo)
27
+ i++
@@ -34,6 +34,5 @@ var FileView = Backbone.View.extend({
34
34
  },
35
35
  photo_link: function(e) {
36
36
  e.preventDefault();
37
- Backbone.history.navigate(":photo_id/ajax_edit".replace(':photo_id', this.model.get('id')), {trigger: true});
38
37
  }
39
38
  });
@@ -1,5 +1,10 @@
1
- class Admix::PhotosController < Admix::InheritedController
1
+ class Admix::PhotosController < Admix::AdmixController
2
2
 
3
+ respond_to :json
4
+ respond_to :html, :only => [:upload, :index, :destroy]
5
+
6
+ inherit_resources
7
+
3
8
  before_filter :image_param
4
9
 
5
10
  polymorphic_belongs_to :album, param: :album_id
@@ -8,8 +13,6 @@ class Admix::PhotosController < Admix::InheritedController
8
13
  # load_and_authorize_resource :photo, :through => :album_id
9
14
  skip_load_and_authorize_resource
10
15
 
11
- respond_to :json
12
-
13
16
  def upload
14
17
  render inline: params.to_s
15
18
  end
data/app/models/album.rb CHANGED
@@ -2,7 +2,6 @@ class Album
2
2
 
3
3
  include Mongoid::Document
4
4
  include Mongoid::Timestamps
5
- include Mongoid::Paranoia
6
5
  include Mongoid::Slug
7
6
 
8
7
  field :name, type: String
@@ -22,8 +21,7 @@ class Album
22
21
 
23
22
  embeds_many :photos, cascade_callbacks: true
24
23
 
25
-
26
- scope :published, where(published: true)
24
+ scope :published, where(published: true, :photos.ne => nil, :photos.exists => true)
27
25
 
28
26
 
29
27
  end
@@ -44,7 +44,7 @@ class Albums::ImageUploader < CarrierWave::Uploader::Base
44
44
  # version :thumb do
45
45
  # process :resize_to_fit => [80, 80]
46
46
  # end
47
-
47
+
48
48
  version :medium do
49
49
  process :resize_to_fill => [640,420]
50
50
  end
@@ -1,7 +1,7 @@
1
1
  module MixRailsAlbums
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
- MINOR = 15
4
+ MINOR = 16
5
5
  TINY = 0
6
6
  PRE = nil
7
7
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mix-rails-albums
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.0
4
+ version: 0.16.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-24 00:00:00.000000000 Z
12
+ date: 2013-01-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -114,98 +114,87 @@ executables: []
114
114
  extensions: []
115
115
  extra_rdoc_files: []
116
116
  files:
117
- - app/uploaders/albums/image_uploader.rb
118
- - app/controllers/admix/albums_controller.rb
119
- - app/controllers/admix/photos_controller.rb
120
- - app/controllers/albums_controller.rb
121
- - app/assets/stylesheets/skins/tango/next-horizontal.png
117
+ - app/assets/stylesheets/skins/tango/next-vertical.png
122
118
  - app/assets/stylesheets/skins/tango/skin.css
119
+ - app/assets/stylesheets/skins/tango/next-horizontal.png
123
120
  - app/assets/stylesheets/skins/tango/prev-vertical.png
124
- - app/assets/stylesheets/skins/tango/next-vertical.png
125
121
  - app/assets/stylesheets/skins/tango/credits.txt
126
122
  - app/assets/stylesheets/skins/tango/prev-horizontal.png
127
- - app/assets/stylesheets/skins/ie7/loading.gif
128
- - app/assets/stylesheets/skins/ie7/prev-horizontal.gif
129
- - app/assets/stylesheets/skins/ie7/skin.css
130
- - app/assets/stylesheets/skins/ie7/loading_small.gif
131
- - app/assets/stylesheets/skins/ie7/credits.txt
132
123
  - app/assets/stylesheets/skins/ie7/loading-small.gif
124
+ - app/assets/stylesheets/skins/ie7/skin.css
133
125
  - app/assets/stylesheets/skins/ie7/next-horizontal.gif
126
+ - app/assets/stylesheets/skins/ie7/credits.txt
127
+ - app/assets/stylesheets/skins/ie7/loading_small.gif
128
+ - app/assets/stylesheets/skins/ie7/loading.gif
129
+ - app/assets/stylesheets/skins/ie7/prev-horizontal.gif
134
130
  - app/assets/stylesheets/colorbox/colorbox.css.scss
135
- - app/assets/images/albums/photos.png
136
- - app/assets/images/albums/delete.png
137
- - app/assets/images/albums/rotate_cw.png
138
- - app/assets/images/albums/crop.png
139
- - app/assets/images/albums/rotate_ccw.png
140
- - app/assets/images/colorbox/border.png
141
- - app/assets/images/colorbox/loading.gif
142
- - app/assets/images/colorbox/loading_background.png
143
- - app/assets/images/colorbox/controls.png
131
+ - app/assets/images/colorbox/ie6/borderMiddleLeft.png
132
+ - app/assets/images/colorbox/ie6/borderTopRight.png
133
+ - app/assets/images/colorbox/ie6/borderBottomLeft.png
134
+ - app/assets/images/colorbox/ie6/borderTopLeft.png
135
+ - app/assets/images/colorbox/ie6/borderBottomCenter.png
144
136
  - app/assets/images/colorbox/ie6/borderTopCenter.png
145
137
  - app/assets/images/colorbox/ie6/borderMiddleRight.png
146
138
  - app/assets/images/colorbox/ie6/borderBottomRight.png
147
- - app/assets/images/colorbox/ie6/borderBottomCenter.png
148
- - app/assets/images/colorbox/ie6/borderTopLeft.png
149
- - app/assets/images/colorbox/ie6/borderTopRight.png
150
- - app/assets/images/colorbox/ie6/borderBottomLeft.png
151
- - app/assets/images/colorbox/ie6/borderMiddleLeft.png
139
+ - app/assets/images/colorbox/border.png
140
+ - app/assets/images/colorbox/loading_background.png
141
+ - app/assets/images/colorbox/controls.png
142
+ - app/assets/images/colorbox/loading.gif
152
143
  - app/assets/images/colorbox/overlay.png
153
- - app/assets/javascripts/admix/photos.js.erb
154
- - app/assets/javascripts/albums/jquery.jcarousel.min.js
155
- - app/assets/javascripts/albums/show.js.coffee
156
- - app/assets/javascripts/templates/photo_modal_edit.hamlc.erb
157
- - app/assets/javascripts/templates/photo_view.hamlc.erb
158
- - app/assets/javascripts/backbone/templates/photos/index.jst.ejs
159
- - app/assets/javascripts/backbone/templates/photos/upload_index.hamlc.erb
160
- - app/assets/javascripts/backbone/templates/photos/modal.hamlc.erb
161
- - app/assets/javascripts/backbone/templates/photos/show.jst.ejs
162
- - app/assets/javascripts/backbone/templates/photos/edit.jst.ejs
163
- - app/assets/javascripts/backbone/templates/photos/new.jst.ejs
164
- - app/assets/javascripts/backbone/templates/photos/photo.jst.ejs
144
+ - app/assets/images/albums/delete.png
145
+ - app/assets/images/albums/photos.png
146
+ - app/assets/images/albums/rotate_cw.png
147
+ - app/assets/images/albums/rotate_ccw.png
148
+ - app/assets/images/albums/crop.png
149
+ - app/assets/javascripts/application.js
150
+ - app/assets/javascripts/backbone/views/photos/upload_index_view.js.coffee
151
+ - app/assets/javascripts/backbone/views/photos/thumbnail_view.js.coffee
152
+ - app/assets/javascripts/backbone/models/photo.js.coffee
165
153
  - app/assets/javascripts/backbone/templates/photos/thumbnail.hamlc.erb
154
+ - app/assets/javascripts/backbone/templates/photos/upload_index.hamlc.erb
166
155
  - app/assets/javascripts/backbone/application.js.coffee
167
156
  - app/assets/javascripts/backbone/routers/photos_router.js.coffee
168
- - app/assets/javascripts/backbone/models/photo.js.coffee
169
- - app/assets/javascripts/backbone/views/photos/new_view.js.coffee
170
- - app/assets/javascripts/backbone/views/photos/index_view.js.coffee
171
- - app/assets/javascripts/backbone/views/photos/edit_view.js.coffee
172
- - app/assets/javascripts/backbone/views/photos/photo_view.js.coffee
173
- - app/assets/javascripts/backbone/views/photos/upload_index_view.js.coffee
174
- - app/assets/javascripts/backbone/views/photos/show_view.js.coffee
175
- - app/assets/javascripts/backbone/views/photos/thumbnail_view.js.coffee
157
+ - app/assets/javascripts/admix/photos.js.erb
158
+ - app/assets/javascripts/views/fileview.js
159
+ - app/assets/javascripts/views/filezipview.js
160
+ - app/assets/javascripts/views/photo_modal_view.js.coffee
161
+ - app/assets/javascripts/views/filelistview.js
176
162
  - app/assets/javascripts/photos/upload.js.coffee.erb
163
+ - app/assets/javascripts/models/filezip.js
164
+ - app/assets/javascripts/models/fileitem.js
177
165
  - app/assets/javascripts/collections/filelist.js
166
+ - app/assets/javascripts/templates/photo_view.hamlc.erb
167
+ - app/assets/javascripts/templates/photo_modal_edit.hamlc.erb
178
168
  - app/assets/javascripts/routers/photo_router.js.coffee.erb
179
- - app/assets/javascripts/models/fileitem.js
180
- - app/assets/javascripts/models/filezip.js
181
- - app/assets/javascripts/application.js
182
- - app/assets/javascripts/views/filelistview.js
183
- - app/assets/javascripts/views/photo_modal_view.js.coffee
184
- - app/assets/javascripts/views/filezipview.js
185
- - app/assets/javascripts/views/fileview.js
186
- - app/helpers/admix/albums_helper.rb
187
- - app/models/admix/photos_datagrid.rb
188
- - app/models/admix/albums_datagrid.rb
189
- - app/models/album.rb
190
- - app/models/photo.rb
191
- - app/views/admix/albums/_show.html.haml
192
- - app/views/admix/albums/_table_actions.html.haml
193
- - app/views/admix/albums/_form_fields.html.haml
169
+ - app/assets/javascripts/albums/show.js.coffee
170
+ - app/assets/javascripts/albums/jquery.jcarousel.min.js
194
171
  - app/views/admix/photos/index.html.haml
195
172
  - app/views/admix/photos/_upload.html.haml
173
+ - app/views/admix/albums/_form_fields.html.haml
174
+ - app/views/admix/albums/_table_actions.html.haml
175
+ - app/views/admix/albums/_show.html.haml
196
176
  - app/views/albums/index.html.haml
197
177
  - app/views/albums/show.html.haml
198
- - config/locales/photos.pt-BR.yml
199
- - config/locales/albums.pt-BR.yml
200
- - config/locales/albums.en.yml
178
+ - app/controllers/albums_controller.rb
179
+ - app/controllers/admix/albums_controller.rb
180
+ - app/controllers/admix/photos_controller.rb
181
+ - app/models/album.rb
182
+ - app/models/admix/photos_datagrid.rb
183
+ - app/models/admix/albums_datagrid.rb
184
+ - app/models/photo.rb
185
+ - app/helpers/admix/albums_helper.rb
186
+ - app/uploaders/albums/image_uploader.rb
201
187
  - config/initializers/carrierwave.rb
202
188
  - config/initializers/albums.rb
203
189
  - config/routes.rb
204
190
  - config/application.rb
191
+ - config/locales/photos.pt-BR.yml
192
+ - config/locales/albums.pt-BR.yml
193
+ - config/locales/albums.en.yml
205
194
  - lib/tasks/albums_tasks.rake
206
- - lib/mix-rails-albums.rb
207
195
  - lib/mix-rails-albums/version.rb
208
196
  - lib/mix-rails-albums/engine.rb
197
+ - lib/mix-rails-albums.rb
209
198
  - MIT-LICENSE
210
199
  - Rakefile
211
200
  - README.rdoc
@@ -223,7 +212,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
223
212
  version: '0'
224
213
  segments:
225
214
  - 0
226
- hash: -408504066564617472
215
+ hash: -3421642337988709305
227
216
  required_rubygems_version: !ruby/object:Gem::Requirement
228
217
  none: false
229
218
  requirements:
@@ -232,7 +221,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
232
221
  version: '0'
233
222
  segments:
234
223
  - 0
235
- hash: -408504066564617472
224
+ hash: -3421642337988709305
236
225
  requirements: []
237
226
  rubyforge_project:
238
227
  rubygems_version: 1.8.24
@@ -1,20 +0,0 @@
1
- <h1>Edit photo</h1>
2
-
3
- <form id="edit-photo" name="photo">
4
- <div class="field">
5
- <label for="image"> image:</label>
6
- <input type="text" name="image" id="image" value="<%= image %>" >
7
- </div>
8
-
9
- <div class="field">
10
- <label for="description"> description:</label>
11
- <input type="text" name="description" id="description" value="<%= description %>" >
12
- </div>
13
-
14
- <div class="actions">
15
- <input type="submit" value="Update Photo" />
16
- </div>
17
-
18
- </form>
19
-
20
- <a href="#/index">Back</a>
@@ -1,15 +0,0 @@
1
- <h1>Listing photos</h1>
2
-
3
- <table id="photos-table">
4
- <tr>
5
- <th>Image</th>
6
- <th>Description</th>
7
- <th></th>
8
- <th></th>
9
- <th></th>
10
- </tr>
11
- </table>
12
-
13
- <br/>
14
-
15
- <a href="#/new">New Photo</a>
@@ -1,14 +0,0 @@
1
- .modal.hide.fade.admix-photo-modal{id: "photo-modal-#{@id}"}
2
- .modal-header
3
- %button.close{"aria-hidden" => "true", "data-dismiss" => "modal", :type => "button"} ×
4
- %h3 Detalhes da foto
5
- .modal-body
6
- .edit-area.pull-right
7
- %textarea.span5{id: "input_photo_description_#{@id}",placeholder: 'Adicione uma descrição para esta foto.'}
8
- #{@description}
9
- .photo
10
- %img{src: @image.medium.url}
11
- %p One fine body…
12
- .modal-footer
13
- %a.btn{href:"#", "data-dismiss": "modal"} Cancelar
14
- %a.btn.btn-primary.save{:href => "#"} Salvar mudanças
@@ -1,20 +0,0 @@
1
- <h1>New photo</h1>
2
-
3
- <form id="new-photo" name="photo">
4
- <div class="field">
5
- <label for="image"> image:</label>
6
- <input type="text" name="image" id="image" value="<%= image %>" >
7
- </div>
8
-
9
- <div class="field">
10
- <label for="description"> description:</label>
11
- <input type="text" name="description" id="description" value="<%= description %>" >
12
- </div>
13
-
14
- <div class="actions">
15
- <input type="submit" value="Create Photo" />
16
- </div>
17
-
18
- </form>
19
-
20
- <a href="#/index">Back</a>
@@ -1,6 +0,0 @@
1
- <td><%= image %></td>
2
- <td><%= description %></td>
3
-
4
- <td><a href="#/<%= id %>">Show</td>
5
- <td><a href="#/<%= id %>/edit">Edit</td>
6
- <td><a href="#/<%= id %>/destroy" class="destroy">Destroy</a></td>
@@ -1,12 +0,0 @@
1
- <p>
2
- <b>Image:</b>
3
- <%= image %>
4
- </p>
5
-
6
- <p>
7
- <b>Description:</b>
8
- <%= description %>
9
- </p>
10
-
11
-
12
- <a href="#/index">Back</a>
@@ -1,24 +0,0 @@
1
- Application.Views.Photos ||= {}
2
-
3
- class Application.Views.Photos.EditView extends Backbone.View
4
- template: JST["backbone/templates/photos/edit"]
5
-
6
- events:
7
- "submit #edit-photo": "update"
8
-
9
- update: (e) ->
10
- e.preventDefault()
11
- e.stopPropagation()
12
-
13
- @model.save(null,
14
- success: (photo) =>
15
- @model = photo
16
- window.location.hash = "/#{@model.id}"
17
- )
18
-
19
- render: ->
20
- @$el.html(@template(@model.toJSON() ))
21
-
22
- this.$("form").backboneLink(@model)
23
-
24
- return this
@@ -1,20 +0,0 @@
1
- Application.Views.Photos ||= {}
2
-
3
- class Application.Views.Photos.IndexView extends Backbone.View
4
- template: JST["backbone/templates/photos/index"]
5
-
6
- initialize: () ->
7
- @options.photos.bind('reset', @addAll)
8
-
9
- addAll: () =>
10
- @options.photos.each(@addOne)
11
-
12
- addOne: (photo) =>
13
- view = new Application.Views.Photos.PhotoView({model : photo})
14
- @$("tbody").append(view.render().el)
15
-
16
- render: =>
17
- @$el.html(@template(photos: @options.photos.toJSON() ))
18
- @addAll()
19
-
20
- return this
@@ -1,37 +0,0 @@
1
- Application.Views.Photos ||= {}
2
-
3
- class Application.Views.Photos.NewView extends Backbone.View
4
- template: JST["backbone/templates/photos/new"]
5
-
6
- events:
7
- "submit #new-photo": "save"
8
-
9
- constructor: (options) ->
10
- super(options)
11
- @model = new @collection.model()
12
-
13
- @model.bind("change:errors", () =>
14
- this.render()
15
- )
16
-
17
- save: (e) ->
18
- e.preventDefault()
19
- e.stopPropagation()
20
-
21
- @model.unset("errors")
22
-
23
- @collection.create(@model.toJSON(),
24
- success: (photo) =>
25
- @model = photo
26
- window.location.hash = "/#{@model.id}"
27
-
28
- error: (photo, jqXHR) =>
29
- @model.set({errors: $.parseJSON(jqXHR.responseText)})
30
- )
31
-
32
- render: ->
33
- @$el.html(@template(@model.toJSON() ))
34
-
35
- this.$("form").backboneLink(@model)
36
-
37
- return this
@@ -1,19 +0,0 @@
1
- Application.Views.Photos ||= {}
2
-
3
- class Application.Views.Photos.PhotoView extends Backbone.View
4
- template: JST["backbone/templates/photos/photo"]
5
-
6
- events:
7
- "click .destroy" : "destroy"
8
-
9
- tagName: "tr"
10
-
11
- destroy: () ->
12
- @model.destroy()
13
- this.remove()
14
-
15
- return false
16
-
17
- render: ->
18
- @$el.html(@template(@model.toJSON() ))
19
- return this
@@ -1,8 +0,0 @@
1
- Application.Views.Photos ||= {}
2
-
3
- class Application.Views.Photos.ShowView extends Backbone.View
4
- template: JST["backbone/templates/photos/show"]
5
-
6
- render: ->
7
- @$el.html(@template(@model.toJSON() ))
8
- return this