bootsy 2.0.7 → 2.0.8
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.
- checksums.yaml +4 -4
- data/app/assets/javascripts/bootsy/bootsy.js +2 -3
- data/app/assets/javascripts/bootsy/init.js +14 -9
- data/lib/bootsy/activerecord/image_gallery.rb +1 -1
- data/lib/bootsy/container.rb +35 -13
- data/lib/bootsy/simple_form/bootsy_input.rb +12 -3
- data/lib/bootsy/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a690695a8fe4970f189b8f070ec20a95a9a64102
|
4
|
+
data.tar.gz: ec879d16e88ec7f56fff78bc5f1351ef08848246
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10b8ff7d3b323ebb9e647ee150f4ca7d53132e8c395ff65be57063886e0d668340283b35dcadf739ad9a7d564aad31c7b4eecd8c44f07594f8bf3c90b2b51b86
|
7
|
+
data.tar.gz: 15f0b8bdf3f6d417537904fb238ec74255c9bc29e1e95234b919d2b828e427b5b964295cb9c11d8af3e222df503b22f2bed6e57ef4b56e50a9aa770795c3449f
|
@@ -7,7 +7,6 @@ Bootsy.Area = function($el) {
|
|
7
7
|
this.modal = $el.siblings('.bootsy-modal');
|
8
8
|
this.locale = $el.data('bootsy-locale') || $('html').attr('lang') || 'en';
|
9
9
|
this.unsavedChanges = false;
|
10
|
-
this.initialized = false;
|
11
10
|
|
12
11
|
this.options = {
|
13
12
|
locale: this.locale,
|
@@ -210,7 +209,7 @@ Bootsy.Area.prototype.setImageGalleryId = function(id) {
|
|
210
209
|
Bootsy.Area.prototype.init = function() {
|
211
210
|
var insert;
|
212
211
|
|
213
|
-
if (!this.initialized) {
|
212
|
+
if (!this.$el.data('bootsy-initialized')) {
|
214
213
|
insert = this.insertImage.bind(this);
|
215
214
|
|
216
215
|
if ((this.options.image === true) && (this.options.uploader === true)) {
|
@@ -300,6 +299,6 @@ Bootsy.Area.prototype.init = function() {
|
|
300
299
|
this.hideRefreshButton();
|
301
300
|
this.hideEmptyAlert();
|
302
301
|
|
303
|
-
this.initialized
|
302
|
+
this.$el.data('bootsy-initialized', true);
|
304
303
|
}
|
305
304
|
};
|
@@ -4,19 +4,24 @@ window.Bootsy = window.Bootsy || {};
|
|
4
4
|
// Public: Intialize Bootsy editors in all visible `textarea`
|
5
5
|
// elements that has the `bootsy_text_area` class.
|
6
6
|
Bootsy.init = function() {
|
7
|
-
Bootsy.areas
|
7
|
+
if (!Bootsy.areas) {
|
8
|
+
Bootsy.areas = {};
|
9
|
+
}
|
8
10
|
|
9
|
-
$('textarea.bootsy_text_area').
|
10
|
-
|
11
|
-
|
11
|
+
$('textarea.bootsy_text_area').each(function(index) {
|
12
|
+
if (!$(this).data('bootsy-initialized')) {
|
13
|
+
var area = new Bootsy.Area($(this));
|
14
|
+
var areaIdx = $(this).attr('id') || index;
|
12
15
|
|
13
|
-
|
14
|
-
areaIdx
|
15
|
-
|
16
|
+
/* There's always people who let elements share ids */
|
17
|
+
if(Bootsy.areas[areaIdx] !== undefined) {
|
18
|
+
areaIdx = $(this).attr('id') + index;
|
19
|
+
}
|
16
20
|
|
17
|
-
|
21
|
+
area.init();
|
18
22
|
|
19
|
-
|
23
|
+
Bootsy.areas[areaIdx] = area;
|
24
|
+
}
|
20
25
|
});
|
21
26
|
};
|
22
27
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Bootsy
|
2
2
|
class ImageGallery < ActiveRecord::Base
|
3
|
-
belongs_to :bootsy_resource, polymorphic: true
|
3
|
+
belongs_to :bootsy_resource, polymorphic: true, autosave: false
|
4
4
|
has_many :images, dependent: :destroy
|
5
5
|
|
6
6
|
scope :destroy_orphans, ->(time_limit) { where('created_at < ? AND bootsy_resource_id IS NULL', time_limit).destroy_all }
|
data/lib/bootsy/container.rb
CHANGED
@@ -1,28 +1,50 @@
|
|
1
|
-
require 'active_support/concern'
|
2
|
-
|
3
1
|
module Bootsy
|
2
|
+
# Public: Methods and attributes to turn any
|
3
|
+
# model into a Bootsy Container.
|
4
|
+
#
|
5
|
+
# Examples
|
6
|
+
#
|
7
|
+
# class Post < ActiveRecord::Base
|
8
|
+
# include Bootsy::Container
|
9
|
+
# end
|
4
10
|
module Container
|
5
|
-
|
6
11
|
extend ActiveSupport::Concern
|
7
12
|
|
8
13
|
included do
|
9
14
|
class_eval do
|
10
|
-
has_one :bootsy_image_gallery,
|
15
|
+
has_one :bootsy_image_gallery,
|
16
|
+
class_name: 'Bootsy::ImageGallery',
|
17
|
+
as: :bootsy_resource,
|
18
|
+
dependent: :destroy
|
11
19
|
|
20
|
+
# Public: Get the `id` attribute of the image gallery.
|
21
|
+
#
|
22
|
+
# Returns an Integer id or nil when there is
|
23
|
+
# not an image gallery.
|
12
24
|
def bootsy_image_gallery_id
|
13
|
-
|
14
|
-
nil
|
15
|
-
else
|
16
|
-
self.bootsy_image_gallery.id
|
17
|
-
end
|
25
|
+
self.bootsy_image_gallery.try(:id)
|
18
26
|
end
|
19
27
|
|
28
|
+
# Public: Set the image gallery `id` and save
|
29
|
+
# the association between models.
|
30
|
+
#
|
31
|
+
# Examples
|
32
|
+
#
|
33
|
+
# container.id
|
34
|
+
# # => 34
|
35
|
+
# gallery.id
|
36
|
+
# # => 12
|
37
|
+
# container.bootsy_image_gallery_id = gallery.id
|
38
|
+
# container.image_gallery_id
|
39
|
+
# # => 12
|
40
|
+
# gallery.bootsy_resource.id
|
41
|
+
# # => 34
|
20
42
|
def bootsy_image_gallery_id=(value)
|
21
43
|
if self.bootsy_image_gallery.nil? && !value.blank?
|
22
|
-
|
23
|
-
self.bootsy_image_gallery
|
24
|
-
|
25
|
-
|
44
|
+
image_gallery = Bootsy::ImageGallery.find(value)
|
45
|
+
self.bootsy_image_gallery = image_gallery
|
46
|
+
image_gallery.bootsy_resource = self
|
47
|
+
image_gallery.save
|
26
48
|
end
|
27
49
|
end
|
28
50
|
end
|
@@ -3,9 +3,18 @@ require 'simple_form'
|
|
3
3
|
class BootsyInput < SimpleForm::Inputs::Base
|
4
4
|
enable :placeholder, :maxlength, :container, :editor_options, :uploader
|
5
5
|
|
6
|
-
def input
|
6
|
+
def input(wrapper_options = nil)
|
7
7
|
bootsy_params = [:editor_options, :container, :uploader]
|
8
|
-
input_html_options.merge!
|
9
|
-
|
8
|
+
input_html_options.merge!(input_options.select {|k,v| bootsy_params.include?(k) })
|
9
|
+
|
10
|
+
# Check presence of `merge_wrapper_options` to keep
|
11
|
+
# compatibility with both Simple Form 3.0 and 3.1.
|
12
|
+
merged_input_options = if respond_to?(:merge_wrapper_options, true)
|
13
|
+
merge_wrapper_options(input_html_options, wrapper_options)
|
14
|
+
else
|
15
|
+
input_html_options
|
16
|
+
end
|
17
|
+
|
18
|
+
@builder.bootsy_area(attribute_name, merged_input_options)
|
10
19
|
end
|
11
20
|
end
|
data/lib/bootsy/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bootsy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Volmer Soares
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mini_magick
|