lato_media 2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +27 -0
  4. data/Rakefile +5 -0
  5. data/app/assets/config/lato_media_manifest.js +2 -0
  6. data/app/assets/javascripts/lato_media/application.js +18 -0
  7. data/app/assets/javascripts/lato_media/initializers/Inputs.js +62 -0
  8. data/app/assets/javascripts/lato_media/interfaces/MediaSelector.js +128 -0
  9. data/app/assets/stylesheets/lato_media/application.scss +17 -0
  10. data/app/assets/stylesheets/lato_media/cells/_cells.scss +2 -0
  11. data/app/assets/stylesheets/lato_media/cells/elements/_elements.scss +2 -0
  12. data/app/assets/stylesheets/lato_media/cells/elements/_preview.scss +67 -0
  13. data/app/assets/stylesheets/lato_media/cells/elements/_previews.scss +23 -0
  14. data/app/assets/stylesheets/lato_media/cells/inputs/_gallery.scss +13 -0
  15. data/app/assets/stylesheets/lato_media/cells/inputs/_inputs.scss +2 -0
  16. data/app/assets/stylesheets/lato_media/cells/inputs/_media.scss +25 -0
  17. data/app/assets/stylesheets/lato_media/pages/_medias.scss +20 -0
  18. data/app/assets/stylesheets/lato_media/pages/_pages.scss +1 -0
  19. data/app/assets/stylesheets/lato_media/partials/_media_selector.scss +53 -0
  20. data/app/assets/stylesheets/lato_media/partials/_partials.scss +1 -0
  21. data/app/assets/stylesheets/lato_media/theme.scss.erb +12 -0
  22. data/app/cells/lato_media/elements/preview/cell.rb +44 -0
  23. data/app/cells/lato_media/elements/preview/views/general.html.erb +14 -0
  24. data/app/cells/lato_media/elements/preview/views/image.html.erb +10 -0
  25. data/app/cells/lato_media/elements/preview/views/not_found.html.erb +15 -0
  26. data/app/cells/lato_media/elements/preview/views/show.html.erb +33 -0
  27. data/app/cells/lato_media/elements/previews/cell.rb +37 -0
  28. data/app/cells/lato_media/elements/previews/views/show.html.erb +43 -0
  29. data/app/cells/lato_media/inputs/gallery/cell.rb +80 -0
  30. data/app/cells/lato_media/inputs/gallery/views/show.html.erb +39 -0
  31. data/app/cells/lato_media/inputs/media/cell.rb +64 -0
  32. data/app/cells/lato_media/inputs/media/views/show.html.erb +40 -0
  33. data/app/controllers/lato_media/application_controller.rb +13 -0
  34. data/app/controllers/lato_media/back/back_controller.rb +13 -0
  35. data/app/controllers/lato_media/back/media_selector_controller.rb +43 -0
  36. data/app/controllers/lato_media/back/medias_controller.rb +101 -0
  37. data/app/controllers/lato_media/doc/cells_controller.rb +43 -0
  38. data/app/controllers/lato_media/doc/doc_controller.rb +17 -0
  39. data/app/controllers/lato_media/doc/general_controller.rb +9 -0
  40. data/app/helpers/lato_media/application_helper.rb +4 -0
  41. data/app/jobs/lato_media/application_job.rb +4 -0
  42. data/app/mailers/lato_media/application_mailer.rb +6 -0
  43. data/app/models/lato_media/application_record.rb +5 -0
  44. data/app/models/lato_media/media/entity_helpers.rb +15 -0
  45. data/app/models/lato_media/media.rb +26 -0
  46. data/app/views/lato_media/back/media_selector/load_form.js.erb +9 -0
  47. data/app/views/lato_media/back/media_selector/load_index.js.erb +6 -0
  48. data/app/views/lato_media/back/media_selector/load_inputs_gallery.js.erb +6 -0
  49. data/app/views/lato_media/back/media_selector/load_inputs_media.js.erb +6 -0
  50. data/app/views/lato_media/back/medias/edit.html.erb +51 -0
  51. data/app/views/lato_media/back/medias/index.html.erb +25 -0
  52. data/app/views/lato_media/back/medias/new.html.erb +25 -0
  53. data/app/views/lato_media/back/medias/refresh_index.js.erb +11 -0
  54. data/app/views/lato_media/back/medias/shared/_dropzone_modal.html.erb +12 -0
  55. data/app/views/lato_media/back/medias/shared/_form.html.erb +52 -0
  56. data/app/views/lato_media/back/medias/shared/_index.html.erb +14 -0
  57. data/app/views/lato_media/doc/cells/elements_preview.html.erb +241 -0
  58. data/app/views/lato_media/doc/cells/elements_previews.html.erb +87 -0
  59. data/app/views/lato_media/doc/cells/inputs_gallery.html.erb +63 -0
  60. data/app/views/lato_media/doc/cells/inputs_media.html.erb +63 -0
  61. data/app/views/lato_media/doc/doc/index.html.erb +59 -0
  62. data/app/views/lato_media/doc/general/installation.html.erb +49 -0
  63. data/app/views/lato_media/doc/general/personalization.html.erb +0 -0
  64. data/app/views/lato_media/partials/_media_selector.html.erb +12 -0
  65. data/app/views/lato_media/partials/media_selector/_modal.html.erb +16 -0
  66. data/app/views/lato_media/partials/media_selector/_modal_form.html.erb +6 -0
  67. data/app/views/lato_media/partials/media_selector/_modal_index.html.erb +18 -0
  68. data/config/configs.yml +50 -0
  69. data/config/initializers/assets.rb +4 -0
  70. data/config/languages/default.yml +39 -0
  71. data/config/languages/it.yml +39 -0
  72. data/config/routes/api.rb +3 -0
  73. data/config/routes/back.rb +9 -0
  74. data/config/routes/doc.rb +15 -0
  75. data/config/routes.rb +16 -0
  76. data/db/migrate/20160224181218_create_lato_media_media.rb +15 -0
  77. data/lib/lato_media/engine.rb +16 -0
  78. data/lib/lato_media/version.rb +3 -0
  79. data/lib/lato_media.rb +5 -0
  80. data/lib/tasks/lato_media_tasks.rake +4 -0
  81. metadata +179 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d98dcf681865bedf65da24fa84faf6de698dafcf
4
+ data.tar.gz: 1b59c4832da05d4f69385656040ebf2f8ec78be3
5
+ SHA512:
6
+ metadata.gz: c11d7f15b2b5f721605dcb39120f7ccedef89355a81f0fefb49f777d3ae7894762763961758dc740d60751f967e168ad932c2f5e7a5e9da6728a0f67c8d6d7f0
7
+ data.tar.gz: 5622ff9d9ccea5382d9da718d7d3e7c1d6176db3b029a49a82d131b28dae3847dfb79018a598fc66936ba04359818f498aa04ed15ce1007f660c5ae7a317eb54
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2017 Gregorio Galante
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,27 @@
1
+ # Lato Media
2
+
3
+ ## Installation
4
+
5
+ Add the lato_media gem on your Gemfile
6
+
7
+ ```ruby
8
+ gem 'lato_media'
9
+ ```
10
+
11
+ Install the gem
12
+
13
+ ```console
14
+ bundle install
15
+ ```
16
+
17
+ Copy the migrations
18
+
19
+ ```console
20
+ rails lato_media:install:migrations
21
+ ```
22
+
23
+ Exec migrations
24
+
25
+ ```console
26
+ bundle exec rake db:migrate
27
+ ```
data/Rakefile ADDED
@@ -0,0 +1,5 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
@@ -0,0 +1,2 @@
1
+ //= link_directory ../javascripts/lato_media .js
2
+ //= link_directory ../stylesheets/lato_media .css
@@ -0,0 +1,18 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file. JavaScript code in this file should be added after the last require_* statement.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree ./initializers
14
+ //= require_tree ./interfaces
15
+
16
+ $(window).load(function () {
17
+ MediaInputsInitializer.init()
18
+ })
@@ -0,0 +1,62 @@
1
+ var MediaInputsInitializer = (function () {
2
+
3
+ function initializeMedia () {
4
+ $('.inputs-media .inputs-media__input').change(function () {
5
+ // get utils data
6
+ var id = $(this).attr('id')
7
+ var media = $('#inputs-media-' + id)
8
+ var input = $(media).find('.inputs-media__input')
9
+ var action = $(media).find('.inputs-media__reload')
10
+ var value = $(input).attr('value')
11
+ // generate new url
12
+ var url = action.attr('href')
13
+ url = _updateQueryStringParameter(url, 'id', id)
14
+ url = _updateQueryStringParameter(url, 'value', value)
15
+ // update url and send request
16
+ $(action).attr('href', url)
17
+ $(action).trigger('click')
18
+ })
19
+ }
20
+
21
+ function initializeGallery () {
22
+ $('.inputs-gallery .inputs-gallery__input').change(function () {
23
+ // get utils data
24
+ var id = $(this).attr('id')
25
+ var gallery = $('#inputs-gallery-' + id)
26
+ var input = $(gallery).find('.inputs-gallery__input')
27
+ var action = $(gallery).find('.inputs-gallery__reload')
28
+ var value = $(input).attr('value')
29
+ // generate new url
30
+ var url = action.attr('href')
31
+ url = _updateQueryStringParameter(url, 'id', id)
32
+ url = _updateQueryStringParameter(url, 'value', value)
33
+ // update url and send request
34
+ $(action).attr('href', url)
35
+ $(action).trigger('click')
36
+ })
37
+ }
38
+
39
+ // This function updates uri params.
40
+ function _updateQueryStringParameter(uri, key, value) {
41
+ var re = new RegExp("([?&])" + key + "=.*?(&|$)", "i");
42
+ var separator = uri.indexOf('?') !== -1 ? "&" : "?";
43
+ if (uri.match(re)) {
44
+ return uri.replace(re, '$1' + key + "=" + value + '$2');
45
+ }
46
+ else {
47
+ return uri + separator + key + "=" + value;
48
+ }
49
+ }
50
+
51
+ // Init:
52
+
53
+ function init () {
54
+ initializeMedia()
55
+ initializeGallery()
56
+ }
57
+
58
+ return {
59
+ init: init
60
+ }
61
+
62
+ })()
@@ -0,0 +1,128 @@
1
+ var MediaSelector = (function () {
2
+
3
+ // This is the main function used to active the media selector.
4
+ // The inputId is the input used by the selector to save the selected data.
5
+ // The maxItems is a possible option used to set how many images can be selected.
6
+ function open (inputId, maxItems, event) {
7
+ if (!maxItems) { maxItems = 1 }
8
+ if (event) { event.preventDefault() }
9
+ // listen events on modal
10
+ _listenLoadIndexAction(inputId, maxItems)
11
+ _listenCancelButtonAction(inputId)
12
+ _listenListButtonAction(inputId)
13
+ _listenAddButtonAction(inputId)
14
+ // load index for media selector
15
+ _reloadIndex()
16
+ // open the modal
17
+ Modal.open('media__media_selector')
18
+ }
19
+
20
+ // This function closes the media selector and remove all event watcher on it.
21
+ function close (event) {
22
+ if (event) { event.preventDefault() }
23
+ // remove event listener
24
+ $('#media__media_selector').unbind('loadIndexAction')
25
+ $('#media__media_selector_cancel_button').unbind('click')
26
+ // close the modal
27
+ Modal.close('media__media_selector')
28
+ }
29
+
30
+ // This function reload the index list for the medias.
31
+ function _reloadIndex () {
32
+ $('#media__media_selector_load_index').trigger('click')
33
+ }
34
+
35
+ // This functions listens the dom cha on the media selector and run the correct actions.
36
+ function _listenLoadIndexAction (inputId, maxItems) {
37
+ $('#media__media_selector').bind('loadIndexAction', function () {
38
+ // update active medias
39
+ _updateActiveMedias(inputId)
40
+ // listen medias click action
41
+ var medias = $('#media__media_selector .partials__media-selector-index-list .elements-preview')
42
+ $(medias).click(function () {
43
+ var mediaId = $(this).attr('data-media-id')
44
+ // update input with selected medias
45
+ _updateInput(mediaId, inputId, maxItems)
46
+ // update view for selected media
47
+ _updateActiveMedias(inputId)
48
+ })
49
+ })
50
+ }
51
+
52
+ // This function listens the click on cancel button to clear the input.
53
+ function _listenCancelButtonAction (inputId) {
54
+ $('#media__media_selector_cancel_button').bind('click', function (e) {
55
+ e.preventDefault()
56
+ var input = $('#' + inputId)
57
+ $(input).val('')
58
+ $(input).trigger('change')
59
+ close()
60
+ })
61
+ }
62
+
63
+ // This function listens the click on add button to update the input.
64
+ function _listenAddButtonAction (inputId) {
65
+ $('#media__media_selector_add_button').bind('click', function (e) {
66
+ e.preventDefault()
67
+ $('#media__media_selector_load_form').trigger('click')
68
+ })
69
+ }
70
+
71
+ // This function listens the click on add button to update the input.
72
+ function _listenListButtonAction (inputId) {
73
+ $('#media__media_selector_list_button').bind('click', function (e) {
74
+ e.preventDefault()
75
+ $('#media__media_selector_load_index').trigger('click')
76
+ })
77
+ }
78
+
79
+ // This function update the input with a specific id to add / remove a media.
80
+ function _updateInput (mediaId, inputId, maxItems) {
81
+ // find input informations
82
+ var input = $('#' + inputId)
83
+ var inputValue = $(input).val()
84
+ var selectedMedias = inputValue ? inputValue.split(',') : []
85
+ // update selected medias
86
+ var mediaIndex = selectedMedias.indexOf(mediaId)
87
+ if (mediaIndex > -1) {
88
+ selectedMedias.splice(mediaIndex, 1)
89
+ } else {
90
+ if (maxItems > 1 && selectedMedias.length >= maxItems) {
91
+ alert('You can not select other medias')
92
+ return
93
+ }
94
+ if (maxItems > 1) {
95
+ selectedMedias.push(mediaId)
96
+ } else {
97
+ selectedMedias = [mediaId]
98
+ }
99
+ }
100
+ // update input value
101
+ $(input).val(selectedMedias.join())
102
+ $(input).trigger("change") // manually trigger change event
103
+ }
104
+
105
+ // This function update the style to show active medias.
106
+ function _updateActiveMedias (inputId) {
107
+ // find inputs informations
108
+ var input = $('#' + inputId)
109
+ var inputValue = $(input).val()
110
+ var selectedMedias = inputValue.split(',')
111
+ // update style
112
+ var medias = $('#media__media_selector .partials__media-selector-index-list .elements-preview')
113
+ $(medias).each(function () {
114
+ var mediaId = $(this).attr('data-media-id')
115
+ if (selectedMedias.indexOf(mediaId) > -1) {
116
+ $(this).addClass('elements-preview--active')
117
+ } else {
118
+ $(this).removeClass('elements-preview--active')
119
+ }
120
+ })
121
+ }
122
+
123
+ return {
124
+ open: open,
125
+ close: close
126
+ }
127
+
128
+ })()
@@ -0,0 +1,17 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
+ * files in this directory. Styles in this file should be added after the last require_* statement.
11
+ * It is generally better to create a new file per style scope.
12
+ */
13
+
14
+ @import "theme";
15
+ @import "cells/cells";
16
+ @import "partials/partials";
17
+ @import "pages/pages";
@@ -0,0 +1,2 @@
1
+ @import "elements/elements";
2
+ @import "inputs/inputs";
@@ -0,0 +1,2 @@
1
+ @import "preview";
2
+ @import "previews";
@@ -0,0 +1,67 @@
1
+ .elements-preview {
2
+ border: solid 1px $color_grey;
3
+ display: block;
4
+ outline: 0;
5
+ overflow: hidden;
6
+
7
+ &:focus {
8
+ border-color: $color_main;
9
+ }
10
+ }
11
+
12
+ .elements-preview__container {
13
+ position: relative;
14
+ padding-bottom: 100%;
15
+ }
16
+
17
+ .elements-preview__label {
18
+ overflow: hidden;
19
+ white-space: nowrap;
20
+ text-overflow: ellipsis;
21
+ position: absolute;
22
+ left: 50%;
23
+ bottom: 10px;
24
+ right: auto;
25
+ transform: translate(-50%, 0);
26
+ max-width: 70%;
27
+ background: rgba($color_white, 0.85);
28
+ box-shadow: 0px 11px 20px rgba(41, 59, 90, 0.08);
29
+ padding: 5px;
30
+ border-radius: 5px;
31
+ }
32
+
33
+ .elements-preview__icon-container {
34
+ width: 100%;
35
+ height: 100%;
36
+ position: absolute;
37
+ top: 0;
38
+ left: 0;
39
+ background-color: $color_white;
40
+ }
41
+
42
+ .elements-preview__icon {
43
+ position: absolute;
44
+ top: 50%;
45
+ left: 50%;
46
+ transform: translate(-50%, -50%);
47
+ font-size: 50px;
48
+ }
49
+
50
+ .elements-preview__image {
51
+
52
+ }
53
+
54
+ .elements-preview__not-found {
55
+
56
+ }
57
+
58
+ .elements-preview__image-background {
59
+ position: absolute;
60
+ top: 0;
61
+ left: 0;
62
+ width: 100%;
63
+ height: 100%;
64
+ background-size: cover;
65
+ background-position: center;
66
+ background-repeat: no-repeat;
67
+ }
@@ -0,0 +1,23 @@
1
+ .elements-previews {
2
+ outline: 0;
3
+ }
4
+
5
+ .elements-previews__list {
6
+ border-radius: 10px;
7
+ border: solid 1px $color_grey;
8
+ }
9
+
10
+ .elements-previews__not-found {
11
+ border-radius: 10px;
12
+ border: solid 1px $color_grey;
13
+ position: relative;
14
+ width: 100%;
15
+ height: 200px;
16
+
17
+ span {
18
+ position: absolute;
19
+ top: 50%;
20
+ left: 50%;
21
+ transform: translate(-50%, -50%);
22
+ }
23
+ }
@@ -0,0 +1,13 @@
1
+ .inputs-gallery {
2
+
3
+ &:hover {
4
+ .elements-previews__list, .elements-previews__not-found {
5
+ background-color: rgba($color_main, 0.25);
6
+ transition: all 0.25s;
7
+ }
8
+ }
9
+ }
10
+
11
+ .inputs-gallery__reload {
12
+ display: none;
13
+ }
@@ -0,0 +1,2 @@
1
+ @import "media";
2
+ @import "gallery";
@@ -0,0 +1,25 @@
1
+ .inputs-media {
2
+
3
+ &:hover {
4
+ .elements-preview__container {
5
+ background-color: $color_main;
6
+ }
7
+
8
+ .elements-preview__image-background, .elements-preview__icon-container {
9
+ transition: all 0.25s;
10
+ opacity: 0.75;
11
+ }
12
+ }
13
+ }
14
+
15
+ .inputs-media__preview {
16
+
17
+ }
18
+
19
+ .inputs-media__input {
20
+ display: none;
21
+ }
22
+
23
+ .inputs-media__reload {
24
+ display: none;
25
+ }
@@ -0,0 +1,20 @@
1
+ .medias__medias-index {
2
+
3
+ }
4
+
5
+ .medias__dropzone {
6
+ form {
7
+ min-height: 350px;
8
+ }
9
+ }
10
+
11
+ .medias__dropzone-modal-actions {
12
+ position: fixed;
13
+ bottom: 0;
14
+ left: 0;
15
+ width: 100%;
16
+ background: $color_white;
17
+ text-align: right;
18
+ padding: 15px;
19
+ border-top: solid 2px $color_grey;
20
+ }
@@ -0,0 +1 @@
1
+ @import "medias";
@@ -0,0 +1,53 @@
1
+ .partials__media-selector {
2
+
3
+ }
4
+
5
+ .partials__media-selector-actions {
6
+ display: none;
7
+ }
8
+
9
+ .partials__media-selector-index-container {
10
+ padding-bottom: 70px;
11
+ }
12
+
13
+ .partials__media-selector-index {
14
+
15
+ }
16
+
17
+ .partials__media-selector-index-list {
18
+
19
+ .elements-preview {
20
+ cursor: pointer;
21
+ }
22
+
23
+ .elements-preview--active {
24
+ border-color: $color_main;
25
+ background-color: $color_main;
26
+
27
+ .elements-preview__image-background, .elements-preview__icon-container {
28
+ opacity: 0.5;
29
+ }
30
+ }
31
+
32
+ }
33
+
34
+ .partials__media-selector-index-pagination {
35
+ margin-top: 10px;
36
+ }
37
+
38
+ .partials__media-selector-buttons {
39
+ position: fixed;
40
+ bottom: 0;
41
+ left: 0;
42
+ width: 100%;
43
+ background: $color_white;
44
+ text-align: right;
45
+ padding: 15px;
46
+ border-top: solid 2px $color_grey;
47
+ }
48
+
49
+ .partials__media-selector-form {
50
+ form {
51
+ min-height: 350px;
52
+ }
53
+ }
@@ -0,0 +1 @@
1
+ @import "media_selector";
@@ -0,0 +1,12 @@
1
+ <%
2
+ colors = core__get_colors
3
+ %>
4
+
5
+ $color_white: <%= colors[:white] %>;
6
+ $color_black: <%= colors[:black] %>;
7
+ $color_grey: <%= colors[:grey] %>;
8
+ $color_main: <%= colors[:main] %>;
9
+ $color_active: <%= colors[:active] %>;
10
+ $color_danger: <%= colors[:danger] %>;
11
+ $color_warning: <%= colors[:warning] %>;
12
+ $color_success: <%= colors[:success] %>;
@@ -0,0 +1,44 @@
1
+ module LatoMedia
2
+
3
+ class Elements::Preview::Cell < LatoCore::Cell
4
+
5
+ view_paths << "#{LatoMedia::Engine.root}/app/cells"
6
+
7
+ @@requested_args = [:media]
8
+
9
+ @@default_args = {
10
+ class: '',
11
+ size: 'large',
12
+ height: nil,
13
+ url: nil,
14
+ remote: false,
15
+ onclick: ''
16
+ }
17
+
18
+ def initialize(args = {})
19
+ @args = validate_args(
20
+ args: args,
21
+ requested_args: @@requested_args,
22
+ default_args: @@default_args
23
+ )
24
+
25
+ set_conditions
26
+ end
27
+
28
+ def show
29
+ render 'show.html'
30
+ end
31
+
32
+ private
33
+
34
+ def set_conditions
35
+ if @args[:media].image?
36
+ @icon = ''
37
+ else
38
+ @icon = 'file-o'
39
+ end
40
+ end
41
+
42
+ end
43
+
44
+ end
@@ -0,0 +1,14 @@
1
+ <div
2
+ class="elements-preview__container elements-preview__not-found"
3
+ <% if @args[:height] %>
4
+ style="height: <%= @args[:height] %>px; padding-bottom : 0;"
5
+ <% end %>
6
+ >
7
+ <div class="elements-preview__icon-container">
8
+ <div class="elements-preview__icon">
9
+ <i class="fa fa-<%= @icon %>" aria-hidden="true"></i>
10
+ </div>
11
+ </div>
12
+
13
+ <div class="elements-preview__label"><%= @args[:media].title %></div>
14
+ </div>
@@ -0,0 +1,10 @@
1
+ <div
2
+ class="elements-preview__container elements-preview__image"
3
+ <% if @args[:height] %>
4
+ style="height: <%= @args[:height] %>px; padding-bottom : 0;"
5
+ <% end %>
6
+ >
7
+ <div class="elements-preview__image-background" style="background-image: url(<%= @args[:media].attachment.url(@args[:size]) %>)"></div>
8
+
9
+ <div class="elements-preview__label"><%= @args[:media].title %></div>
10
+ </div>
@@ -0,0 +1,15 @@
1
+ <div
2
+ class="elements-preview__container elements-preview__not-found"
3
+ <% if @args[:height] %>
4
+ style="height: <%= @args[:height] %>px; padding-bottom : 0;"
5
+ <% end %>
6
+ >
7
+
8
+ <div class="elements-preview__icon-container">
9
+ <div class="elements-preview__icon">
10
+ <i class="fa fa-ban" aria-hidden="true"></i>
11
+ </div>
12
+ </div>
13
+
14
+ <div class="elements-preview__label"><%= LANGUAGES[:lato_media][:mixed][:file_not_present] %></div>
15
+ </div>
@@ -0,0 +1,33 @@
1
+ <% if @args[:url] %>
2
+ <a
3
+ href="<%= @args[:url] %>"
4
+ class="elements-preview <%= @args[:class] %>"
5
+ onclick="<%= @args[:onclick] %>"
6
+ data-media-id="<%= @args[:media].id %>"
7
+ <% if @args[:remote] %>
8
+ data-remote="true"
9
+ <% end %>
10
+ >
11
+ <% else %>
12
+ <div
13
+ class="elements-preview <%= @args[:class] %>"
14
+ onclick="<%= @args[:onclick] %>"
15
+ data-media-id="<%= @args[:media].id %>"
16
+ >
17
+ <% end %>
18
+
19
+ <% if @args[:media].exists? %>
20
+ <% if @args[:media].image? %>
21
+ <%= render './image.html' %>
22
+ <% else %>
23
+ <%= render './general.html' %>
24
+ <% end %>
25
+ <% else %>
26
+ <%= render './not_found.html' %>
27
+ <% end %>
28
+
29
+ <% if @args[:url] %>
30
+ </a>
31
+ <% else %>
32
+ </div>
33
+ <% end %>