Skip to content
This repository has been archived by the owner on Jul 19, 2021. It is now read-only.

Commit

Permalink
Merge
Browse files Browse the repository at this point in the history
  • Loading branch information
a-barbieri committed Mar 26, 2018
2 parents b8d1dad + 3430996 commit d520858
Show file tree
Hide file tree
Showing 43 changed files with 1,195 additions and 669 deletions.
10 changes: 5 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ GEM
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
ruby_dep (~> 1.2)
loofah (2.2.1)
loofah (2.2.2)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.0)
Expand All @@ -185,7 +185,7 @@ GEM
mini_portile2 (~> 2.3.0)
orm_adapter (0.5.0)
parallel (1.12.1)
parser (2.5.0.4)
parser (2.5.0.5)
ast (~> 2.4.0)
pg (0.21.0)
powerpack (0.1.1)
Expand Down Expand Up @@ -215,8 +215,8 @@ GEM
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
rails-html-sanitizer (1.0.4)
loofah (~> 2.2, >= 2.2.2)
railties (5.1.5)
actionpack (= 5.1.5)
activesupport (= 5.1.5)
Expand Down Expand Up @@ -259,7 +259,7 @@ GEM
ruby-progressbar (1.9.0)
ruby_dep (1.5.0)
rubyzip (1.2.1)
sass (3.5.5)
sass (3.5.6)
sass-listen (~> 4.0.0)
sass-listen (4.0.0)
rb-fsevent (~> 0.9, >= 0.9.4)
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ Here below a list of field types available and their use:
| string | Store a string. No formatting options available. | [source](http://www.rubydoc.info/gems/binda/Binda/String) |
| text | Store a text. TinyMCE let's you format the text as you like. | [source](http://www.rubydoc.info/gems/binda/Binda/Text) |
| image | Store image. | [source](http://www.rubydoc.info/gems/binda/Binda/Image) |
| svg | Store svg. | [source](http://www.rubydoc.info/gems/binda/Binda/Svg) |
| video | Store video. | [source](http://www.rubydoc.info/gems/binda/Binda/Video) |
| audio | Store audio. | [source](http://www.rubydoc.info/gems/binda/Binda/Audio) |
| date | Store a date. | [source](http://www.rubydoc.info/gems/binda/Binda/Date) |
Expand Down Expand Up @@ -440,6 +441,12 @@ You can retrieve field content from a instance of `Binda::Component`, `Binda::Bo
|`get_image_size`| Returns the image size in MB. | [source](http://www.rubydoc.info/gems/binda/Binda/FieldableAssociationHelpers:get_image_size) |
|`get_image_dimension`| Returns a hash { width: xxx, height: xxx } with image dimension. | [source](http://www.rubydoc.info/gems/binda/Binda/FieldableAssociationHelpers:get_image_dimension) |
|`get_image_mime_type`| Returns the mime type of the image. | [source](http://www.rubydoc.info/gems/binda/Binda/FieldableAssociationHelpers:get_image_mime_type) |
|`has_svg`| Returns `true/false`.| [source](http://www.rubydoc.info/gems/binda/Binda/FieldableAssociationHelpers:has_svg) |
|`get_svg_url`| Returns the url of the svg. | [source](http://www.rubydoc.info/gems/binda/Binda/FieldableAssociationHelpers:get_svg_url) |
|`get_svg_path`| Returns the path of the svg. | [source](http://www.rubydoc.info/gems/binda/Binda/FieldableAssociationHelpers:get_svg_path) |
|`get_svg_size`| Returns the svg size in MB. | [source](http://www.rubydoc.info/gems/binda/Binda/FieldableAssociationHelpers:get_svg_size) |
|`get_svg_mime_type`| Returns the mime type of the svg. | [source](http://www.rubydoc.info/gems/binda/Binda/FieldableAssociationHelpers:get_svg_mime_type) |

|`has_video`| Returns `true/false`.| [source](http://www.rubydoc.info/gems/binda/Binda/FieldableAssociationHelpers:has_video) |
|`get_video_url`| Returns the url of the video. | [source](http://www.rubydoc.info/gems/binda/Binda/FieldableAssociationHelpers:get_video_url) |
|`get_video_path`| Returns the path of the video. | [source](http://www.rubydoc.info/gems/binda/Binda/FieldableAssociationHelpers:get_video_path) |
Expand Down
19 changes: 19 additions & 0 deletions app/assets/javascripts/binda/components/fileupload.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ function updateFileuploadField(data, id) {
setup_video_preview(data, id);
} else if (data.type == "audio") {
setup_audio_preview(data, id);
} else if (data.type == "svg") {
setup_svg_preview(data, id);
} else {
alert("Something went wrong. No preview has been received.");
}
Expand Down Expand Up @@ -243,3 +245,20 @@ function setup_audio_preview(data, id) {
$parent.find(".fileupload--filename").text(data.name);
$parent.find(".fileupload--previewlink a").attr("href", data.url);
}

function setup_svg_preview(data, id) {
let $parent = $("#fileupload-" + id);
let $preview = $("#fileupload-" + id + " .fileupload--preview");

// Update thumbnail
$preview.css("background-image", `url(${data.thumbnailUrl})`);

// Remove and add class to trigger css animation
let uploadedClass = "fileupload--preview--uploaded";
$preview.removeClass(uploadedClass).addClass(uploadedClass);

// Update details
$parent.find(".fileupload--filesize").text(data.size);
$parent.find(".fileupload--filename").text(data.name);
$parent.find(".fileupload--previewlink a").attr("href", data.url);
}
Loading

0 comments on commit d520858

Please sign in to comment.