bootsy 2.0.5 → 2.0.6

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: 2fd19bd8302ef3b07ae64fe9346417c910ac2de0
4
- data.tar.gz: 2fde333b4b996b95c492ad1f95f782bcba6969c7
3
+ metadata.gz: f3e427acd6cd736c47f74ecd5b6ab500d65b392a
4
+ data.tar.gz: 261b8bba75df325c62140a95c3658c4fce149d86
5
5
  SHA512:
6
- metadata.gz: c1707b0e8a58328889b9de650eb50c5f7b87b7da6a4492e9ffc88a981a0d2f6e420218772f84ced5c1da3d69f9eb59f56e8d820bb88e0be9b4363f0c869abcbc
7
- data.tar.gz: 25072bd9c85b63fc2e2c9880dd0de29a1095ea178ebcd38c365ec332615ada2b2afca7711a84f3eb4510757772b1c39688bd27889e9ab668e25c2b8b5785c87c
6
+ metadata.gz: 067d908ddc81707cd99d661126bdae0daabf71bd9fd5efb956c381c3ab49328f38121d008a605460dc0a42b220898e267bb1520e3fb2b8e1f47038ad1c608db5
7
+ data.tar.gz: 1dc13c44973b4796563ec38b6d9806fd74288e7fcd3ed837cf9b8d0eb1025369451d5133279b504820295d20d54fbd9f7fb4523c99b45af8669988a446c0ae38
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2013 Volmer Soares
1
+ Copyright 2012-2014 Volmer Soares
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -8,12 +8,15 @@
8
8
 
9
9
  *Bootsy* is a WYSIWYG solution for Rails based on [Bootstrap-wysihtml5](https://github.com/jhollingworth/bootstrap-wysihtml5) which includes image uploads via [CarrierWave](https://github.com/carrierwaveuploader/carrierwave).
10
10
 
11
- ![image](https://f.cloud.github.com/assets/301187/1365250/e1b7ba80-3854-11e3-9bfe-8bd1e090aca8.png)
11
+ ### Live demo
12
+
13
+ * [bootsy-demo.herokuapp.com](http://bootsy-demo.herokuapp.com/)
14
+ [![image](https://f.cloud.github.com/assets/301187/1365250/e1b7ba80-3854-11e3-9bfe-8bd1e090aca8.png)](http://bootsy-demo.herokuapp.com/)
12
15
 
13
16
 
14
17
  ## Requirements
15
18
 
16
- * Ruby `2.0` or `1.9.3`;
19
+ * Ruby `2` or `1.9.3`;
17
20
  * ImageMagick or GraphicsMagick (for MiniMagick);
18
21
  * Rails `4.0`;
19
22
  * [Bootstrap `3`](http://getbootstrap.com/) properly added to your application.
@@ -149,4 +152,4 @@ for it as well. Just follow [this example](https://github.com/volmer/bootsy/tree
149
152
 
150
153
  ## License
151
154
 
152
- MIT License. Copyright 2013 Volmer Soares
155
+ MIT License. Copyright 2012-2014 Volmer Soares
@@ -1,3 +1,5 @@
1
+ /* global Bootsy */
2
+
1
3
  window.Bootsy = window.Bootsy || {};
2
4
 
3
5
  Bootsy.Area = function($el) {
@@ -14,12 +16,30 @@ Bootsy.Area = function($el) {
14
16
  uploader: $el.data('bootsy-uploader'),
15
17
  };
16
18
 
17
- if ($el.data('bootsy-font-styles') === false) this.options['font-styles'] = false;
18
- if ($el.data('bootsy-emphasis') === false) this.options.emphasis = false;
19
- if ($el.data('bootsy-lists') === false) this.options.lists = false;
20
- if ($el.data('bootsy-html') === true) this.options.html = true;
21
- if ($el.data('bootsy-link') === false) this.options.link = false;
22
- if ($el.data('bootsy-color') === false) this.options.color = false;
19
+ // Set default values to editor options
20
+ if ($el.data('bootsy-font-styles') === false) {
21
+ this.options['font-styles'] = false;
22
+ }
23
+
24
+ if ($el.data('bootsy-emphasis') === false) {
25
+ this.options.emphasis = false;
26
+ }
27
+
28
+ if ($el.data('bootsy-lists') === false) {
29
+ this.options.lists = false;
30
+ }
31
+
32
+ if ($el.data('bootsy-html') === true) {
33
+ this.options.html = true;
34
+ }
35
+
36
+ if ($el.data('bootsy-link') === false) {
37
+ this.options.link = false;
38
+ }
39
+
40
+ if ($el.data('bootsy-color') === false) {
41
+ this.options.color = false;
42
+ }
23
43
 
24
44
  // Delegate find to the modal
25
45
  this.find = this.modal.find.bind(this.modal);
@@ -66,8 +86,6 @@ Bootsy.Area.prototype.hideRefreshButton = function() {
66
86
 
67
87
  // Set upload form
68
88
  Bootsy.Area.prototype.setUploadForm = function(html) {
69
- var form;
70
-
71
89
  this.find('.modal-footer').html(html);
72
90
 
73
91
  this.hideUploadLoadingAnimation();
@@ -103,7 +121,7 @@ Bootsy.Area.prototype.setImageGallery = function() {
103
121
  this.addImage(value);
104
122
  }.bind(this));
105
123
 
106
- if (data.images.length == 0) {
124
+ if (data.images.length === 0) {
107
125
  this.showEmptyAlert();
108
126
  }
109
127
 
@@ -111,7 +129,7 @@ Bootsy.Area.prototype.setImageGallery = function() {
111
129
 
112
130
  this.modal.data('gallery-loaded', true);
113
131
  }.bind(this),
114
- error: function(e) {
132
+ error: function() {
115
133
  alert(Bootsy.translations[this.locale].error);
116
134
 
117
135
  this.showRefreshButton();
@@ -129,7 +147,7 @@ Bootsy.Area.prototype.deleteImage = function (id) {
129
147
  image.remove();
130
148
 
131
149
  // Put message back if 0 images
132
- if (this.find('.bootsy-image').length == 0 ) {
150
+ if (this.find('.bootsy-image').length === 0 ) {
133
151
  this.showEmptyAlert();
134
152
  }
135
153
  }.bind(this));
@@ -200,6 +218,8 @@ Bootsy.Area.prototype.init = function() {
200
218
  var img, imageObject;
201
219
  var imagePrefix = '/' + $(this).attr('data-image-size') + '_';
202
220
 
221
+ e.preventDefault();
222
+
203
223
  if ($(this).data('image-size') === 'original') {
204
224
  imagePrefix = '/';
205
225
  }
@@ -257,7 +277,7 @@ Bootsy.Area.prototype.init = function() {
257
277
  window.onbeforeunload = this.unsavedChangesAlert.bind(this);
258
278
  }
259
279
 
260
- this.$el.closest('form').submit(function(e) {
280
+ this.$el.closest('form').submit(function() {
261
281
  this.unsavedChanges = false;
262
282
 
263
283
  return true;
@@ -1,5 +1,8 @@
1
+ /* global Bootsy */
1
2
  window.Bootsy = window.Bootsy || {};
2
3
 
4
+ // Public: Intialize Bootsy editors in all visible `textarea`
5
+ // elements that has the `bootsy_text_area` class.
3
6
  Bootsy.init = function() {
4
7
  Bootsy.areas = {};
5
8
 
@@ -17,4 +20,12 @@ Bootsy.init = function() {
17
20
  });
18
21
  };
19
22
 
20
- $(Bootsy.init);
23
+ /* Initialize Bootsy on document load */
24
+ $(function() {
25
+ Bootsy.init();
26
+
27
+ /* Reload Bootsy on page load when using Turbolinks. */
28
+ if (window.Turbolinks) {
29
+ document.addEventListener('page:load', Bootsy.init);
30
+ }
31
+ });
@@ -66,10 +66,9 @@ module Bootsy
66
66
  end
67
67
 
68
68
  private
69
+
69
70
  def find_gallery
70
- ImageGallery.find params[:image_gallery_id]
71
- rescue
72
- ImageGallery.new
71
+ ImageGallery.find(params[:image_gallery_id])
73
72
  end
74
73
 
75
74
  # Never trust parameters from the scary internet, only allow the white list through.
@@ -1,4 +1,4 @@
1
- <div class="bootsy-image dropdown col-md-2" data-id="<%= image.id %>">
1
+ <div class="bootsy-image dropdown col-sm-2" data-id="<%= image.id %>">
2
2
  <%= link_to image_tag(image.image_file.thumb.url), '#', class: 'thumbnail',
3
3
  data: { toggle: 'dropdown' } %>
4
4
 
@@ -5,6 +5,7 @@ pt-BR:
5
5
  destroy: Apagar
6
6
  close: Fechar
7
7
  load: Carregar
8
+ upload: Nova imagem
8
9
  image_gallery: Galeria de Imagens
9
10
  image:
10
11
  s: Imagem
@@ -20,4 +21,7 @@ pt-BR:
20
21
  position:
21
22
  left: Esquerda
22
23
  right: Direita
23
- inline: Mesma linha
24
+ inline: Mesma linha
25
+ no_images_uploaded: Não existem imagens salvas.
26
+ js:
27
+ alert_unsaved: As suas modificações ainda não foram gravadas.
@@ -19,7 +19,7 @@ module Bootsy
19
19
 
20
20
  def bootsy_image_gallery_id=(value)
21
21
  if self.bootsy_image_gallery.nil? && !value.blank?
22
- ig = Bootsy::ImageGallery.find value
22
+ ig = Bootsy::ImageGallery.find(value)
23
23
  self.bootsy_image_gallery = ig
24
24
  ig.bootsy_resource = self
25
25
  ig.save
@@ -1,21 +1,16 @@
1
1
  module Bootsy
2
2
  module FormHelper
3
3
  def bootsy_area(object_name, method, options = {})
4
- object = options[:object]
5
- container = options.delete(:container)
4
+ container = options[:container] || options[:object]
6
5
 
7
- bootsy_options = Bootsy.editor_options.merge(options.delete(:editor_options) || {})
8
- bootsy_options[:uploader] = enable_uploader?(object, options.delete(:uploader), container)
6
+ output = self.text_area(object_name, method, text_area_options(options))
9
7
 
10
- options[:data] = data_options(options, bootsy_options)
11
- options[:class] = class_attr(options)
8
+ if output.present? && enable_uploader?(options)
9
+ container.bootsy_image_gallery_id ||= Bootsy::ImageGallery.create!.id
12
10
 
13
- output = self.text_area(object_name, method, options)
11
+ output += self.render('bootsy/images/modal', container: container)
14
12
 
15
- if bootsy_options[:uploader]
16
- output += self.render 'bootsy/images/modal', { container: container || object }
17
-
18
- if container.blank? || (container == object)
13
+ if container.new_record?
19
14
  output += self.hidden_field(object_name, :bootsy_image_gallery_id, class: 'bootsy_image_gallery_id')
20
15
  end
21
16
  end
@@ -25,19 +20,19 @@ module Bootsy
25
20
 
26
21
  private
27
22
 
28
- def enable_uploader?(object, uploader, container)
29
- if uploader == false
23
+ def enable_uploader?(options)
24
+ if options[:uploader] == false
30
25
  false
31
- elsif container.is_a?(Container)
26
+ elsif options[:container].is_a?(Container)
32
27
  true
33
- elsif container.blank? && object.is_a?(Container)
28
+ elsif options[:container].blank? && options[:object].is_a?(Container)
34
29
  true
35
30
  else
36
31
  false
37
32
  end
38
33
  end
39
34
 
40
- def class_attr(options)
35
+ def tag_class(options)
41
36
  classes = if options[:class].blank?
42
37
  []
43
38
  elsif options[:class].kind_of?(Array)
@@ -49,8 +44,25 @@ module Bootsy
49
44
  classes << 'bootsy_text_area'
50
45
  end
51
46
 
52
- def data_options(options, bootsy_options)
53
- (options[:data] || {}).merge Hash[ bootsy_options.map { |k,v| ["bootsy-#{k}", v] } ]
47
+ def data_options(options)
48
+ (options[:data] || {}).merge Hash[ bootsy_options(options).map { |k,v| ["bootsy-#{k}", v] } ]
49
+ end
50
+
51
+ def bootsy_options(options)
52
+ Bootsy.editor_options.
53
+ merge(options[:editor_options] || {}).
54
+ merge(uploader: enable_uploader?(options))
55
+ end
56
+
57
+ def text_area_options(options)
58
+ options.except(
59
+ :container,
60
+ :uploader,
61
+ :editor_options
62
+ ).merge(
63
+ data: data_options(options),
64
+ class: tag_class(options)
65
+ )
54
66
  end
55
67
  end
56
68
  end
@@ -1,3 +1,3 @@
1
1
  module Bootsy
2
- VERSION = '2.0.5'
2
+ VERSION = '2.0.6'
3
3
  end
@@ -4,37 +4,47 @@ module Bootsy
4
4
  source_root __FILE__
5
5
 
6
6
  def add_routes
7
- route "mount Bootsy::Engine => '/bootsy', as: 'bootsy'"
7
+ route("mount Bootsy::Engine => '/bootsy', as: 'bootsy'")
8
8
  end
9
9
 
10
10
  def copy_locale
11
- copy_file "../../../../config/locales/en.yml", "config/locales/bootsy.en.yml"
11
+ copy_file('../../../../config/locales/en.yml', 'config/locales/bootsy.en.yml')
12
12
  end
13
13
 
14
14
  def add_assets
15
-
16
- [{original: 'app/assets/javascripts/application.js',
17
- skip_if: 'require bootsy',
18
- content: "\n//= require bootsy",
19
- position: {after: '//= require jquery_ujs'}},
20
- {original: 'app/assets/stylesheets/application.css',
21
- skip_if: 'require bootsy',
22
- content: "\n *= require bootsy",
23
- position: {after: '*= require_self'}}]. each do |params|
24
-
25
- if File.binread(params[:original]).include?(params[:skip_if])
26
- say_status 'skipped', "insert into #{params[:original]}", :yellow
15
+ [
16
+ {
17
+ original: 'app/assets/javascripts/application.js',
18
+ skip_if: 'require bootsy',
19
+ content: "\n//= require bootsy",
20
+ position: {
21
+ after: '//= require jquery_ujs'
22
+ }
23
+ },
24
+ {
25
+ original: 'app/assets/stylesheets/application.css',
26
+ skip_if: 'require bootsy',
27
+ content: "\n *= require bootsy",
28
+ position: {
29
+ after: '*= require_self'
30
+ }
31
+ }
32
+ ].each do |params|
33
+ if File.exists?(params[:original])
34
+ if File.binread(params[:original]).include?(params[:skip_if])
35
+ say_status('skipped', "insert into #{params[:original]}", :yellow)
36
+ else
37
+ insert_into_file(params[:original], params[:content], params[:position])
38
+ end
27
39
  else
28
- insert_into_file params[:original], params[:content], params[:position]
40
+ say_status('not found', "#{params[:original]} not found. You must manually require Bootsy in your assets pipeline.", :red)
29
41
  end
30
42
  end
31
-
32
43
  end
33
44
 
34
45
  def copy_config
35
- template '../templates/bootsy.rb', 'config/initializers/bootsy.rb'
46
+ template('../templates/bootsy.rb', 'config/initializers/bootsy.rb')
36
47
  end
37
-
38
48
  end
39
49
  end
40
50
  end
metadata CHANGED
@@ -1,55 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootsy
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.5
4
+ version: 2.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Volmer Soares
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-06 00:00:00.000000000 Z
11
+ date: 2014-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mini_magick
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: 3.7.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 3.7.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: carrierwave
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: 0.9.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.9.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: remotipart
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: 1.2.1
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: 1.2.1
55
55
  description: A beautiful WYSIWYG editor with image uploads for Rails.
@@ -59,8 +59,12 @@ executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
+ - MIT-LICENSE
63
+ - README.md
64
+ - Rakefile
62
65
  - app/assets/images/bootsy/gallery-loader.gif
63
66
  - app/assets/images/bootsy/upload-loader.gif
67
+ - app/assets/javascripts/bootsy.js
64
68
  - app/assets/javascripts/bootsy/bootstrap-wysihtml5.js
65
69
  - app/assets/javascripts/bootsy/bootstrap.file-input.js
66
70
  - app/assets/javascripts/bootsy/bootsy.js
@@ -70,11 +74,10 @@ files:
70
74
  - app/assets/javascripts/bootsy/locales/bootsy.pt-BR.js
71
75
  - app/assets/javascripts/bootsy/translations.js
72
76
  - app/assets/javascripts/bootsy/wysihtml5.js
73
- - app/assets/javascripts/bootsy.js
77
+ - app/assets/stylesheets/bootsy.css
74
78
  - app/assets/stylesheets/bootsy/bootstrap-submenu.css
75
79
  - app/assets/stylesheets/bootsy/bootstrap-wysihtml5.css
76
80
  - app/assets/stylesheets/bootsy/bootsy.css
77
- - app/assets/stylesheets/bootsy.css
78
81
  - app/controllers/bootsy/application_controller.rb
79
82
  - app/controllers/bootsy/images_controller.rb
80
83
  - app/helpers/bootsy/application_helper.rb
@@ -88,6 +91,7 @@ files:
88
91
  - config/routes.rb
89
92
  - db/migrate/20120624171333_create_bootsy_images.rb
90
93
  - db/migrate/20120628124845_create_bootsy_image_galleries.rb
94
+ - lib/bootsy.rb
91
95
  - lib/bootsy/activerecord/image.rb
92
96
  - lib/bootsy/activerecord/image_gallery.rb
93
97
  - lib/bootsy/container.rb
@@ -97,17 +101,14 @@ files:
97
101
  - lib/bootsy/form_helper.rb
98
102
  - lib/bootsy/simple_form/bootsy_input.rb
99
103
  - lib/bootsy/version.rb
100
- - lib/bootsy.rb
104
+ - lib/generators/bootsy/USAGE
101
105
  - lib/generators/bootsy/install_generator.rb
102
106
  - lib/generators/bootsy/templates/bootsy.rb
103
- - lib/generators/bootsy/USAGE
104
107
  - lib/tasks/bootsy_tasks.rake
105
108
  - lib/tasks/cucumber.rake
106
- - MIT-LICENSE
107
- - Rakefile
108
- - README.md
109
109
  homepage: http://github.com/volmer/bootsy
110
- licenses: []
110
+ licenses:
111
+ - MIT
111
112
  metadata: {}
112
113
  post_install_message:
113
114
  rdoc_options: []
@@ -115,17 +116,17 @@ require_paths:
115
116
  - lib
116
117
  required_ruby_version: !ruby/object:Gem::Requirement
117
118
  requirements:
118
- - - '>='
119
+ - - ">="
119
120
  - !ruby/object:Gem::Version
120
121
  version: '0'
121
122
  required_rubygems_version: !ruby/object:Gem::Requirement
122
123
  requirements:
123
- - - '>='
124
+ - - ">="
124
125
  - !ruby/object:Gem::Version
125
126
  version: '0'
126
127
  requirements: []
127
128
  rubyforge_project:
128
- rubygems_version: 2.0.14
129
+ rubygems_version: 2.2.0
129
130
  signing_key:
130
131
  specification_version: 4
131
132
  summary: A beautiful WYSIWYG editor with image uploads for Rails.