bootsy 0.1.3 → 0.1.4

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.
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
- Bootsy
2
- ======
1
+ # Bootsy
2
+
3
3
  [![Build Status](https://secure.travis-ci.org/volmer/bootsy.png?branch=master)](http://travis-ci.org/volmer/bootsy)
4
+ [![Dependency Status](https://gemnasium.com/volmer/bootsy.png)](https://gemnasium.com/volmer/bootsy)
4
5
 
5
6
  *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/jnicklas/carrierwave).
6
7
 
@@ -23,47 +23,71 @@ window.Bootsy = (function(){
23
23
  }
24
24
 
25
25
  Bootsy.alertUnsavedChanges = function(){
26
- if(unsavedChanges){
26
+ if(Bootsy.unsavedChanges){
27
27
  return "<%= I18n.t 'bootsy.js.alert_unsaved' %>";
28
28
  }
29
29
  };
30
30
 
31
31
  Bootsy.ready = function(){
32
32
  if($('textarea.bootsy_text_area').length > 0){
33
- element = $('#bootsy_image_gallery');
34
-
35
- element.parents('form').after(element);
36
-
37
- element.find('a.refresh_btn').live('click', function(e){
38
- $(this).hide();
39
- Bootsy.progressBar(element);
40
- });
41
-
42
- element.find('a.destroy_btn').click(function(e){
43
- Bootsy.progressBar(element);
44
- });
45
-
46
- // element.find('#new_image').live('ajax:before', function(e){
47
- // console.log('sending...')
48
- // Bootsy.progressBar(element);
49
- // });
50
-
51
- element.modal({show: false});
52
- element.on('shown', function(){
53
- Bootsy.refreshGallery(element);
54
- });
55
33
 
56
34
  Bootsy.editorOptions = {color: true, locale: "<%= I18n.default_locale %>"};
57
35
 
58
36
  if($('textarea.bootsy_text_area').attr('data-enable-image') == 'false'){
59
37
  Bootsy.editorOptions.image = false;
60
38
  }else{
61
- if($('textarea.bootsy_text_area').attr('data-enable-uploader') == 'false'){
62
- Bootsy.editorOptions.image = true;
63
- }else{
39
+
40
+ if($('textarea.bootsy_text_area').attr('data-enable-uploader') != 'false'){
64
41
  Bootsy.editorOptions.image = false;
65
42
  Bootsy.editorOptions.imageUpload = true;
66
43
  Bootsy.editorOptions.imageUploadCallback = Bootsy.openImageGallery;
44
+
45
+ element = $('#bootsy_image_gallery');
46
+
47
+ element.parents('form').after(element);
48
+
49
+ element.find('a.refresh_btn').live('click', function(e){
50
+ $(this).hide();
51
+ Bootsy.progressBar(element);
52
+ });
53
+
54
+ element.find('a.destroy_btn').click(function(e){
55
+ Bootsy.progressBar(element);
56
+ });
57
+
58
+ // element.find('#new_image').live('ajax:before', function(e){
59
+ // console.log('sending...')
60
+ // Bootsy.progressBar(element);
61
+ // });
62
+
63
+ element.modal({show: false});
64
+ element.on('shown', function(){
65
+ Bootsy.refreshGallery(element);
66
+ });
67
+
68
+ element.on('hide', function() {
69
+ Bootsy.editor.currentView.element.focus();
70
+ });
71
+
72
+ element.on('click.dismiss.modal', '[data-dismiss="modal"]', function(e) {
73
+ e.stopPropagation();
74
+ });
75
+
76
+ element.find('ul.dropdown-menu a.insert').live('click', function(e){
77
+ var imagePrefix = "/"+$(this).attr('data-image-size')+"_";
78
+ if($(this).attr('data-image-size') == 'original'){
79
+ imagePrefix = '/';
80
+ }
81
+ var img = $(this).parents('li.dropdown').find('img');
82
+ var obj = {
83
+ src: img.attr('src').replace("/thumb_", imagePrefix),
84
+ alt: img.attr('alt').replace("Thumb_", "")
85
+ };
86
+
87
+ obj.align = $(this).attr('data-position');
88
+
89
+ Bootsy.insertImage(obj, Bootsy.editor);
90
+ });
67
91
  }
68
92
  }
69
93
 
@@ -76,29 +100,15 @@ window.Bootsy = (function(){
76
100
 
77
101
  Bootsy.editor = $('textarea.bootsy_text_area').wysihtml5(Bootsy.editorOptions).data("wysihtml5").editor;
78
102
 
79
- element.on('hide', function() {
80
- Bootsy.editor.currentView.element.focus();
81
- });
82
-
83
- element.on('click.dismiss.modal', '[data-dismiss="modal"]', function(e) {
103
+ // In order to properly work with Twitter Bootstrap 2.1
104
+ $('body').off('click.dropdown touchstart.dropdown.data-api', '.dropdown');
105
+ $('body').on('click.dropdown touchstart.dropdown.data-api', '.dropdown form', function(e){
84
106
  e.stopPropagation();
85
107
  });
86
108
 
87
- element.find('ul.dropdown-menu a.insert').live('click', function(e){
88
- var imagePrefix = "/"+$(this).attr('data-image-size')+"_";
89
- if($(this).attr('data-image-size') == 'original'){
90
- imagePrefix = '/';
91
- }
92
- var img = $(this).parents('li.dropdown').find('img');
93
- var obj = {
94
- src: img.attr('src').replace("/thumb_", imagePrefix),
95
- alt: img.attr('alt').replace("Thumb_", "")
96
- };
97
-
98
- obj.align = $(this).attr('data-position');
99
-
100
- Bootsy.insertImage(obj, Bootsy.editor);
101
- });
109
+ if($('textarea.bootsy_text_area').attr('data-alert-unsaved') != 'false'){
110
+ window.onbeforeunload = Bootsy.alertUnsavedChanges;
111
+ }
102
112
 
103
113
  Bootsy.editor.on("change", function(){
104
114
  Bootsy.unsavedChanges = true;
@@ -108,16 +118,6 @@ window.Bootsy = (function(){
108
118
  Bootsy.unsavedChanges = false;
109
119
  return true;
110
120
  });
111
-
112
- // In order to properly work with Twitter Bootstrap 2.1
113
- $('body').off('click.dropdown touchstart.dropdown.data-api', '.dropdown');
114
- $('body').on('click.dropdown touchstart.dropdown.data-api', '.dropdown form', function(e){
115
- e.stopPropagation();
116
- });
117
-
118
- if($('textarea.bootsy_text_area').attr('data-alert-unsaved') != 'false'){
119
- window.onbeforeunload = Bootsy.alertUnsavedChanges;
120
- }
121
121
  }
122
122
  };
123
123
 
@@ -2,44 +2,42 @@ module Bootsy
2
2
  module FormHelper
3
3
  def bootsy_area object, method, options = {}
4
4
 
5
- container = options.delete :container
5
+ foreign_container = options.delete :container
6
+ enable_uploader = true
6
7
 
7
- unless container.kind_of?(Container) || (container.nil? && object.kind_of?(Container))
8
- options[:editor_options] = {uploader: false}
8
+ unless foreign_container.kind_of?(Container) || (foreign_container.nil? && object.kind_of?(Container))
9
+ enable_uploader = false
9
10
  end
10
11
 
11
12
  editor_options = options.delete :editor_options
12
13
 
13
14
  unless editor_options.nil?
14
-
15
- options[:'data-enable-uploader'] = 'false' if editor_options[:uploader] == false
16
-
15
+ enable_uploader = false if editor_options[:uploader] == false
17
16
  options[:'data-alert-unsaved'] = 'false' if editor_options[:alert_unsaved] == false
18
-
19
17
  options[:'data-enable-font-styles'] = 'false' if editor_options[:font_styles] == false
20
-
21
18
  options[:'data-enable-emphasis'] = 'false' if editor_options[:emphasis] == false
22
-
23
19
  options[:'data-enable-lists'] = 'false' if editor_options[:lists] == false
24
-
25
20
  options[:'data-enable-html'] = 'true' if editor_options[:html] == true
26
-
27
21
  options[:'data-enable-link'] = 'false' if editor_options[:link] == false
28
-
29
22
  options[:'data-enable-image'] = 'false' if editor_options[:image] == false
30
-
31
23
  options[:'data-enable-color'] = 'false' if editor_options[:color] == false
32
-
33
24
  end
34
25
 
26
+ options[:'data-enable-uploader'] = 'false' unless enable_uploader
27
+
35
28
  object_name = object.class.name.underscore
29
+
30
+ output = raw ''
36
31
 
37
- output = self.render 'bootsy/images/modal', {container: container || object}
32
+ output = self.render 'bootsy/images/modal', {container: foreign_container || object} if enable_uploader
33
+
38
34
  options[:class] = (options[:class].nil? ? [] : (options[:class].kind_of?(Array) ? options[:class] : [options[:class]])) + [:bootsy_text_area]
39
35
  output += self.text_area object_name, method, options
40
36
 
41
- if container.nil? || (container == object)
42
- output += self.hidden_field object_name, :bootsy_image_gallery_id, :class => 'bootsy_image_gallery_id'
37
+ if enable_uploader
38
+ if foreign_container.nil? || (foreign_container == object)
39
+ output += self.hidden_field object_name, :bootsy_image_gallery_id, :class => 'bootsy_image_gallery_id'
40
+ end
43
41
  end
44
42
 
45
43
  output
@@ -1,3 +1,3 @@
1
1
  module Bootsy
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootsy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-21 00:00:00.000000000 Z
12
+ date: 2012-09-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mini_magick
@@ -163,44 +163,44 @@ extensions: []
163
163
  extra_rdoc_files: []
164
164
  files:
165
165
  - app/uploaders/bootsy/image_uploader.rb
166
- - app/views/bootsy/images/_index.html.erb
167
- - app/views/bootsy/images/_new.html.erb
168
166
  - app/views/bootsy/images/index.js.erb
169
- - app/views/bootsy/images/_modal.html.erb
170
- - app/views/bootsy/images/create.js.erb
167
+ - app/views/bootsy/images/_index.html.erb
171
168
  - app/views/bootsy/images/destroy.js.erb
169
+ - app/views/bootsy/images/create.js.erb
170
+ - app/views/bootsy/images/_modal.html.erb
171
+ - app/views/bootsy/images/_new.html.erb
172
172
  - app/controllers/bootsy/application_controller.rb
173
173
  - app/controllers/bootsy/images_controller.rb
174
+ - app/helpers/bootsy/application_helper.rb
174
175
  - app/assets/javascripts/bootsy.js
175
- - app/assets/javascripts/bootsy/bootsy.js.erb
176
- - app/assets/javascripts/bootsy/bootstrap-wysihtml5.js
177
- - app/assets/javascripts/bootsy/wysihtml5.js
178
176
  - app/assets/javascripts/bootsy/locales/bootstrap-wysihtml5.pt-BR.js
177
+ - app/assets/javascripts/bootsy/wysihtml5.js
178
+ - app/assets/javascripts/bootsy/bootstrap-wysihtml5.js
179
+ - app/assets/javascripts/bootsy/bootsy.js.erb
179
180
  - app/assets/stylesheets/bootsy.css
180
181
  - app/assets/stylesheets/bootsy/bootstrap-wysihtml5.css
181
182
  - app/assets/stylesheets/bootsy/bootsy.css
182
- - app/helpers/bootsy/application_helper.rb
183
- - config/cucumber.yml
184
- - config/bootsy.yml
185
- - config/routes.rb
186
- - config/locales/pt-BR.yml
187
183
  - config/locales/en.yml
188
- - db/migrate/20120628124845_create_bootsy_image_galleries.rb
184
+ - config/locales/pt-BR.yml
185
+ - config/routes.rb
186
+ - config/bootsy.yml
187
+ - config/cucumber.yml
189
188
  - db/migrate/20120624171333_create_bootsy_images.rb
190
- - lib/tasks/bootsy_tasks.rake
191
- - lib/tasks/cucumber.rake
192
- - lib/generators/bootsy/USAGE
189
+ - db/migrate/20120628124845_create_bootsy_image_galleries.rb
193
190
  - lib/generators/bootsy/install_generator.rb
194
191
  - lib/generators/bootsy/templates/bootsy.rb
192
+ - lib/generators/bootsy/USAGE
195
193
  - lib/bootsy.rb
196
- - lib/bootsy/core_ext.rb
197
- - lib/bootsy/activerecord/image_gallery.rb
198
- - lib/bootsy/activerecord/image.rb
194
+ - lib/tasks/bootsy_tasks.rake
195
+ - lib/tasks/cucumber.rake
199
196
  - lib/bootsy/form_helper.rb
200
197
  - lib/bootsy/version.rb
198
+ - lib/bootsy/activerecord/image_gallery.rb
199
+ - lib/bootsy/activerecord/image.rb
200
+ - lib/bootsy/core_ext.rb
201
201
  - lib/bootsy/container.rb
202
- - lib/bootsy/engine.rb
203
202
  - lib/bootsy/form_builder.rb
203
+ - lib/bootsy/engine.rb
204
204
  - MIT-LICENSE
205
205
  - Rakefile
206
206
  - README.md
@@ -218,7 +218,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
218
218
  version: '0'
219
219
  segments:
220
220
  - 0
221
- hash: 475960961
221
+ hash: 1343926653393299360
222
222
  required_rubygems_version: !ruby/object:Gem::Requirement
223
223
  none: false
224
224
  requirements:
@@ -227,7 +227,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
227
227
  version: '0'
228
228
  segments:
229
229
  - 0
230
- hash: 475960961
230
+ hash: 1343926653393299360
231
231
  requirements: []
232
232
  rubyforge_project:
233
233
  rubygems_version: 1.8.24