bootsy 0.0.5 → 0.1.0

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
@@ -15,7 +15,7 @@ Bootsy
15
15
 
16
16
  ## Installation
17
17
 
18
- 1. Add Bootsy to your GemFile:
18
+ 1. Add Bootsy to your Gemfile:
19
19
 
20
20
  ```ruby
21
21
  gem 'bootsy'
@@ -41,7 +41,7 @@ Bootsy
41
41
 
42
42
  ## Usage
43
43
 
44
- Just call the brand new method `bootsy_area` in your `FormBuilder` instances, in the same way that you call the basic `textarea` method. Example:
44
+ Just call the brand new method `bootsy_area` in your `FormBuilder` instances, in the same way you call the basic `textarea` method. Example:
45
45
 
46
46
  ```erb
47
47
  <%= form_for(@post) do |f| %>
@@ -55,11 +55,11 @@ Just call the brand new method `bootsy_area` in your `FormBuilder` instances, in
55
55
  <% end %>
56
56
  ```
57
57
 
58
- Bootsy will group the uploaded image files as galleries and associate them to one of your models. For example, if you have a `Post` model and you want to use `bootsy_area` with it, then you should include the `MediaContainer` module:
58
+ Bootsy will group the uploaded image files as galleries and associate them to one of your models. For example, if you have a `Post` model and you want to use `bootsy_area` with it, then you should include the `Bootsy::Container` module:
59
59
 
60
60
  ```ruby
61
61
  class Post < ActiveRecord::Base
62
- include Bootsy::MediaContainer
62
+ include Bootsy::Container
63
63
 
64
64
  attr_accessible :content, :title
65
65
  end
@@ -76,6 +76,11 @@ Bootsy defines some i18n keys. The english translation is automatically added to
76
76
  Par default, Bootsy only supports ActiveRecord. In order to use Bootsy with Mongoid, please use [bootsy-mongoid](https://github.com/volmer/bootsy-mongoid) instead.
77
77
 
78
78
 
79
+ ## Bootsy with SimpleForm
80
+
81
+ Do you want to use Bootsy alongside with [SimpleForm](https://github.com/plataformatec/simple_form)? Take a look at [Bootsy-SimpleForm](https://github.com/volmer/bootsy-simple_form).
82
+
83
+
79
84
  ## License
80
85
 
81
86
  MIT License. Copyright 2012 Volmer Soares
@@ -12,6 +12,7 @@
12
12
  "<li><a data-wysihtml5-command='formatBlock' data-wysihtml5-command-value='div'>" + locale.font_styles.normal + "</a></li>" +
13
13
  "<li><a data-wysihtml5-command='formatBlock' data-wysihtml5-command-value='h1'>" + locale.font_styles.h1 + "</a></li>" +
14
14
  "<li><a data-wysihtml5-command='formatBlock' data-wysihtml5-command-value='h2'>" + locale.font_styles.h2 + "</a></li>" +
15
+ "<li><a data-wysihtml5-command='formatBlock' data-wysihtml5-command-value='h3'>" + locale.font_styles.h3 + "</a></li>" +
15
16
  "</ul>" +
16
17
  "</li>",
17
18
  "emphasis": "<li>" +
@@ -69,6 +70,25 @@
69
70
  "<div class='btn-group'>" +
70
71
  "<a class='btn' data-wysihtml5-action='change_view' title='" + locale.html.edit + "'><i class='icon-pencil'></i></a>" +
71
72
  "</div>" +
73
+ "</li>",
74
+
75
+ "color": "<li class='dropdown'>" +
76
+ "<a class='btn dropdown-toggle' data-toggle='dropdown' href='#'>" +
77
+ "<span class='current-color'>" + locale.colours.black + "</span>&nbsp;<b class='caret'></b>" +
78
+ "</a>" +
79
+ "<ul class='dropdown-menu'>" +
80
+ "<li><div class='wysihtml5-colors' data-wysihtml5-command-value='black'></div><a class='wysihtml5-colors-title' data-wysihtml5-command='foreColor' data-wysihtml5-command-value='black'>" + locale.colours.black + "</a></li>" +
81
+ "<li><div class='wysihtml5-colors' data-wysihtml5-command-value='silver'></div><a class='wysihtml5-colors-title' data-wysihtml5-command='foreColor' data-wysihtml5-command-value='silver'>" + locale.colours.silver + "</a></li>" +
82
+ "<li><div class='wysihtml5-colors' data-wysihtml5-command-value='gray'></div><a class='wysihtml5-colors-title' data-wysihtml5-command='foreColor' data-wysihtml5-command-value='gray'>" + locale.colours.gray + "</a></li>" +
83
+ "<li><div class='wysihtml5-colors' data-wysihtml5-command-value='maroon'></div><a class='wysihtml5-colors-title' data-wysihtml5-command='foreColor' data-wysihtml5-command-value='maroon'>" + locale.colours.maroon + "</a></li>" +
84
+ "<li><div class='wysihtml5-colors' data-wysihtml5-command-value='red'></div><a class='wysihtml5-colors-title' data-wysihtml5-command='foreColor' data-wysihtml5-command-value='red'>" + locale.colours.red + "</a></li>" +
85
+ "<li><div class='wysihtml5-colors' data-wysihtml5-command-value='purple'></div><a class='wysihtml5-colors-title' data-wysihtml5-command='foreColor' data-wysihtml5-command-value='purple'>" + locale.colours.purple + "</a></li>" +
86
+ "<li><div class='wysihtml5-colors' data-wysihtml5-command-value='green'></div><a class='wysihtml5-colors-title' data-wysihtml5-command='foreColor' data-wysihtml5-command-value='green'>" + locale.colours.green + "</a></li>" +
87
+ "<li><div class='wysihtml5-colors' data-wysihtml5-command-value='olive'></div><a class='wysihtml5-colors-title' data-wysihtml5-command='foreColor' data-wysihtml5-command-value='olive'>" + locale.colours.olive + "</a></li>" +
88
+ "<li><div class='wysihtml5-colors' data-wysihtml5-command-value='navy'></div><a class='wysihtml5-colors-title' data-wysihtml5-command='foreColor' data-wysihtml5-command-value='navy'>" + locale.colours.navy + "</a></li>" +
89
+ "<li><div class='wysihtml5-colors' data-wysihtml5-command-value='blue'></div><a class='wysihtml5-colors-title' data-wysihtml5-command='foreColor' data-wysihtml5-command-value='blue'>" + locale.colours.blue + "</a></li>" +
90
+ "<li><div class='wysihtml5-colors' data-wysihtml5-command-value='orange'></div><a class='wysihtml5-colors-title' data-wysihtml5-command='foreColor' data-wysihtml5-command-value='orange'>" + locale.colours.orange + "</a></li>" +
91
+ "</ul>" +
72
92
  "</li>"
73
93
  };
74
94
  return tpl[key];
@@ -76,6 +96,7 @@
76
96
 
77
97
  var defaultOptions = {
78
98
  "font-styles": true,
99
+ "color": false,
79
100
  "emphasis": true,
80
101
  "lists": true,
81
102
  "html": false,
@@ -85,6 +106,27 @@
85
106
  imageUploadCallback: undefined,
86
107
  events: {},
87
108
  parserRules: {
109
+ classes: {
110
+ // (path_to_project/lib/css/wysiwyg-color.css)
111
+ "wysiwyg-color-silver" : 1,
112
+ "wysiwyg-color-gray" : 1,
113
+ "wysiwyg-color-white" : 1,
114
+ "wysiwyg-color-maroon" : 1,
115
+ "wysiwyg-color-red" : 1,
116
+ "wysiwyg-color-purple" : 1,
117
+ "wysiwyg-color-fuchsia" : 1,
118
+ "wysiwyg-color-green" : 1,
119
+ "wysiwyg-color-lime" : 1,
120
+ "wysiwyg-color-olive" : 1,
121
+ "wysiwyg-color-yellow" : 1,
122
+ "wysiwyg-color-navy" : 1,
123
+ "wysiwyg-color-blue" : 1,
124
+ "wysiwyg-color-teal" : 1,
125
+ "wysiwyg-color-aqua" : 1,
126
+ "wysiwyg-color-orange" : 1,
127
+ "wysiwyg-float-left": 1,
128
+ "wysiwyg-float-right": 1
129
+ },
88
130
  tags: {
89
131
  "b": {},
90
132
  "i": {},
@@ -94,6 +136,7 @@
94
136
  "li": {},
95
137
  "h1": {},
96
138
  "h2": {},
139
+ "h3": {},
97
140
  "blockquote": {},
98
141
  "u": 1,
99
142
  "img": {
@@ -102,6 +145,9 @@
102
145
  "alt": "alt",
103
146
  "src": "src",
104
147
  "height": "numbers"
148
+ },
149
+ "add_class": {
150
+ "align": "align_img"
105
151
  }
106
152
  },
107
153
  "a": {
@@ -112,10 +158,12 @@
112
158
  check_attributes: {
113
159
  href: "url" // important to avoid XSS
114
160
  }
115
- }
161
+ },
162
+ "span": 1,
163
+ "div": 1
116
164
  }
117
165
  },
118
- stylesheets: [],
166
+ stylesheets: ["/assets/bootsy/bootsy.css"], // (path_to_project/lib/css/wysiwyg-color.css)
119
167
  locale: "en"
120
168
  };
121
169
 
@@ -140,7 +188,7 @@
140
188
  constructor: Wysihtml5,
141
189
 
142
190
  createEditor: function(options) {
143
- options = $.extend(defaultOptions, options || {});
191
+ options = $.extend({}, defaultOptions, options || {});
144
192
  options.toolbar = this.toolbar[0];
145
193
 
146
194
  var editor = new wysi.Editor(this.el[0], options);
@@ -160,7 +208,7 @@
160
208
  'class' : "wysihtml5-toolbar",
161
209
  'style': "display:none"
162
210
  });
163
-
211
+ var culture = options.locale || defaultOptions.locale || "en";
164
212
  for(var key in defaultOptions) {
165
213
  var value = false;
166
214
 
@@ -173,17 +221,17 @@
173
221
  }
174
222
 
175
223
  if(value === true) {
176
- toolbar.append(templates(key, locale[options.locale || "en"]));
224
+ toolbar.append(templates(key, locale[culture]));
177
225
 
178
- if(key == "html") {
226
+ if(key === "html") {
179
227
  this.initHtml(toolbar);
180
228
  }
181
229
 
182
- if(key == "link") {
230
+ if(key === "link") {
183
231
  this.initInsertLink(toolbar);
184
232
  }
185
233
 
186
- if(key == "image") {
234
+ if(key === "image") {
187
235
  this.initInsertImage(toolbar);
188
236
  }
189
237
 
@@ -193,11 +241,24 @@
193
241
  }
194
242
  }
195
243
 
244
+ if(options.toolbar) {
245
+ for(key in options.toolbar) {
246
+ toolbar.append(options.toolbar[key]);
247
+ }
248
+ }
249
+
196
250
  toolbar.find("a[data-wysihtml5-command='formatBlock']").click(function(e) {
197
- var el = $(e.srcElement);
251
+ var target = e.target || e.srcElement;
252
+ var el = $(target);
198
253
  self.toolbar.find('.current-font').text(el.html());
199
254
  });
200
255
 
256
+ toolbar.find("a[data-wysihtml5-command='foreColor']").click(function(e) {
257
+ var target = e.target || e.srcElement;
258
+ var el = $(target);
259
+ self.toolbar.find('.current-color').text(el.html());
260
+ });
261
+
201
262
  this.el.before(toolbar);
202
263
 
203
264
  return toolbar;
@@ -241,11 +302,18 @@
241
302
  });
242
303
 
243
304
  toolbar.find('a[data-wysihtml5-command=insertImage]').click(function() {
305
+ var activeButton = $(this).hasClass("wysihtml5-command-active");
306
+
307
+ if (!activeButton) {
244
308
  insertImageModal.modal('show');
245
309
  insertImageModal.on('click.dismiss.modal', '[data-dismiss="modal"]', function(e) {
246
- e.stopPropagation();
247
- });
310
+ e.stopPropagation();
311
+ });
248
312
  return false;
313
+ }
314
+ else {
315
+ return true;
316
+ }
249
317
  });
250
318
  },
251
319
 
@@ -292,14 +360,19 @@
292
360
  });
293
361
 
294
362
  toolbar.find('a[data-wysihtml5-command=createLink]').click(function() {
295
- insertLinkModal.modal('show');
363
+ var activeButton = $(this).hasClass("wysihtml5-command-active");
364
+
365
+ if (!activeButton) {
366
+ insertLinkModal.append('body').modal('show');
296
367
  insertLinkModal.on('click.dismiss.modal', '[data-dismiss="modal"]', function(e) {
297
- e.stopPropagation();
298
- });
368
+ e.stopPropagation();
369
+ });
299
370
  return false;
371
+ }
372
+ else {
373
+ return true;
374
+ }
300
375
  });
301
-
302
-
303
376
  }
304
377
  };
305
378
 
@@ -317,7 +390,8 @@
317
390
  font_styles: {
318
391
  normal: "Normal text",
319
392
  h1: "Heading 1",
320
- h2: "Heading 2"
393
+ h2: "Heading 2",
394
+ h3: "Heading 3"
321
395
  },
322
396
  emphasis: {
323
397
  bold: "Bold",
@@ -340,6 +414,19 @@
340
414
  },
341
415
  html: {
342
416
  edit: "Edit HTML"
417
+ },
418
+ colours: {
419
+ black: "Black",
420
+ silver: "Silver",
421
+ gray: "Grey",
422
+ maroon: "Maroon",
423
+ red: "Red",
424
+ purple: "Purple",
425
+ green: "Green",
426
+ olive: "Olive",
427
+ navy: "Navy",
428
+ blue: "Blue",
429
+ orange: "Orange"
343
430
  }
344
431
  }
345
432
  };
@@ -1,63 +1,125 @@
1
- function bootsyProgressBar(element){
2
- element.find('div.modal-body').html('<div class="progress progress-striped active"><div class="bar" style="width: 100%;"></div></div>');
3
- }
1
+ var Bootsy = (function(){
4
2
 
5
- function bootsyRefreshGallery(element){
6
- element.find('a.refresh_btn').show().click();
7
- }
3
+ var Bootsy = {unsavedChanges: false};
8
4
 
9
- function bootsyOpenImageGallery(editor){
10
- $('#bootsy_image_gallery').modal('show');
11
- }
5
+
6
+ Bootsy.progressBar = function(element){
7
+ element.find('div.modal-body').html('<div class="progress progress-striped active"><div class="bar" style="width: 100%;"></div></div>');
8
+ };
12
9
 
13
- function bootsyInsertImage(image, editor){
14
- $('#bootsy_image_gallery').modal('hide');
15
- editor.composer.commands.exec("insertImage", image);
16
- }
10
+ Bootsy.refreshGallery = function(element){
11
+ element.find('a.refresh_btn').show().click();
12
+ };
17
13
 
18
- $(document).ready(function(){
19
- element = $('#bootsy_image_gallery');
20
-
21
- element.parents('form').after(element);
14
+ Bootsy.openImageGallery = function(editor){
15
+ $('#bootsy_image_gallery').modal('show');
16
+ };
17
+
18
+ Bootsy.insertImage = function(image, editor){
19
+ $('#bootsy_image_gallery').modal('hide');
20
+ editor.composer.commands.exec("insertImage", image);
21
+ }
22
+
23
+ Bootsy.alertUnsavedChanges = function(){
24
+ if(unsavedChanges){
25
+ return "<%= I18n.t 'bootsy.js.alert_unsaved' %>";
26
+ }
27
+ };
28
+
29
+ Bootsy.ready = function(){
30
+ if($('textarea.bootsy_text_area').length > 0){
31
+ element = $('#bootsy_image_gallery');
32
+
33
+ element.parents('form').after(element);
34
+
35
+ element.find('a.refresh_btn').live('click', function(e){
36
+ $(this).hide();
37
+ Bootsy.progressBar(element);
38
+ });
39
+
40
+ element.find('a.destroy_btn').click(function(e){
41
+ Bootsy.progressBar(element);
42
+ });
43
+
44
+ // element.find('#new_image').live('ajax:before', function(e){
45
+ // console.log('sending...')
46
+ // Bootsy.progressBar(element);
47
+ // });
22
48
 
23
- element.find('a.refresh_btn').live('click', function(e){
24
- $(this).hide();
25
- bootsyProgressBar(element);
26
- });
49
+ element.modal({show: false});
50
+ element.on('shown', function(){
51
+ Bootsy.refreshGallery(element);
52
+ });
27
53
 
28
- element.find('a.destroy_btn').click(function(e){
29
- bootsyProgressBar(element);
30
- });
54
+ var editorOptions = {color: true, locale: "<%= I18n.default_locale %>"};
31
55
 
32
- element.modal({show: false});
33
- element.on('shown', function(){
34
- bootsyRefreshGallery(element);
35
- });
56
+ if($('textarea.bootsy_text_area').attr('data-enable-image') == 'false'){
57
+ editorOptions.image = false;
58
+ }else{
59
+ if($('textarea.bootsy_text_area').attr('data-enable-uploader') == 'false'){
60
+ editorOptions.image = true;
61
+ }else{
62
+ editorOptions.image = false;
63
+ editorOptions.imageUpload = true;
64
+ editorOptions.imageUploadCallback = Bootsy.openImageGallery;
65
+ }
66
+ }
36
67
 
37
- wysihtml5Editor = $('textarea.bootsy_text_area').wysihtml5({"image": false, "imageUpload": true, imageUploadCallback: bootsyOpenImageGallery, locale: "<%= I18n.default_locale %>"}).data("wysihtml5").editor;
68
+ if($('textarea.bootsy_text_area').attr('data-enable-font-styles') == 'false') editorOptions['font-styles'] = false;
69
+ if($('textarea.bootsy_text_area').attr('data-enable-emphasis') == 'false') editorOptions.emphasis = false;
70
+ if($('textarea.bootsy_text_area').attr('data-enable-lists') == 'false') editorOptions.lists = false;
71
+ if($('textarea.bootsy_text_area').attr('data-enable-html') == 'true') editorOptions.html = true;
72
+ if($('textarea.bootsy_text_area').attr('data-enable-link') == 'false') editorOptions.link = false;
73
+ if($('textarea.bootsy_text_area').attr('data-enable-color') == 'false') editorOptions.color = false;
38
74
 
39
- element.on('hide', function() {
40
- wysihtml5Editor.currentView.element.focus();
41
- });
75
+ Bootsy.editor = $('textarea.bootsy_text_area').wysihtml5(editorOptions).data("wysihtml5").editor;
42
76
 
43
- element.on('click.dismiss.modal', '[data-dismiss="modal"]', function(e) {
44
- e.stopPropagation();
45
- });
77
+ element.on('hide', function() {
78
+ Bootsy.editor.currentView.element.focus();
79
+ });
46
80
 
47
- element.find('ul.dropdown-menu a.insert').live('click', function(e){
48
- var imagePrefix = "/"+$(this).attr('data-image-size')+"_";
49
- if($(this).attr('data-image-size') == 'original'){
50
- imagePrefix = '/';
81
+ element.on('click.dismiss.modal', '[data-dismiss="modal"]', function(e) {
82
+ e.stopPropagation();
83
+ });
84
+
85
+ element.find('ul.dropdown-menu a.insert').live('click', function(e){
86
+ var imagePrefix = "/"+$(this).attr('data-image-size')+"_";
87
+ if($(this).attr('data-image-size') == 'original'){
88
+ imagePrefix = '/';
89
+ }
90
+ var img = $(this).parents('li.dropdown').find('img');
91
+ var obj = {
92
+ src: img.attr('src').replace("/thumb_", imagePrefix),
93
+ alt: img.attr('alt').replace("Thumb_", "")
94
+ };
95
+
96
+ obj.align = $(this).attr('data-position');
97
+
98
+ Bootsy.insertImage(obj, Bootsy.editor);
99
+ });
100
+
101
+ Bootsy.editor.on("change", function(){
102
+ Bootsy.unsavedChanges = true;
103
+ });
104
+
105
+ $('textarea.bootsy_text_area').closest('form').submit(function(e){
106
+ Bootsy.unsavedChanges = false;
107
+ return true;
108
+ });
109
+
110
+ // In order to properly work with Twitter Bootstrap 2.1
111
+ $('body').off('click.dropdown touchstart.dropdown.data-api', '.dropdown');
112
+ $('body').on('click.dropdown touchstart.dropdown.data-api', '.dropdown form', function(e){
113
+ e.stopPropagation();
114
+ });
115
+
116
+ if($('textarea.bootsy_text_area').attr('data-alert-unsaved') != 'false'){
117
+ window.onbeforeunload = Bootsy.alertUnsavedChanges;
118
+ }
51
119
  }
52
- var img = $(this).parents('li.dropdown').find('img');
53
- var src = img.attr('src').replace("/thumb_", imagePrefix);
54
- var alt = img.attr('alt');
55
-
56
- bootsyInsertImage({src: src, alt: alt}, wysihtml5Editor);
57
- });
58
-
59
- $('body').off('click.dropdown touchstart.dropdown.data-api', '.dropdown');
60
- $('body').on('click.dropdown touchstart.dropdown.data-api', '.dropdown form', function(e){
61
- e.stopPropagation();
62
- });
63
- });
120
+ };
121
+
122
+ return Bootsy;
123
+ }).call(this);
124
+
125
+ $(Bootsy.ready);
@@ -4,31 +4,45 @@
4
4
  (function($){
5
5
  $.fn.wysihtml5.locale["pt-BR"] = {
6
6
  font_styles: {
7
- normal: "Texto normal",
8
- h1: "Título 1",
9
- h2: "Título 2"
7
+ normal: "Texto normal",
8
+ h1: "Título 1",
9
+ h2: "Título 2",
10
+ h3: "Título 3"
10
11
  },
11
12
  emphasis: {
12
- bold: "Negrito",
13
- italic: "Itálico",
14
- underline: "Sublinhado"
13
+ bold: "Negrito",
14
+ italic: "Itálico",
15
+ underline: "Sublinhado"
15
16
  },
16
17
  lists: {
17
- unordered: "Lista",
18
- ordered: "Lista numerada",
19
- outdent: "Remover indentação",
20
- indent: "Indentar"
18
+ unordered: "Lista",
19
+ ordered: "Lista numerada",
20
+ outdent: "Remover indentação",
21
+ indent: "Indentar"
21
22
  },
22
23
  link: {
23
- insert: "Inserir link",
24
- cancel: "Cancelar"
24
+ insert: "Inserir link",
25
+ cancel: "Cancelar"
25
26
  },
26
27
  image: {
27
- insert: "Inserir imagem",
28
- cancel: "Cancelar"
28
+ insert: "Inserir imagem",
29
+ cancel: "Cancelar"
29
30
  },
30
31
  html: {
31
32
  edit: "Editar HTML"
33
+ },
34
+ colours: {
35
+ black: "Preto",
36
+ silver: "Prata",
37
+ gray: "Cinza",
38
+ maroon: "Marrom",
39
+ red: "Vermelho",
40
+ purple: "Roxo",
41
+ green: "Verde",
42
+ olive: "Oliva",
43
+ navy: "Marinho",
44
+ blue: "Azul",
45
+ orange: "Laranja"
32
46
  }
33
47
  };
34
48
  }(jQuery));
@@ -35,10 +35,68 @@ ul.wysihtml5-toolbar a.btn.wysihtml5-command-active {
35
35
  -moz-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15),0 1px 2px rgba(0, 0, 0, 0.05);
36
36
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15),0 1px 2px rgba(0, 0, 0, 0.05);
37
37
  background-color: #E6E6E6;
38
- background-color: #D9D9D9 9;
38
+ background-color: #D9D9D9;
39
39
  outline: 0;
40
40
  }
41
41
 
42
42
  ul.wysihtml5-commands-disabled .dropdown-menu {
43
43
  display: none !important;
44
44
  }
45
+
46
+ ul.wysihtml5-toolbar div.wysihtml5-colors {
47
+ display:block;
48
+ width: 50px;
49
+ height: 20px;
50
+ margin-top: 2px;
51
+ margin-left: 5px;
52
+ position: absolute;
53
+ pointer-events: none;
54
+ }
55
+
56
+ ul.wysihtml5-toolbar a.wysihtml5-colors-title {
57
+ padding-left: 70px;
58
+ }
59
+
60
+ ul.wysihtml5-toolbar div[data-wysihtml5-command-value="black"] {
61
+ background: black !important;
62
+ }
63
+
64
+ ul.wysihtml5-toolbar div[data-wysihtml5-command-value="silver"] {
65
+ background: silver !important;
66
+ }
67
+
68
+ ul.wysihtml5-toolbar div[data-wysihtml5-command-value="gray"] {
69
+ background: gray !important;
70
+ }
71
+
72
+ ul.wysihtml5-toolbar div[data-wysihtml5-command-value="maroon"] {
73
+ background: maroon !important;
74
+ }
75
+
76
+ ul.wysihtml5-toolbar div[data-wysihtml5-command-value="red"] {
77
+ background: red !important;
78
+ }
79
+
80
+ ul.wysihtml5-toolbar div[data-wysihtml5-command-value="purple"] {
81
+ background: purple !important;
82
+ }
83
+
84
+ ul.wysihtml5-toolbar div[data-wysihtml5-command-value="green"] {
85
+ background: green !important;
86
+ }
87
+
88
+ ul.wysihtml5-toolbar div[data-wysihtml5-command-value="olive"] {
89
+ background: olive !important;
90
+ }
91
+
92
+ ul.wysihtml5-toolbar div[data-wysihtml5-command-value="navy"] {
93
+ background: navy !important;
94
+ }
95
+
96
+ ul.wysihtml5-toolbar div[data-wysihtml5-command-value="blue"] {
97
+ background: blue !important;
98
+ }
99
+
100
+ ul.wysihtml5-toolbar div[data-wysihtml5-command-value="orange"] {
101
+ background: orange !important;
102
+ }
@@ -0,0 +1,77 @@
1
+ .wysiwyg-color-black {
2
+ color: black;
3
+ }
4
+
5
+ .wysiwyg-color-silver {
6
+ color: silver;
7
+ }
8
+
9
+ .wysiwyg-color-gray {
10
+ color: gray;
11
+ }
12
+
13
+ .wysiwyg-color-white {
14
+ color: white;
15
+ }
16
+
17
+ .wysiwyg-color-maroon {
18
+ color: maroon;
19
+ }
20
+
21
+ .wysiwyg-color-red {
22
+ color: red;
23
+ }
24
+
25
+ .wysiwyg-color-purple {
26
+ color: purple;
27
+ }
28
+
29
+ .wysiwyg-color-fuchsia {
30
+ color: fuchsia;
31
+ }
32
+
33
+ .wysiwyg-color-green {
34
+ color: green;
35
+ }
36
+
37
+ .wysiwyg-color-lime {
38
+ color: lime;
39
+ }
40
+
41
+ .wysiwyg-color-olive {
42
+ color: olive;
43
+ }
44
+
45
+ .wysiwyg-color-yellow {
46
+ color: yellow;
47
+ }
48
+
49
+ .wysiwyg-color-navy {
50
+ color: navy;
51
+ }
52
+
53
+ .wysiwyg-color-blue {
54
+ color: blue;
55
+ }
56
+
57
+ .wysiwyg-color-teal {
58
+ color: teal;
59
+ }
60
+
61
+ .wysiwyg-color-aqua {
62
+ color: aqua;
63
+ }
64
+
65
+ .wysiwyg-float-left {
66
+ float: left;
67
+ margin: 0 8px 8px 0;
68
+ }
69
+
70
+ .wysiwyg-float-right {
71
+ float: right;
72
+ margin: 0 0 8px 8px;
73
+ }
74
+
75
+ form.bootsy .field_with_errors {
76
+ display: inline-block;
77
+ }
@@ -20,7 +20,8 @@ module Bootsy
20
20
  def create
21
21
  @gallery = find_gallery
22
22
  @gallery.save! unless @gallery.persisted?
23
- @image = @gallery.images.new params[:image]
23
+ @image = Image.new params[:image]
24
+ @image.image_gallery_id = @gallery.id
24
25
  @images = @gallery.images
25
26
 
26
27
  respond_to do |format|
@@ -28,7 +29,6 @@ module Bootsy
28
29
  format.js
29
30
  format.json { render json: @image, status: :created, location: @image }
30
31
  else
31
- pp @image.errors
32
32
  format.js
33
33
  format.json { render json: @image.errors, status: :unprocessable_entity }
34
34
  end
@@ -11,22 +11,22 @@ module Bootsy
11
11
 
12
12
 
13
13
  def store_dir
14
- "uploads/#{model.class.to_s.underscore}/#{model.id}"
14
+ "#{Bootsy.store_dir}/#{model.class.to_s.underscore}/#{model.id}"
15
15
  end
16
16
 
17
17
  # Process files as they are uploaded:
18
- process :resize_to_limit => [940, 940]
18
+ process :resize_to_limit => [1160, 2000]
19
19
 
20
20
  version :large do
21
- process :resize_to_fit => [600, 600]
21
+ process :resize_to_fit => [Bootsy.large_image[:width], Bootsy.large_image[:height]]
22
22
  end
23
23
 
24
24
  version :medium do
25
- process :resize_to_fit => [300, 300]
25
+ process :resize_to_fit => [Bootsy.medium_image[:width], Bootsy.medium_image[:height]]
26
26
  end
27
27
 
28
28
  version :small do
29
- process :resize_to_fit => [160, 160]
29
+ process :resize_to_fit => [Bootsy.small_image[:width], Bootsy.small_image[:height]]
30
30
  end
31
31
 
32
32
  version :thumb do
@@ -4,21 +4,32 @@
4
4
  <%= link_to image_tag(image.image_file.thumb.url), '#', :class => 'thumbnail', data: { toggle: 'dropdown'} %>
5
5
  <ul class="dropdown-menu" role="menu">
6
6
  <li class="nav-header"><%= t 'bootsy.image.size' %></li>
7
- <% [:small, :medium, :large, :original].each do |size| %>
8
- <li>
9
- <%= link_to '#', :class => 'insert', tabindex: '-1', data: { :'image-size' => size.to_s} do %>
7
+ <% Bootsy.image_versions_available.each do |size| %>
8
+ <li class="dropdown-submenu">
9
+ <%= link_to '#' do %>
10
10
  <i class="icon-picture"></i>
11
11
  <%= t "bootsy.image.#{size}" %>
12
12
  <% end %>
13
+ <ul class="dropdown-menu">
14
+ <% [:left, :right, :inline].each do |position| %>
15
+ <li>
16
+ <%= link_to '#', :class => 'insert', tabindex: '-1', data: { :'image-size' => size.to_s, position: position.to_s} do %>
17
+ <%= t "bootsy.image.position.#{position}" %>
18
+ <% end %>
19
+ </li>
20
+ <% end %>
21
+ </ul>
22
+ </li>
23
+ <% end %>
24
+ <% if Bootsy.allow_destroy %>
25
+ <li class="divider"></li>
26
+ <li>
27
+ <%= link_to image, method: :delete, remote: true, data: { confirm: t('bootsy.image.confirm.destroy')}, tabindex: '-1', :class => 'destroy_btn' do %>
28
+ <i class="icon-trash"></i>
29
+ <%= t 'bootsy.action.destroy' %>
30
+ <% end %>
13
31
  </li>
14
32
  <% end %>
15
- <li class="divider"></li>
16
- <li>
17
- <%= link_to image, method: :delete, remote: true, data: { confirm: t('bootsy.image.confirm.destroy')}, tabindex: '-1', :class => 'destroy_btn' do %>
18
- <i class="icon-trash"></i>
19
- <%= t 'bootsy.action.destroy' %>
20
- <% end %>
21
- </li>
22
33
  </ul>
23
34
  </li>
24
35
  <% end %>
@@ -4,7 +4,7 @@
4
4
  <h2><%= t 'bootsy.image.p' %></h2>
5
5
  </div>
6
6
  <div class="modal-body">
7
- <%= refresh_btn resource.bootsy_image_gallery, :images %>
7
+ <%= refresh_btn container.bootsy_image_gallery, :images %>
8
8
  </div>
9
9
  <div class="modal-footer">
10
10
  <a href="#" class="btn" data-dismiss="modal"><%= t 'bootsy.action.close' %></a>
@@ -1 +1 @@
1
- bootsyRefreshGallery($('#bootsy_image_gallery'));
1
+ Bootsy.refreshGallery($('#bootsy_image_gallery'));
@@ -17,3 +17,9 @@ en:
17
17
  new: New image
18
18
  confirm:
19
19
  destroy: Are you sure you want do destroy this image?
20
+ position:
21
+ left: Left
22
+ right: Right
23
+ inline: Inline
24
+ js:
25
+ alert_unsaved: You have unsaved changes.
@@ -16,4 +16,10 @@ pt-BR:
16
16
  original: Original
17
17
  new: Nova imagem
18
18
  confirm:
19
- destroy: Tem certeza que deseja apagar esta imagem?
19
+ destroy: Tem certeza que deseja apagar esta imagem?
20
+ position:
21
+ left: Esquerda
22
+ right: Direita
23
+ inline: Mesma linha
24
+ js:
25
+ alert_unsaved: As suas modificações ainda não foram gravadas.
@@ -3,5 +3,9 @@ Bootsy::Engine.routes.draw do
3
3
  resources :images, only: [:index, :create, :update, :destroy]
4
4
  end
5
5
 
6
- resources :images, only: [:index, :create, :update, :destroy]
6
+ file_routes = [:index, :create, :update]
7
+
8
+ file_routes << :destroy if Bootsy.allow_destroy
9
+
10
+ resources :images, only: file_routes
7
11
  end
@@ -1,10 +1,48 @@
1
1
  require 'carrierwave'
2
2
  require 'remotipart'
3
3
  require 'bootsy/engine'
4
- require 'bootsy/media_container'
4
+ require 'bootsy/container'
5
5
  require 'bootsy/form_helper'
6
6
  require 'bootsy/form_builder'
7
7
  require 'bootsy/core_ext'
8
8
 
9
9
  module Bootsy
10
+ ## CONFIGURATION OPTIONS
11
+
12
+ # Image versions available
13
+ mattr_accessor :image_versions_available
14
+ @@image_versions_available = [:small, :medium, :large, :original]
15
+
16
+ # Whether user can destroy uploaded files
17
+ mattr_accessor :allow_destroy
18
+ @@allow_destroy = true
19
+
20
+ # Settings for small images
21
+ mattr_accessor :small_image
22
+ @@small_image = {width: 160, height: 160}
23
+
24
+ # Settings for medium images
25
+ mattr_accessor :medium_image
26
+ @@medium_image = {width: 360, height: 360}
27
+
28
+ # Settings for large images
29
+ mattr_accessor :large_image
30
+ @@large_image = {width: 760, height: 760}
31
+
32
+ # Settings for the original version of images
33
+ mattr_accessor :original_image
34
+ @@original_image = {}
35
+
36
+ # Store directory (inside of 'public')
37
+ mattr_accessor :store_dir
38
+ @@store_dir = 'uploads'
39
+
40
+
41
+ ## SETUP
42
+
43
+ # Default way to setup Bootsy. Run rails generate bootsy:install
44
+ # to create a fresh initializer with all configuration values.
45
+ def self.setup
46
+ yield self
47
+ end
10
48
  end
@@ -1,6 +1,6 @@
1
1
  module Bootsy
2
2
  class Image < ActiveRecord::Base
3
- belongs_to :image_gallery
3
+ belongs_to :image_gallery, touch: true
4
4
 
5
5
  mount_uploader :image_file, ImageUploader
6
6
 
@@ -1,7 +1,7 @@
1
1
  require 'active_support/concern'
2
2
 
3
3
  module Bootsy
4
- module MediaContainer
4
+ module Container
5
5
 
6
6
  extend ActiveSupport::Concern
7
7
 
@@ -2,20 +2,46 @@ module Bootsy
2
2
  module FormHelper
3
3
  def bootsy_area object, method, options = {}
4
4
 
5
- resource = options[:resource]
6
- options.delete :resource
5
+ container = options.delete :container
7
6
 
8
- unless resource.kind_of?(MediaContainer) || (resource.nil? && object.kind_of?(MediaContainer))
9
- raise ArgumentError, 'Bootsy area needs a model or a resource as its option'
7
+ unless container.kind_of?(Container) || (container.nil? && object.kind_of?(Container))
8
+ raise ArgumentError, 'Bootsy area needs a model or a container as its option'
9
+ end
10
+
11
+ editor_options = options.delete :editor_options
12
+
13
+ unless editor_options.nil?
14
+
15
+ options[:'data-enable-uploader'] = 'false' if editor_options[:uploader] == false
16
+
17
+ options[:'data-alert-unsaved'] = 'false' if editor_options[:alert_unsaved] == false
18
+
19
+ options[:'data-enable-font-styles'] = 'false' if editor_options[:font_styles] == false
20
+
21
+ options[:'data-enable-emphasis'] = 'false' if editor_options[:emphasis] == false
22
+
23
+ options[:'data-enable-lists'] = 'false' if editor_options[:lists] == false
24
+
25
+ options[:'data-enable-html'] = 'true' if editor_options[:html] == true
26
+
27
+ options[:'data-enable-link'] = 'false' if editor_options[:link] == false
28
+
29
+ options[:'data-enable-image'] = 'false' if editor_options[:image] == false
30
+
31
+ options[:'data-enable-color'] = 'false' if editor_options[:color] == false
32
+
10
33
  end
11
34
 
12
35
  object_name = object.class.name.underscore
13
36
 
14
- output = self.render 'bootsy/images/modal', {resource: resource || object}
15
- output += self.text_area object_name, method, options.merge({:class => 'bootsy_text_area'}){|key, oldval, newval| "#{oldval} #{newval}"}
16
- if resource.nil? || (resource == object)
37
+ output = self.render 'bootsy/images/modal', {container: container || object}
38
+ options[:class] = (options[:class].nil? ? [] : (options[:class].kind_of?(Array) ? options[:class] : [options[:class]])) + [:bootsy_text_area]
39
+ output += self.text_area object_name, method, options
40
+
41
+ if container.nil? || (container == object)
17
42
  output += self.hidden_field object_name, :bootsy_image_gallery_id, :class => 'bootsy_image_gallery_id'
18
43
  end
44
+
19
45
  output
20
46
  end
21
47
  end
@@ -1,3 +1,3 @@
1
1
  module Bootsy
2
- VERSION = "0.0.5"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -31,6 +31,10 @@ module Bootsy
31
31
 
32
32
  end
33
33
 
34
+ def copy_config
35
+ template '../templates/bootsy.rb', 'config/initializers/bootsy.rb'
36
+ end
37
+
34
38
  end
35
39
  end
36
40
  end
@@ -0,0 +1,43 @@
1
+ # Use this setup block to configure all options available in Bootsy.
2
+ Bootsy.setup do |config|
3
+
4
+ # Image versions available
5
+ # Possible values: :small, :medium, :large and/or :original
6
+ config.image_versions_available = [:small, :medium, :large, :original]
7
+
8
+
9
+ # SMALL IMAGES
10
+
11
+ # Width limit for small images
12
+ # config.small_image[:width] = 160
13
+
14
+ # Height limit for small images
15
+ # config.small_image[:height] = 160
16
+
17
+
18
+ # MEDIUM IMAGES
19
+
20
+ # Width limit for medium images
21
+ # config.medium_image[:width] = 360
22
+
23
+ # Height limit for medium images
24
+ # config.medium_image[:height] = 360
25
+
26
+
27
+ # LARGE IMAGES
28
+
29
+ # Width limit for large images
30
+ # config.large_image[:width] = 760
31
+
32
+ # Height limit for large images
33
+ # config.large_image[:height] = 760
34
+
35
+
36
+ # Whether user can destroy uploaded files
37
+ # config.allow_destroy = true
38
+
39
+
40
+ # Store directory (inside of 'public')
41
+ # BE CAREFUL! Changing this may break previously uploaded file paths!
42
+ # config.store_dir = 'uploads'
43
+ 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.0.5
4
+ version: 0.1.0
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-16 00:00:00.000000000 Z
12
+ date: 2012-09-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mini_magick
@@ -34,7 +34,7 @@ dependencies:
34
34
  requirements:
35
35
  - - ~>
36
36
  - !ruby/object:Gem::Version
37
- version: 0.6.2
37
+ version: '0.6'
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
@@ -42,7 +42,7 @@ dependencies:
42
42
  requirements:
43
43
  - - ~>
44
44
  - !ruby/object:Gem::Version
45
- version: 0.6.2
45
+ version: '0.6'
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: remotipart
48
48
  requirement: !ruby/object:Gem::Requirement
@@ -50,7 +50,7 @@ dependencies:
50
50
  requirements:
51
51
  - - ~>
52
52
  - !ruby/object:Gem::Version
53
- version: 1.0.2
53
+ version: '1.0'
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
@@ -58,7 +58,7 @@ dependencies:
58
58
  requirements:
59
59
  - - ~>
60
60
  - !ruby/object:Gem::Version
61
- version: 1.0.2
61
+ version: '1.0'
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: rails
64
64
  requirement: !ruby/object:Gem::Requirement
@@ -66,7 +66,7 @@ dependencies:
66
66
  requirements:
67
67
  - - ~>
68
68
  - !ruby/object:Gem::Version
69
- version: 3.2.8
69
+ version: '3.2'
70
70
  type: :development
71
71
  prerelease: false
72
72
  version_requirements: !ruby/object:Gem::Requirement
@@ -74,7 +74,7 @@ dependencies:
74
74
  requirements:
75
75
  - - ~>
76
76
  - !ruby/object:Gem::Version
77
- version: 3.2.8
77
+ version: '3.2'
78
78
  - !ruby/object:Gem::Dependency
79
79
  name: sqlite3
80
80
  requirement: !ruby/object:Gem::Requirement
@@ -82,7 +82,7 @@ dependencies:
82
82
  requirements:
83
83
  - - ~>
84
84
  - !ruby/object:Gem::Version
85
- version: 1.3.6
85
+ version: '1.3'
86
86
  type: :development
87
87
  prerelease: false
88
88
  version_requirements: !ruby/object:Gem::Requirement
@@ -90,7 +90,7 @@ dependencies:
90
90
  requirements:
91
91
  - - ~>
92
92
  - !ruby/object:Gem::Version
93
- version: 1.3.6
93
+ version: '1.3'
94
94
  - !ruby/object:Gem::Dependency
95
95
  name: rspec-rails
96
96
  requirement: !ruby/object:Gem::Requirement
@@ -98,7 +98,7 @@ dependencies:
98
98
  requirements:
99
99
  - - ~>
100
100
  - !ruby/object:Gem::Version
101
- version: 2.11.0
101
+ version: '2.11'
102
102
  type: :development
103
103
  prerelease: false
104
104
  version_requirements: !ruby/object:Gem::Requirement
@@ -106,7 +106,7 @@ dependencies:
106
106
  requirements:
107
107
  - - ~>
108
108
  - !ruby/object:Gem::Version
109
- version: 2.11.0
109
+ version: '2.11'
110
110
  - !ruby/object:Gem::Dependency
111
111
  name: factory_girl_rails
112
112
  requirement: !ruby/object:Gem::Requirement
@@ -114,7 +114,7 @@ dependencies:
114
114
  requirements:
115
115
  - - ~>
116
116
  - !ruby/object:Gem::Version
117
- version: 4.1.0
117
+ version: '4.1'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
@@ -122,7 +122,7 @@ dependencies:
122
122
  requirements:
123
123
  - - ~>
124
124
  - !ruby/object:Gem::Version
125
- version: 4.1.0
125
+ version: '4.1'
126
126
  - !ruby/object:Gem::Dependency
127
127
  name: database_cleaner
128
128
  requirement: !ruby/object:Gem::Requirement
@@ -130,7 +130,7 @@ dependencies:
130
130
  requirements:
131
131
  - - ~>
132
132
  - !ruby/object:Gem::Version
133
- version: 0.8.0
133
+ version: '0.8'
134
134
  type: :development
135
135
  prerelease: false
136
136
  version_requirements: !ruby/object:Gem::Requirement
@@ -138,7 +138,7 @@ dependencies:
138
138
  requirements:
139
139
  - - ~>
140
140
  - !ruby/object:Gem::Version
141
- version: 0.8.0
141
+ version: '0.8'
142
142
  - !ruby/object:Gem::Dependency
143
143
  name: cucumber-rails
144
144
  requirement: !ruby/object:Gem::Requirement
@@ -146,7 +146,7 @@ dependencies:
146
146
  requirements:
147
147
  - - ~>
148
148
  - !ruby/object:Gem::Version
149
- version: 1.3.0
149
+ version: '1.3'
150
150
  type: :development
151
151
  prerelease: false
152
152
  version_requirements: !ruby/object:Gem::Requirement
@@ -154,10 +154,8 @@ dependencies:
154
154
  requirements:
155
155
  - - ~>
156
156
  - !ruby/object:Gem::Version
157
- version: 1.3.0
158
- description: Bootsy is a WYSIWIG editor for Rails applications based on WYSIHTML5
159
- and Twitter Bootstrap. It integrates images uploads using CarrierWave, as an image
160
- gallery scoped in models of your application.
157
+ version: '1.3'
158
+ description: A beautiful WYSIWYG editor with image uploads for Rails.
161
159
  email:
162
160
  - volmerius@gmail.com
163
161
  executables: []
@@ -181,6 +179,7 @@ files:
181
179
  - app/assets/javascripts/bootsy/bootsy.js.erb
182
180
  - app/assets/stylesheets/bootsy.css
183
181
  - app/assets/stylesheets/bootsy/bootstrap-wysihtml5.css
182
+ - app/assets/stylesheets/bootsy/bootsy.css
184
183
  - config/locales/en.yml
185
184
  - config/locales/pt-BR.yml
186
185
  - config/routes.rb
@@ -189,16 +188,17 @@ files:
189
188
  - db/migrate/20120624171333_create_bootsy_images.rb
190
189
  - db/migrate/20120628124845_create_bootsy_image_galleries.rb
191
190
  - lib/generators/bootsy/install_generator.rb
191
+ - lib/generators/bootsy/templates/bootsy.rb
192
192
  - lib/generators/bootsy/USAGE
193
193
  - lib/bootsy.rb
194
194
  - lib/tasks/bootsy_tasks.rake
195
195
  - lib/tasks/cucumber.rake
196
196
  - lib/bootsy/form_helper.rb
197
- - lib/bootsy/media_container.rb
198
197
  - lib/bootsy/version.rb
199
198
  - lib/bootsy/activerecord/image_gallery.rb
200
199
  - lib/bootsy/activerecord/image.rb
201
200
  - lib/bootsy/core_ext.rb
201
+ - lib/bootsy/container.rb
202
202
  - lib/bootsy/form_builder.rb
203
203
  - lib/bootsy/engine.rb
204
204
  - MIT-LICENSE
@@ -218,7 +218,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
218
218
  version: '0'
219
219
  segments:
220
220
  - 0
221
- hash: 2387402174944412572
221
+ hash: 2323044917937113388
222
222
  required_rubygems_version: !ruby/object:Gem::Requirement
223
223
  none: false
224
224
  requirements:
@@ -227,11 +227,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
227
227
  version: '0'
228
228
  segments:
229
229
  - 0
230
- hash: 2387402174944412572
230
+ hash: 2323044917937113388
231
231
  requirements: []
232
232
  rubyforge_project:
233
233
  rubygems_version: 1.8.24
234
234
  signing_key:
235
235
  specification_version: 3
236
- summary: A beautiful wysiwig editor with image uploads for Rails.
236
+ summary: A beautiful WYSIWYG editor with image uploads for Rails.
237
237
  test_files: []