ecm_pictures2_backend 2.0.5 → 2.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2f50752c7159bb9e819a8b43e26fd162866f5fd7
4
- data.tar.gz: d8720154af161c49381c59a756b6b25430822a97
3
+ metadata.gz: b3743c249e5407cbc63a01d94af0d8ee160be989
4
+ data.tar.gz: 47a4bb3d5469f17a221f77765fe380d8ad39efcb
5
5
  SHA512:
6
- metadata.gz: 9a093271ca0f3e9df73dc470d43660aa779d2341193315472394d927be53405f3f582db642cae466e1bd87711c8c9a1bd7431730c7f6b33ef46f17407c69aee6
7
- data.tar.gz: 131e19857af70f387f8fca84fdea17b8c6ba5525953191e0dc22a6a0b08a7f0a70799214d1cc27ca3d9144a3b1dfda15667e8297102d344378f0bbfc7476bd34
6
+ metadata.gz: 1dc7eeda66ea36d8d7bf594a23d33d93529f4130b64d967c7608b3b84d85a3f6f221dbc513422495f06e17a5c7a6d1f9f6d1cee4cd2bbdc10f56062a0e828d0f
7
+ data.tar.gz: 795370db33a9775d06a33267fe3f8dc0c5a7822b8421474841dec4c802135ae5d0a7bb31a87b245e43f73ff0610890538c376aa6542a516d47588f7c9132ce50
@@ -1,39 +1,49 @@
1
- remove_overlays = (elements) ->
2
- $(elements).removeClass('selected')
3
-
4
- add_overlay = (element) ->
5
- element.parent().toggleClass('selected')
6
-
7
- take_snapshot = ->
1
+ take_snapshot = (attribute_name) ->
8
2
  Webcam.snap (data_uri) ->
9
- $('#snapshots').append('<div class="col-xs-12 col-sm-6 col-md-4 col-lg-2"><img class="img-responsive thumbnail" data-onclick-copy-data-to="#ecm_pictures_picture_image_base64" src="'+data_uri+'"/><span class="glyphicon glyphicon-ok overlay" /></div>')
3
+ console.log attribute_name
4
+ snapshot_container = $("[name='snapshots-for-#{attribute_name}']").first()
5
+ img_name = "webcam-snapshot-for-#{attribute_name}"
6
+ img_taken_at = Date.now()
7
+ snapshot_container.append('<div class="col-xs-12 col-sm-6 col-md-4 col-lg-2 thumbnail-with-overlay"><img data-taken-at="'+img_taken_at+'" data-attribute-name="'+attribute_name+'" name="'+img_name+'" class="img-responsive thumbnail webcam-snapshot" src="'+data_uri+'"/><span class="text-success glyphicon glyphicon-ok-circle overlay" style="display: none;" /></div>')
10
8
 
11
9
  $ ->
12
- $('[data-camera-toggle=true]').each (index) ->
10
+ $('[data-webcam-toggle=true]').each (index) ->
13
11
  button = $(@)
14
12
  button.on 'click', ->
15
- camera_container = $(@).data('camera-target')
16
- $(camera_container).css('width', '640px')
17
- $(camera_container).css('height', '480px')
18
- Webcam.attach(camera_container)
13
+ camera_container_name = $(@).data('attribute-name')
14
+ camera_container = $("[name='webcam-for-#{camera_container_name}']").first()
15
+ console.log camera_container
16
+ camera_container.css('width', '640px')
17
+ camera_container.css('height', '480px')
18
+ Webcam.attach(camera_container.attr('id'))
19
19
  false
20
20
 
21
21
  $ ->
22
- $('[data-capture-picture=true]').each (index) ->
22
+ $('[data-webcam-trigger=true]').each (index) ->
23
23
  button = $(@)
24
24
  button.on 'click', ->
25
- take_snapshot()
25
+ attribute_name = $(@).data('attribute-name')
26
+ take_snapshot(attribute_name)
26
27
  false
27
28
 
28
29
  $ ->
29
- $('#snapshots').on 'click', '[data-onclick-copy-data-to]', (e) ->
30
- source = $(@)
31
- source.on 'click', ->
32
- target_id = $(@).attr('data-onclick-copy-data-to')
33
- target = $(target_id)
34
- # raw_image_data = source.attr('src').replace(/^data\:image\/\w+\;base64\,/, '')
35
- raw_image_data = source.attr('src')
36
- target.val(raw_image_data)
37
- remove_overlays($(@).parent().parent().find('.selected'))
38
- add_overlay($(@))
39
- e.preventDefault
30
+ $('.webcam-snapshots').on 'click', 'img.webcam-snapshot', (e) ->
31
+ multiple = $(@).parent().data('multiple')
32
+ console.log multiple
33
+ attribute_name = $(@).data('attribute-name')
34
+ taken_at = $(@).data('taken-at')
35
+ raw_image_data = $(@).attr('src')
36
+ hidden_tag = '<input type="hidden" name="'+attribute_name+'[]" data-taken-at="'+taken_at+'" class="webcam optional" value="'+raw_image_data+'">'
37
+ console.log $("input[name='#{attribute_name}[]']")
38
+ if multiple && (existent = $("input[name='#{attribute_name}[]']")).length
39
+ console.log('Removing already existent tags')
40
+ existent.remove()
41
+ $(@).parent().parent().find('span').hide()
42
+ if (existent = $("input[name='#{attribute_name}[]'][data-taken-at='#{taken_at}']")).length
43
+ console.log('Removing already existent tag')
44
+ existent.remove()
45
+ $(@).parent().find('span').hide()
46
+ else
47
+ console.log('Adding hidden tag')
48
+ $(@).after(hidden_tag)
49
+ $(@).parent().find('span').show()
@@ -1,16 +1,18 @@
1
- #snapshots div.selected {
2
- display: relative;
3
- }
4
-
5
- #snapshots .glyphicon.overlay {
6
- position: absolute;
1
+ .thumbnail-with-overlay .glyphicon.overlay {
7
2
  top: 15px;
8
3
  left: 30px;
9
4
  font-size: 20px;
10
- color: green;
11
- display: none;
5
+ color: light-green;
12
6
  }
13
7
 
14
8
  #snapshots div.selected > .glyphicon.overlay {
15
9
  display: inline-block;
10
+ }
11
+
12
+ .thumbnail-with-overlay {
13
+ display: relative;
14
+ }
15
+
16
+ .thumbnail-with-overlay .overlay {
17
+ position: absolute;
16
18
  }
@@ -6,8 +6,20 @@ class Ecm::Pictures::Backend::PictureGalleriesController < Itsf::Backend::Resour
6
6
  private
7
7
 
8
8
  def permitted_params
9
- params
10
- .require(:ecm_pictures_picture_gallery)
11
- .permit(:name, :markup_language, :description, :link_images, :tag_list, picture_images: [])
9
+ # raise params.inspect
10
+ picture_images_base_64 = params[:ecm_pictures_picture_gallery].delete(:picture_images_base_64)
11
+ picture_images = picture_images_base_64.collect do |data|
12
+ Tempfile.new(['image', '.jpg']).tap do |t|
13
+ t.write(Base64.decode64(data.gsub(/^data\:image\/\w+\;base64\,/, '')).force_encoding('UTF-8'))
14
+ t.rewind
15
+ end
16
+ end
17
+ # raise picture_images.inspect
18
+ p = params.require(:ecm_pictures_picture_gallery).permit(:name, :markup_language, :description, :link_images, :tag_list, picture_images: [])
19
+ if picture_images.any?
20
+ p.merge(picture_images: picture_images)
21
+ else
22
+ p
23
+ end
12
24
  end
13
25
  end
@@ -0,0 +1,10 @@
1
+ class WebcamInput < SimpleForm::Inputs::Base
2
+ def input
3
+ multiple = input_options.delete(:multiple)
4
+ if multiple
5
+ template.render partial: 'inputs/webcam_multiple', locals: { f: @builder, attribute_name: attribute_name, input_options: input_options, input_html_options: input_html_options }
6
+ else
7
+ template.render partial: 'inputs/webcam', locals: { f: @builder, attribute_name: attribute_name, input_options: input_options, input_html_options: input_html_options }
8
+ end
9
+ end
10
+ end
@@ -11,6 +11,10 @@
11
11
  .well
12
12
  = form.input :picture_images, as: :file, input_html: { multiple: 'multiple' }
13
13
 
14
+ - if Ecm::Pictures::Backend::Configuration.enable_html5_camera_support
15
+ .well
16
+ = form.input :picture_images, as: :webcam, multiple: true
17
+
14
18
  - if form.object.respond_to?(:tag_list)
15
19
  .well
16
20
  = form.input :tag_list, input_html: { value: form.object.tag_list.to_s }
@@ -13,13 +13,8 @@
13
13
  = image_tag(form.object.image.url(:default_thumb)) if form.object.image.present?
14
14
 
15
15
  - if Ecm::Pictures::Backend::Configuration.enable_html5_camera_support
16
- %input{ name: 'ecm_pictures_picture[image_base64]', type: 'hidden', id: 'ecm_pictures_picture_image_base64', value: '' }
17
16
  .well
18
- .bottom-margin-1
19
- = link_to(t('.enable_camera'), '#', class: 'btn btn-primary', data: { 'camera-toggle': true, 'camera-target': '#camera' })
20
- = link_to(t('.capture_picture'), '#', class: 'btn btn-primary', data: { 'capture-picture': true, 'camera-target': '#camera' })
21
- #camera.bottom-margin-1
22
- #snapshots.row
17
+ = form.input :picture_images, as: :webcam
23
18
 
24
19
  - if form.object.respond_to?(:tag_list)
25
20
  .well
@@ -0,0 +1,7 @@
1
+ .webcam-controls.bottom-margin-1
2
+ = link_to(t('.enable_camera'), '#', class: 'btn btn-primary', data: { 'webcam-toggle': true, 'attribute-name': "#{f.object.class.name.underscore.gsub('/', '_')}[#{attribute_name}_base_64]" })
3
+ = link_to(t('.capture_picture'), '#', class: 'btn btn-primary', data: { 'webcam-trigger': true, 'attribute-name': "#{f.object.class.name.underscore.gsub('/', '_')}[#{attribute_name}_base_64]" })
4
+
5
+ .webcam.bottom-margin-1{ id: "webcam-for-#{f.object.class.name.underscore.gsub('/', '_')}_#{attribute_name}_base_64", name: "webcam-for-#{f.object.class.name.underscore.gsub('/', '_')}[#{attribute_name}_base_64]" }
6
+
7
+ .webcam-snapshots.row{ 'data-multiple': "false", id: "snapshots-for-#{f.object.class.name.underscore.gsub('/', '_')}_#{attribute_name}_base_64", name: "snapshots-for-#{f.object.class.name.underscore.gsub('/', '_')}[#{attribute_name}_base_64]" }
@@ -0,0 +1,7 @@
1
+ .webcam-controls.bottom-margin-1
2
+ = link_to(t('.enable_camera'), '#', class: 'btn btn-primary', data: { 'webcam-toggle': true, 'attribute-name': "#{f.object.class.name.underscore.gsub('/', '_')}[#{attribute_name}_base_64]" })
3
+ = link_to(t('.capture_picture'), '#', class: 'btn btn-primary', data: { 'webcam-trigger': true, 'attribute-name': "#{f.object.class.name.underscore.gsub('/', '_')}[#{attribute_name}_base_64]" })
4
+
5
+ .webcam.bottom-margin-1{ id: "webcam-for-#{f.object.class.name.underscore.gsub('/', '_')}_#{attribute_name}_base_64", name: "webcam-for-#{f.object.class.name.underscore.gsub('/', '_')}[#{attribute_name}_base_64]" }
6
+
7
+ .webcam-snapshots.multiple.row{ 'data-multiple': "true", id: "snapshots-for-#{f.object.class.name.underscore.gsub('/', '_')}_#{attribute_name}_base_64", name: "snapshots-for-#{f.object.class.name.underscore.gsub('/', '_')}[#{attribute_name}_base_64]" }
@@ -1,6 +1,13 @@
1
1
  de:
2
2
  classes:
3
3
  ecm/pictures/backend/engine: 'Bilder'
4
+ inputs:
5
+ webcam:
6
+ capture_picture: Auslösen
7
+ enable_camera: Kamera aktivieren
8
+ webcam_multiple:
9
+ capture_picture: Auslösen
10
+ enable_camera: Kamera aktivieren
4
11
  routes:
5
12
  mount:
6
13
  ecm_pictures_backend: '/backend/bilder'
@@ -0,0 +1,13 @@
1
+ en:
2
+ classes:
3
+ ecm/pictures/backend/engine: 'Pictures'
4
+ inputs:
5
+ webcam:
6
+ capture_picture: Capture picture
7
+ enable_camera: Enable camera
8
+ webcam_multiple:
9
+ capture_picture: Capture picture
10
+ enable_camera: Enable camera
11
+ routes:
12
+ mount:
13
+ ecm_pictures_backend: '/backend/pictures'
@@ -8,6 +8,8 @@ module Ecm
8
8
  app.config.assets.precompile << 'ecm_pictures_backend.js'
9
9
  app.config.assets.precompile << 'ecm_pictures_backend.css'
10
10
  end
11
+
12
+ config.autoload_paths << root.join(*%w(app inputs))
11
13
  end
12
14
  end
13
15
  end
@@ -1,7 +1,7 @@
1
1
  module Ecm
2
2
  module Pictures
3
3
  module Backend
4
- VERSION = '2.0.5'.freeze
4
+ VERSION = '2.0.6'.freeze
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ecm_pictures2_backend
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.5
4
+ version: 2.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roberto Vasquez Angel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-10 00:00:00.000000000 Z
11
+ date: 2016-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -228,6 +228,7 @@ files:
228
228
  - app/controllers/ecm/pictures/backend/picture_galleries_controller.rb
229
229
  - app/controllers/ecm/pictures/backend/pictures_controller.rb
230
230
  - app/helpers/ecm/pictures/backend/application_helper.rb
231
+ - app/inputs/webcam_input.rb
231
232
  - app/policies/ecm/pictures/backend/engine_policy.rb
232
233
  - app/policies/ecm/pictures/picture_gallery_policy.rb
233
234
  - app/policies/ecm/pictures/picture_policy.rb
@@ -238,8 +239,11 @@ files:
238
239
  - app/views/ecm/pictures/backend/pictures/_form.html.haml
239
240
  - app/views/ecm/pictures/backend/pictures/_show.html.haml
240
241
  - app/views/ecm/pictures/backend/pictures/_table.html.haml
242
+ - app/views/inputs/_webcam.haml
243
+ - app/views/inputs/_webcam_multiple.haml
241
244
  - app/views/layouts/ecm/pictures/backend/application.html.erb
242
245
  - config/locales/de.yml
246
+ - config/locales/en.yml
243
247
  - config/rbac.yml
244
248
  - config/routes.rb
245
249
  - lib/ecm/pictures/backend.rb
@@ -276,3 +280,4 @@ signing_key:
276
280
  specification_version: 4
277
281
  summary: Backend Module for ECM Pictures 2
278
282
  test_files: []
283
+ has_rdoc: