bootsy 2.0.13 → 2.1.0

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: 000c431fdbdf268b93ef584550157a86e614cf7d
4
- data.tar.gz: ac3417b829147f272c288dd1bb52a5dac9b1cd21
3
+ metadata.gz: ecb062c39cbffa271dda6803ef4bcaa1a302d88d
4
+ data.tar.gz: c5afb0b14abb89b4ee1091b79c2907144fd597f8
5
5
  SHA512:
6
- metadata.gz: b962a45cef1d7220f15f2900a891a87e9c0df7b5de7b45fb607f09a40a97cf6dbc418ce126d78d9fd4d7205982d5557d7bca9d9f0574ce7a9194ec189b75753f
7
- data.tar.gz: 1039372deb799338efc78711bf79c0bd54730a951617fc10866d016598b9ee6bc0774d4e66c71a96cba42c7726e29a476825c2d7b3ce8e176e16f419ae1abf38
6
+ metadata.gz: e9cf8f084c8eadd962250214c5e7a9da48242c879bf443bfd64fd27120dbcf6ec593b71a0fcfe2934df5106a889b3fbcfb3334710b546d2724650c88531a7315
7
+ data.tar.gz: b172836a39271c1534adbb592757547467ff365536f58973411004bad06762a306837f8b5864e6f99762478ce6ed76eb17828c70f780609bbab24c04b08fe858
data/README.md CHANGED
@@ -113,7 +113,7 @@ You can enable and disable features as you like. For instance, if you don't want
113
113
  Available options are: `:font_styles`, `:emphasis`, `:lists`, `:html`, `:link`, `:image` and `:color`.
114
114
 
115
115
 
116
- ### Alert of usaved changes
116
+ ### Alert of unsaved changes
117
117
 
118
118
  By default Bootsy alerts the user about unsaved changes if the page is closed or reloaded. You can disable
119
119
  this feature with:
@@ -1,8 +1,9 @@
1
1
  //= require jquery.remotipart
2
+ //= require bootsy/polyfill
2
3
  //= require bootsy/wysihtml5
3
4
  //= require bootsy/bootstrap-wysihtml5
4
5
  //= require bootsy/bootsy
5
- //= require bootsy/bootstrap.file-input.js
6
+ //= require bootsy/bootstrap.file-input
6
7
  //= require bootsy/init
7
8
  //= require bootsy/editor_options
8
9
  //= require bootsy/translations
@@ -5,8 +5,11 @@ window.Bootsy = window.Bootsy || {};
5
5
  Bootsy.Area = function($el) {
6
6
  this.$el = $el;
7
7
  this.modal = $el.siblings('.bootsy-modal');
8
- this.locale = $el.data('bootsy-locale') || $('html').attr('lang') || 'en';
9
8
  this.unsavedChanges = false;
9
+ this.locale = $el.data('bootsy-locale') || $('html').attr('lang');
10
+ if (!Bootsy.translations[this.locale]) {
11
+ this.locale = 'en';
12
+ }
10
13
 
11
14
  this.options = {
12
15
  locale: this.locale,
@@ -100,6 +103,20 @@ Bootsy.Area.prototype.setUploadForm = function(html) {
100
103
  }.bind(this));
101
104
  };
102
105
 
106
+ // The image upload failed
107
+ Bootsy.Area.prototype.imageUploadFailed = function(e, xhr, status, error) {
108
+ this.invalidErrors = xhr.responseJSON;
109
+ if (Number(xhr.status) === 422 && this.invalidErrors.image_file) {
110
+ this.hideUploadLoadingAnimation();
111
+ if (this.validation) this.validation.remove();
112
+ this.validation = $("<p class='text-danger'>");
113
+ this.validation.text(this.invalidErrors.image_file[0]);
114
+ this.find('.bootsy-upload-form').append(this.validation);
115
+ } else {
116
+ alert(Bootsy.translations[this.locale].error);
117
+ }
118
+ this.showRefreshButton();
119
+ };
103
120
 
104
121
  // Set image gallery
105
122
  Bootsy.Area.prototype.setImageGallery = function() {
@@ -114,7 +131,9 @@ Bootsy.Area.prototype.setImageGallery = function() {
114
131
  },
115
132
  dataType: 'json',
116
133
  success: function(data) {
134
+ this.hideRefreshButton();
117
135
  this.hideGalleryLoadingAnimation();
136
+ this.find('.bootsy-gallery .bootsy-image').remove();
118
137
 
119
138
  $.each(data.images, function(index, value) {
120
139
  this.addImage(value);
@@ -128,11 +147,7 @@ Bootsy.Area.prototype.setImageGallery = function() {
128
147
 
129
148
  this.modal.data('gallery-loaded', true);
130
149
  }.bind(this),
131
- error: function() {
132
- alert(Bootsy.translations[this.locale].error);
133
-
134
- this.showRefreshButton();
135
- }.bind(this)
150
+ error: this.imageUploadFailed.bind(this)
136
151
  });
137
152
  };
138
153
 
@@ -152,7 +167,6 @@ Bootsy.Area.prototype.deleteImage = function (id) {
152
167
  }.bind(this));
153
168
  };
154
169
 
155
-
156
170
  // Add image to gallery
157
171
  Bootsy.Area.prototype.addImage = function(html) {
158
172
  this.hideEmptyAlert();
@@ -262,6 +276,8 @@ Bootsy.Area.prototype.init = function() {
262
276
  this.deleteImage(data.id);
263
277
  }.bind(this));
264
278
 
279
+ this.modal.on('ajax:error', '.bootsy-upload-form', this.imageUploadFailed.bind(this));
280
+
265
281
  this.modal.on('ajax:success', '.bootsy-upload-form', function(evt, data) {
266
282
  this.setImageGalleryId(data.gallery_id);
267
283
  this.addImage(data.image);
@@ -27,10 +27,12 @@ Bootsy.init = function() {
27
27
 
28
28
  /* Initialize Bootsy on document load */
29
29
  $(function() {
30
- Bootsy.init();
30
+ $(window).load(function() {
31
+ Bootsy.init();
31
32
 
32
- /* Reload Bootsy on page load when using Turbolinks. */
33
- if (window.Turbolinks) {
34
- $(document).on('page:load', Bootsy.init);
35
- }
33
+ /* Reload Bootsy on page load when using Turbolinks. */
34
+ if (window.Turbolinks) {
35
+ $(document).on('page:load', Bootsy.init);
36
+ }
37
+ });
36
38
  });
@@ -0,0 +1,29 @@
1
+ /*
2
+ Bootsy makes use of Function.prototype.bind, which is not supported by some older browsers.
3
+ Source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind
4
+ */
5
+
6
+ if (!Function.prototype.bind) {
7
+ Function.prototype.bind = function(oThis) {
8
+ if (typeof this !== 'function') {
9
+ // closest thing possible to the ECMAScript 5
10
+ // internal IsCallable function
11
+ throw new TypeError('Function.prototype.bind - what is trying to be bound is not callable');
12
+ }
13
+
14
+ var aArgs = Array.prototype.slice.call(arguments, 1),
15
+ fToBind = this,
16
+ fNOP = function() {},
17
+ fBound = function() {
18
+ return fToBind.apply(this instanceof fNOP && oThis
19
+ ? this
20
+ : oThis,
21
+ aArgs.concat(Array.prototype.slice.call(arguments)));
22
+ };
23
+
24
+ fNOP.prototype = this.prototype;
25
+ fBound.prototype = new fNOP();
26
+
27
+ return fBound;
28
+ };
29
+ }
@@ -314,6 +314,10 @@ textarea.bootsy:required:invalid {
314
314
  padding-right: 5px;
315
315
  }
316
316
 
317
+ .bootsy-upload-spacer {
318
+ padding: 0 10px 0 10px;
319
+ }
320
+
317
321
  .bootsy-gallery-loader {
318
322
  display: block;
319
323
  margin: 0 auto;
@@ -1,5 +1,5 @@
1
1
  module Bootsy
2
- class ApplicationController < ActionController::Base
2
+ class ApplicationController < Bootsy.base_controller
3
3
  # Prevent CSRF attacks by raising an exception.
4
4
  # For APIs, you may want to use :null_session instead.
5
5
  protect_from_forgery with: :exception
@@ -2,8 +2,9 @@ require_dependency 'bootsy/application_controller'
2
2
 
3
3
  module Bootsy
4
4
  class ImagesController < Bootsy::ApplicationController
5
+ before_action :set_gallery, only: [:index, :create]
6
+
5
7
  def index
6
- @gallery = find_gallery
7
8
  @images = @gallery.images
8
9
 
9
10
  respond_to do |format|
@@ -19,7 +20,6 @@ module Bootsy
19
20
  end
20
21
 
21
22
  def create
22
- @gallery = find_gallery
23
23
  @gallery.save!
24
24
  @image = @gallery.images.new(image_params)
25
25
 
@@ -41,8 +41,8 @@ module Bootsy
41
41
 
42
42
  private
43
43
 
44
- def find_gallery
45
- ImageGallery.find(params[:image_gallery_id])
44
+ def set_gallery
45
+ @gallery = ImageGallery.find(params[:image_gallery_id])
46
46
  end
47
47
 
48
48
  # Private: Returns the String markup to render
@@ -72,7 +72,7 @@ module Bootsy
72
72
  end
73
73
 
74
74
  def image_params
75
- params.require(:image).permit(:image_file)
75
+ params.require(:image).permit(:image_file, :remote_image_file_url)
76
76
  end
77
77
 
78
78
  def create_and_respond
@@ -4,5 +4,14 @@
4
4
 
5
5
  <%= image_tag 'bootsy/upload-loader.gif', class: 'bootsy-upload-loader' %>
6
6
 
7
+ <div class="input-group">
8
+ <%= f.url_field :remote_image_file_url, class: 'form-control', placeholder: t('bootsy.action.enter_image_url') %>
9
+ <span class="input-group-btn">
10
+ <%= f.submit t('bootsy.action.submit_upload'), class: 'btn btn-default' %>
11
+ </span>
12
+ </div>
13
+
14
+ <span class="bootsy-upload-spacer"><%= t('bootsy.action.or') %></span>
15
+
7
16
  <%= f.file_field :image_file, title: t('bootsy.action.upload') %>
8
17
  <% end %>
@@ -5,7 +5,10 @@ en:
5
5
  destroy: Delete
6
6
  close: Close
7
7
  load: Load
8
+ or: or
8
9
  upload: Upload New Image
10
+ submit_upload: Go
11
+ enter_image_url: Enter a URL from the web...
9
12
  image_gallery: Image Gallery
10
13
  image:
11
14
  s: Image
@@ -5,7 +5,10 @@ pt-BR:
5
5
  destroy: Apagar
6
6
  close: Fechar
7
7
  load: Carregar
8
+ or: ou
8
9
  upload: Nova imagem
10
+ submit_upload: Ir
11
+ enter_image_url: Digite uma URL da web...
9
12
  image_gallery: Galeria de Imagens
10
13
  image:
11
14
  s: Imagem
@@ -1,9 +1,9 @@
1
1
  Bootsy::Engine.routes.draw do
2
2
  resources :image_galleries, only: [] do
3
- resources :images, only: [:index, :create, :update, :destroy]
3
+ resources :images, only: [:index, :create, :destroy]
4
4
  end
5
5
 
6
- file_routes = [:index, :create, :update]
6
+ file_routes = [:index, :create]
7
7
 
8
8
  file_routes << :destroy if Bootsy.allow_destroy
9
9
 
@@ -56,6 +56,10 @@ module Bootsy
56
56
  mattr_accessor :store_dir
57
57
  @@store_dir = 'uploads'
58
58
 
59
+ # Specify which controller to inherit from
60
+ mattr_accessor :base_controller
61
+ @@base_controller = ActionController::Base
62
+
59
63
  # Default way to setup Bootsy. Run rails generate bootsy:install
60
64
  # to create a fresh initializer with all configuration values.
61
65
  def self.setup
@@ -11,43 +11,41 @@ module Bootsy
11
11
  extend ActiveSupport::Concern
12
12
 
13
13
  included do
14
- class_eval do
15
- has_one :bootsy_image_gallery,
16
- class_name: 'Bootsy::ImageGallery',
17
- as: :bootsy_resource,
18
- dependent: :destroy
14
+ has_one :bootsy_image_gallery,
15
+ class_name: 'Bootsy::ImageGallery',
16
+ as: :bootsy_resource,
17
+ dependent: :destroy
18
+ end
19
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.
24
- def bootsy_image_gallery_id
25
- bootsy_image_gallery.try(:id)
26
- end
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.
24
+ def bootsy_image_gallery_id
25
+ bootsy_image_gallery.try(:id)
26
+ end
27
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
42
- def bootsy_image_gallery_id=(value)
43
- if bootsy_image_gallery.nil? && value.present?
44
- self.bootsy_image_gallery = Bootsy::ImageGallery.find(value)
45
- bootsy_image_gallery.bootsy_resource = self
46
- bootsy_image_gallery.save
47
- else
48
- value
49
- end
50
- end
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
42
+ def bootsy_image_gallery_id=(value)
43
+ if bootsy_image_gallery.nil? && value.present?
44
+ self.bootsy_image_gallery = Bootsy::ImageGallery.find(value)
45
+ bootsy_image_gallery.bootsy_resource = self
46
+ bootsy_image_gallery.save
47
+ else
48
+ value
51
49
  end
52
50
  end
53
51
  end
@@ -1,4 +1,4 @@
1
1
  # Public: The gem version
2
2
  module Bootsy
3
- VERSION = '2.0.13'
3
+ VERSION = '2.1.0'
4
4
  end
@@ -61,4 +61,9 @@ Bootsy.setup do |config|
61
61
  # Store directory (inside 'public') for storage = :file
62
62
  # BE CAREFUL! Changing this may break previously uploaded file paths!
63
63
  # config.store_dir = 'uploads'
64
+ #
65
+ #
66
+ # Specify the controller to inherit from. Using ApplicationController
67
+ # allows you to perform authentication from within your app.
68
+ # config.base_controller = ActionController::Base
64
69
  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.13
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Volmer Soares
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-20 00:00:00.000000000 Z
11
+ date: 2015-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mini_magick
@@ -72,6 +72,7 @@ files:
72
72
  - app/assets/javascripts/bootsy/init.js
73
73
  - app/assets/javascripts/bootsy/locales/bootstrap-wysihtml5.pt-BR.js
74
74
  - app/assets/javascripts/bootsy/locales/bootsy.pt-BR.js
75
+ - app/assets/javascripts/bootsy/polyfill.js
75
76
  - app/assets/javascripts/bootsy/translations.js
76
77
  - app/assets/javascripts/bootsy/wysihtml5.js
77
78
  - app/assets/stylesheets/bootsy.css