bootsy 2.0.7 → 2.0.8

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: b4cd22d7f1a69efb5e1bce79204237a5fb6f7dc3
4
- data.tar.gz: 2c7e22f00ea3e679be68a0ed662130a2ff4977c2
3
+ metadata.gz: a690695a8fe4970f189b8f070ec20a95a9a64102
4
+ data.tar.gz: ec879d16e88ec7f56fff78bc5f1351ef08848246
5
5
  SHA512:
6
- metadata.gz: 82b4ce1c063a5a75befa4dbc4180b5efad94eb57eb526b9c8a3a20828cde1f443ea715837d9f1a8a327ec25498b91d2d2fba9578b4ec6c40db4ac0f151f64dc9
7
- data.tar.gz: 70f7482591efc70538077e4dfe9d22f50a88bfe55c3b50dc06b7e4468c29a221749f59045015ff155d1943d8f3fef53d0a026c8ae9db4923446f4faa20442d53
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 = true;
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').filter(':visible').each(function(index) {
10
- var area = new Bootsy.Area($(this));
11
- var areaIdx = $(this).attr('id') || index;
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
- if(Bootsy.areas[areaIdx] !== undefined) {
14
- areaIdx = $(this).attr('id') + index;
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
- area.init();
21
+ area.init();
18
22
 
19
- Bootsy.areas[areaIdx] = area;
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 }
@@ -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, class_name: 'Bootsy::ImageGallery', as: :bootsy_resource, dependent: :destroy
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
- if self.bootsy_image_gallery.nil?
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
- ig = Bootsy::ImageGallery.find(value)
23
- self.bootsy_image_gallery = ig
24
- ig.bootsy_resource = self
25
- ig.save
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! input_options.select {|k,v| bootsy_params.include? k }
9
- @builder.bootsy_area attribute_name, input_html_options
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
@@ -1,3 +1,3 @@
1
1
  module Bootsy
2
- VERSION = '2.0.7'
2
+ VERSION = '2.0.8'
3
3
  end
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.7
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-03-08 00:00:00.000000000 Z
11
+ date: 2014-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mini_magick