spina-slider 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,39 @@
1
+ let hidden_input = $("input[data-hidden-field-id='<%= j params[:hidden_field_id] %>']");
2
+ hidden_input.parents('.media_picker').find('.image').remove();
3
+ hidden_input.val("");
4
+
5
+ <% if @image.present? %>
6
+ hidden_input.parents('.media_picker').append("<%=j render partial: 'spina/admin/images/image', object: @image, locals: {simple: true} %>");
7
+ hidden_input.val("<%= @image.id %>");
8
+
9
+ // Trix editor
10
+ <% if params[:trix_toolbar_id].present? %>
11
+ <% if params[:slider].present? %>
12
+ <% if params[:slider] == 'first' %>
13
+ $('trix-editor[toolbar="<%= params[:trix_toolbar_id] %>"]').trigger('first-photo-selected', ["<%= main_app.url_for(@image.file) %>", "<%= params[:alt] %>", "<%= params[:link_to_url] %>"]);
14
+ <% elsif params[:slider] == 'second' %>
15
+ $('trix-editor[toolbar="<%= params[:trix_toolbar_id] %>"]').trigger('second-photo-selected', ["<%= main_app.url_for(@image.file) %>", "<%= params[:alt] %>", "<%= params[:link_to_url] %>"]);
16
+ <% end %>
17
+ <% else %>
18
+ $('trix-editor[toolbar="<%= params[:trix_toolbar_id] %>"]').trigger('image-insert', ["<%= main_app.url_for(@image.file) %>", "<%= params[:alt] %>", "<%= params[:link_to_url] %>"]);
19
+ <% end %>
20
+ $.hideModal();
21
+ <% end %>
22
+ <% end %>
23
+
24
+ <% if @images.present? %>
25
+ let image_collection = $("<%= j render partial: 'spina/admin/image_collections/image_collection', locals: {images: @images} %>");
26
+ hidden_input.parents('.horizontal-form-content').find('.image-collection').html(image_collection);
27
+ hidden_input.val("<%= @images.map(&:id).join(',') %>");
28
+ <% end %>
29
+
30
+ $('.sortable-grid').sortable().bind('sortupdate', function(e) {
31
+ position_array = [];
32
+ $(e.target).find('li.image').each(function(index) {
33
+ position_array.push($(this).data('image-id'));
34
+ });
35
+ $(e.target).parents('.horizontal-form-content').find('.images-positions').val(position_array.join(","));
36
+ });
37
+ $('.sortable-grid').trigger('sortupdate');
38
+
39
+ $.hideModal();
@@ -0,0 +1 @@
1
+ $("<%=j render partial: 'modal', locals: {multiple: params[:multiple], slider: params[:slider]} %>").modal();
@@ -0,0 +1,9 @@
1
+ = render partial: 'spina/admin/partables/texts/slider_js', locals: { editor_id: object_id}
2
+
3
+ .horizontal-form-label
4
+ = f.object.title
5
+ .horizontal-form-content
6
+ = f.fields_for :partable, f.object.partable do |ff|
7
+ - object_id = (ff.object.persisted? ? ff.object.object_id : "new_association_#{ff.object.object_id}").to_s + "_content"
8
+ = ff.hidden_field :content, id: "#{object_id}_input", value: ff.object.content(fallback: false, default: nil)
9
+ %trix-editor.text-input.trix-content{ input: "#{object_id}_input", id: "#{object_id}_editor" }
@@ -0,0 +1,27 @@
1
+ :javascript
2
+ function selectFirstImage(e) {
3
+ var toolbar_id = $(this).closest('trix-toolbar').attr('id');
4
+ $(this).addClass('btn-selected');
5
+ $.get("#{ Spina::Engine.routes.url_helpers.admin_media_picker_path }" + "?trix_toolbar_id=" + toolbar_id + "&slider=first");
6
+ }
7
+ function selectSecondImage(e) {
8
+ var toolbar_id = $(this).closest('trix-toolbar').attr('id');
9
+ $(this).addClass('btn-selected');
10
+ $.get("#{ Spina::Engine.routes.url_helpers.admin_media_picker_path }" + "?trix_toolbar_id=" + toolbar_id + "&slider=second");
11
+ }
12
+ function createListeners() {
13
+ $('.first-slider-file').on('click', selectFirstImage);
14
+ $('.second-slider-file').on('click', selectSecondImage);
15
+ $('trix-editor').on('first-photo-selected', sliderController.photoAssignFirst);
16
+ $('trix-editor').on('second-photo-selected', sliderController.photoAssignSecond);
17
+ $('.slider-preview').on('preview-slider', sliderController.previewSlider);
18
+ $('.add-slider').on('click', sliderController.addSlider);
19
+ $('.add-slider').on('click', sliderController.clearList);
20
+ }
21
+ $(document).on("trix-initialize", function(event) {
22
+ if ($('trix-toolbar').find('.trix-button--text.image-slider').length == 0) {
23
+ $('.trix-button-group--text-tools').append(customTrixTools.sliderBtn);
24
+ $('.trix-dialogs').append(customTrixTools.sliderDialog);
25
+ createListeners();
26
+ }
27
+ });
@@ -0,0 +1,6 @@
1
+ = render partial: 'spina/admin/partables/texts/slider_js', locals: { editor_id: object_id}
2
+
3
+
4
+ - object_id = (f.object.persisted? ? f.object.object_id : "new_association_#{f.object.object_id}").to_s + "_#{field}"
5
+ = f.hidden_field field, id: "#{object_id}_input"
6
+ %trix-editor.text-input.trix-content{ input: "#{object_id}_input" }
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "spina/slider"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,9 @@
1
+ require "spina/slider/version"
2
+
3
+ module Spina
4
+ module Slider
5
+ class Error < StandardError; end
6
+
7
+ class Engine < ::Rails::Engine; end
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ module Spina
2
+ module Slider
3
+ VERSION = "1.0.0"
4
+ end
5
+ end
@@ -0,0 +1,27 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "spina/slider/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "spina-slider"
8
+ spec.version = Spina::Slider::VERSION
9
+ spec.authors = ["Michael Wilmouth"]
10
+ spec.email = ["wilmouthworks@gmail.com"]
11
+
12
+ spec.summary = %q{Before/after image slider for spina CMS}
13
+ spec.homepage = "https://github.com/mawilmouth/spina-slider"
14
+ spec.license = "MIT"
15
+
16
+ # Specify which files should be added to the gem when it is released.
17
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
18
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
19
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
+ end
21
+ spec.bindir = "exe"
22
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
+ spec.require_paths = ["lib"]
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.17"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ end
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: spina-slider
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Michael Wilmouth
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-11-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.17'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.17'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description:
42
+ email:
43
+ - wilmouthworks@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - CODE_OF_CONDUCT.md
50
+ - Gemfile
51
+ - Gemfile.lock
52
+ - LICENSE.txt
53
+ - README.md
54
+ - Rakefile
55
+ - app/assets/javascripts/slider.js
56
+ - app/assets/stylesheets/slider.scss
57
+ - app/assets/stylesheets/twentytwenty-no-compass.scss
58
+ - app/views/layouts/spina/admin/admin.html.haml
59
+ - app/views/spina/admin/media_picker/_modal.html.haml
60
+ - app/views/spina/admin/media_picker/select.js.erb
61
+ - app/views/spina/admin/media_picker/show.js.erb
62
+ - app/views/spina/admin/partables/texts/_form.html.haml
63
+ - app/views/spina/admin/partables/texts/_slider_js.html.haml
64
+ - app/views/spina/admin/shared/_rich_text_field.html.haml
65
+ - bin/console
66
+ - bin/setup
67
+ - lib/spina/slider.rb
68
+ - lib/spina/slider/version.rb
69
+ - spina-slider.gemspec
70
+ homepage: https://github.com/mawilmouth/spina-slider
71
+ licenses:
72
+ - MIT
73
+ metadata: {}
74
+ post_install_message:
75
+ rdoc_options: []
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ requirements: []
89
+ rubyforge_project:
90
+ rubygems_version: 2.7.6.2
91
+ signing_key:
92
+ specification_version: 4
93
+ summary: Before/after image slider for spina CMS
94
+ test_files: []