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 +4 -4
- data/README.md +1 -1
- data/app/assets/javascripts/bootsy.js +2 -1
- data/app/assets/javascripts/bootsy/bootsy.js +23 -7
- data/app/assets/javascripts/bootsy/init.js +7 -5
- data/app/assets/javascripts/bootsy/polyfill.js +29 -0
- data/app/assets/stylesheets/bootsy.css +4 -0
- data/app/controllers/bootsy/application_controller.rb +1 -1
- data/app/controllers/bootsy/images_controller.rb +5 -5
- data/app/views/bootsy/images/_new.html.erb +9 -0
- data/config/locales/bootsy.en.yml +3 -0
- data/config/locales/bootsy.pt-BR.yml +3 -0
- data/config/routes.rb +2 -2
- data/lib/bootsy.rb +4 -0
- data/lib/bootsy/container.rb +33 -35
- data/lib/bootsy/version.rb +1 -1
- data/lib/generators/bootsy/templates/bootsy.rb +5 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ecb062c39cbffa271dda6803ef4bcaa1a302d88d
|
4
|
+
data.tar.gz: c5afb0b14abb89b4ee1091b79c2907144fd597f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
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:
|
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
|
-
|
30
|
+
$(window).load(function() {
|
31
|
+
Bootsy.init();
|
31
32
|
|
32
|
-
|
33
|
-
|
34
|
-
|
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
|
+
}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Bootsy
|
2
|
-
class ApplicationController <
|
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
|
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 %>
|
data/config/routes.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
Bootsy::Engine.routes.draw do
|
2
2
|
resources :image_galleries, only: [] do
|
3
|
-
resources :images, only: [:index, :create, :
|
3
|
+
resources :images, only: [:index, :create, :destroy]
|
4
4
|
end
|
5
5
|
|
6
|
-
file_routes = [:index, :create
|
6
|
+
file_routes = [:index, :create]
|
7
7
|
|
8
8
|
file_routes << :destroy if Bootsy.allow_destroy
|
9
9
|
|
data/lib/bootsy.rb
CHANGED
@@ -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
|
data/lib/bootsy/container.rb
CHANGED
@@ -11,43 +11,41 @@ module Bootsy
|
|
11
11
|
extend ActiveSupport::Concern
|
12
12
|
|
13
13
|
included do
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
has_one :bootsy_image_gallery,
|
15
|
+
class_name: 'Bootsy::ImageGallery',
|
16
|
+
as: :bootsy_resource,
|
17
|
+
dependent: :destroy
|
18
|
+
end
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
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
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
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
|
data/lib/bootsy/version.rb
CHANGED
@@ -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
|
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-
|
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
|