bootsy 0.1.5 → 0.1.6

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
@@ -66,15 +66,52 @@ Bootsy will group the uploaded image files as galleries and associate them to on
66
66
  end
67
67
  ```
68
68
 
69
+ ## Editor options
70
+
71
+ It's possible to customize how the editor is displayed and its behavior by passing a hash `editor_options` to your `bootsy_area`.
72
+
73
+
74
+ ### Buttons
75
+
76
+ You can enable/disable the buttons available in the editor. For example, if you want to disable the link and color buttons:
77
+
78
+ ```erb
79
+ <%= f.bootsy_area :my_attribute, editor_options: {link: false, color: false} %>
80
+ ```
81
+ Available options are: `:font_styles`, `:emphasis`, `:lists`, `:html`, `:link`, `:image` and `:color`.
82
+
83
+
84
+ ### Alert for usaved changes
85
+
86
+ By default, Bootsy alerts for unsaved changes if the user attempts to unload the window. You can disable it by doing:
87
+
88
+ ```erb
89
+ <%= f.bootsy_area :my_attribute, editor_options: {alert_unsaved: false} %>
90
+ ```
91
+
92
+ ### Uploader
93
+
94
+ It is also possible to disable the image upload feature entirely. This way the user can insert images in his/her text by providing an image url. Simple and easy:
95
+
96
+ ```erb
97
+ <%= f.bootsy_area :my_attribute, editor_options: {uploader: false} %>
98
+ ```
99
+ *Note*: this option is automatically defined if you use `bootsy_area` without a `Bootsy::Container` model.
100
+
101
+
102
+ ## Configuration
103
+
104
+ You can set the image sizes available (small, medium, large and/or its original), its dimensions and more. Take a look at the initalizer file, `/config/initializers/bootsy.rb`.
105
+
69
106
 
70
107
  ## I18n
71
108
 
72
- Bootsy defines some i18n keys. The english translation is automatically added to your `config/locales` directory as `bootsy.en.yml`. You can follow that template in order to translate Bootsy for your language. You can find some examples [here](https://github.com/volmer/bootsy/tree/master/config/locales).
109
+ Bootsy defines some i18n keys. The english translation is automatically added to your `config/locales` directory as `bootsy.en.yml`. You can follow that template in order to translate Bootsy for your language. You can find some examples [here](https://github.com/volmer/bootsy/tree/master/config/locales). It is also necessary to add a translation for Bootstrap-wysihtml5, the javascript editor, in your assets pipeline. Instructions [here](https://github.com/jhollingworth/bootstrap-wysihtml5#i18n).
73
110
 
74
111
 
75
112
  ## Mongoid support
76
113
 
77
- Par default, Bootsy only supports ActiveRecord. In order to use Bootsy with Mongoid, please use [bootsy-mongoid](https://github.com/volmer/bootsy-mongoid) instead.
114
+ Par default, Bootsy only supports ActiveRecord. In order to use Bootsy with Mongoid, please use [Bootsy-Mongoid](https://github.com/volmer/bootsy-mongoid) instead.
78
115
 
79
116
 
80
117
  ## Bootsy with SimpleForm
@@ -4,168 +4,109 @@
4
4
  var templates = function(key, locale) {
5
5
 
6
6
  var tpl = {
7
- "font-styles": "<li class='dropdown'>" +
8
- "<a class='btn dropdown-toggle' data-toggle='dropdown' href='#'>" +
9
- "<i class='icon-font'></i>&nbsp;<span class='current-font'>" + locale.font_styles.normal + "</span>&nbsp;<b class='caret'></b>" +
10
- "</a>" +
11
- "<ul class='dropdown-menu'>" +
12
- "<li><a data-wysihtml5-command='formatBlock' data-wysihtml5-command-value='div'>" + locale.font_styles.normal + "</a></li>" +
13
- "<li><a data-wysihtml5-command='formatBlock' data-wysihtml5-command-value='h1'>" + locale.font_styles.h1 + "</a></li>" +
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>" +
16
- "</ul>" +
17
- "</li>",
18
- "emphasis": "<li>" +
19
- "<div class='btn-group'>" +
20
- "<a class='btn' data-wysihtml5-command='bold' title='CTRL+B'>" + locale.emphasis.bold + "</a>" +
21
- "<a class='btn' data-wysihtml5-command='italic' title='CTRL+I'>" + locale.emphasis.italic + "</a>" +
22
- "<a class='btn' data-wysihtml5-command='underline' title='CTRL+U'>" + locale.emphasis.underline + "</a>" +
23
- "</div>" +
24
- "</li>",
25
- "lists": "<li>" +
26
- "<div class='btn-group'>" +
27
- "<a class='btn' data-wysihtml5-command='insertUnorderedList' title='" + locale.lists.unordered + "'><i class='icon-list'></i></a>" +
28
- "<a class='btn' data-wysihtml5-command='insertOrderedList' title='" + locale.lists.ordered + "'><i class='icon-th-list'></i></a>" +
29
- "<a class='btn' data-wysihtml5-command='Outdent' title='" + locale.lists.outdent + "'><i class='icon-indent-right'></i></a>" +
30
- "<a class='btn' data-wysihtml5-command='Indent' title='" + locale.lists.indent + "'><i class='icon-indent-left'></i></a>" +
31
- "</div>" +
32
- "</li>",
33
- "link": "<li>" +
34
- "<div class='bootstrap-wysihtml5-insert-link-modal modal hide fade'>" +
35
- "<div class='modal-header'>" +
36
- "<a class='close' data-dismiss='modal'>&times;</a>" +
37
- "<h3>" + locale.link.insert + "</h3>" +
38
- "</div>" +
39
- "<div class='modal-body'>" +
40
- "<input value='http://' class='bootstrap-wysihtml5-insert-link-url input-xlarge'>" +
41
- "</div>" +
42
- "<div class='modal-footer'>" +
43
- "<a href='#' class='btn' data-dismiss='modal'>" + locale.link.cancel + "</a>" +
44
- "<a href='#' class='btn btn-primary' data-dismiss='modal'>" + locale.link.insert + "</a>" +
45
- "</div>" +
46
- "</div>" +
47
- "<a class='btn' data-wysihtml5-command='createLink' title='" + locale.link.insert + "'><i class='icon-share'></i></a>" +
48
- "</li>",
49
- "image": "<li>" +
50
- "<div class='bootstrap-wysihtml5-insert-image-modal modal hide fade'>" +
51
- "<div class='modal-header'>" +
52
- "<a class='close' data-dismiss='modal'>&times;</a>" +
53
- "<h3>" + locale.image.insert + "</h3>" +
54
- "</div>" +
55
- "<div class='modal-body'>" +
56
- "<input value='http://' class='bootstrap-wysihtml5-insert-image-url input-xlarge'>" +
57
- "</div>" +
58
- "<div class='modal-footer'>" +
59
- "<a href='#' class='btn' data-dismiss='modal'>" + locale.image.cancel + "</a>" +
60
- "<a href='#' class='btn btn-primary' data-dismiss='modal'>" + locale.image.insert + "</a>" +
61
- "</div>" +
62
- "</div>" +
63
- "<a class='btn' data-wysihtml5-command='insertImage' title='" + locale.image.insert + "'><i class='icon-picture'></i></a>" +
64
- "</li>",
65
- "imageUpload": "<li>" +
66
- "<a class='btn' data-wysihtml5-command='insertUploadedImage' title='" + locale.image.insert + "'><i class='icon-picture'></i></a>" +
67
- "</li>",
7
+ "font-styles":
8
+ "<li class='dropdown'>" +
9
+ "<a class='btn dropdown-toggle' data-toggle='dropdown' href='#'>" +
10
+ "<i class='icon-font'></i>&nbsp;<span class='current-font'>" + locale.font_styles.normal + "</span>&nbsp;<b class='caret'></b>" +
11
+ "</a>" +
12
+ "<ul class='dropdown-menu'>" +
13
+ "<li><a data-wysihtml5-command='formatBlock' data-wysihtml5-command-value='div'>" + locale.font_styles.normal + "</a></li>" +
14
+ "<li><a data-wysihtml5-command='formatBlock' data-wysihtml5-command-value='h1'>" + locale.font_styles.h1 + "</a></li>" +
15
+ "<li><a data-wysihtml5-command='formatBlock' data-wysihtml5-command-value='h2'>" + locale.font_styles.h2 + "</a></li>" +
16
+ "<li><a data-wysihtml5-command='formatBlock' data-wysihtml5-command-value='h3'>" + locale.font_styles.h3 + "</a></li>" +
17
+ "</ul>" +
18
+ "</li>",
19
+
20
+ "emphasis":
21
+ "<li>" +
22
+ "<div class='btn-group'>" +
23
+ "<a class='btn' data-wysihtml5-command='bold' title='CTRL+B'>" + locale.emphasis.bold + "</a>" +
24
+ "<a class='btn' data-wysihtml5-command='italic' title='CTRL+I'>" + locale.emphasis.italic + "</a>" +
25
+ "<a class='btn' data-wysihtml5-command='underline' title='CTRL+U'>" + locale.emphasis.underline + "</a>" +
26
+ "</div>" +
27
+ "</li>",
28
+
29
+ "lists":
30
+ "<li>" +
31
+ "<div class='btn-group'>" +
32
+ "<a class='btn' data-wysihtml5-command='insertUnorderedList' title='" + locale.lists.unordered + "'><i class='icon-list'></i></a>" +
33
+ "<a class='btn' data-wysihtml5-command='insertOrderedList' title='" + locale.lists.ordered + "'><i class='icon-th-list'></i></a>" +
34
+ "<a class='btn' data-wysihtml5-command='Outdent' title='" + locale.lists.outdent + "'><i class='icon-indent-right'></i></a>" +
35
+ "<a class='btn' data-wysihtml5-command='Indent' title='" + locale.lists.indent + "'><i class='icon-indent-left'></i></a>" +
36
+ "</div>" +
37
+ "</li>",
38
+
39
+ "link":
40
+ "<li>" +
41
+ "<div class='bootstrap-wysihtml5-insert-link-modal modal hide fade'>" +
42
+ "<div class='modal-header'>" +
43
+ "<a class='close' data-dismiss='modal'>&times;</a>" +
44
+ "<h3>" + locale.link.insert + "</h3>" +
45
+ "</div>" +
46
+ "<div class='modal-body'>" +
47
+ "<input value='http://' class='bootstrap-wysihtml5-insert-link-url input-xlarge'>" +
48
+ "</div>" +
49
+ "<div class='modal-footer'>" +
50
+ "<a href='#' class='btn' data-dismiss='modal'>" + locale.link.cancel + "</a>" +
51
+ "<a href='#' class='btn btn-primary' data-dismiss='modal'>" + locale.link.insert + "</a>" +
52
+ "</div>" +
53
+ "</div>" +
54
+ "<a class='btn' data-wysihtml5-command='createLink' title='" + locale.link.insert + "'><i class='icon-share'></i></a>" +
55
+ "</li>",
56
+
57
+ "image":
58
+ "<li>" +
59
+ "<div class='bootstrap-wysihtml5-insert-image-modal modal hide fade'>" +
60
+ "<div class='modal-header'>" +
61
+ "<a class='close' data-dismiss='modal'>&times;</a>" +
62
+ "<h3>" + locale.image.insert + "</h3>" +
63
+ "</div>" +
64
+ "<div class='modal-body'>" +
65
+ "<input value='http://' class='bootstrap-wysihtml5-insert-image-url input-xlarge'>" +
66
+ "</div>" +
67
+ "<div class='modal-footer'>" +
68
+ "<a href='#' class='btn' data-dismiss='modal'>" + locale.image.cancel + "</a>" +
69
+ "<a href='#' class='btn btn-primary' data-dismiss='modal'>" + locale.image.insert + "</a>" +
70
+ "</div>" +
71
+ "</div>" +
72
+ "<a class='btn' data-wysihtml5-command='insertImage' title='" + locale.image.insert + "'><i class='icon-picture'></i></a>" +
73
+ "</li>",
74
+
75
+ "imageUpload":
76
+ "<li>" +
77
+ "<a class='btn' data-wysihtml5-command='insertUploadedImage' title='" + locale.image.insert + "'><i class='icon-picture'></i></a>" +
78
+ "</li>",
79
+
68
80
  "html":
69
- "<li>" +
70
- "<div class='btn-group'>" +
71
- "<a class='btn' data-wysihtml5-action='change_view' title='" + locale.html.edit + "'><i class='icon-pencil'></i></a>" +
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>" +
92
- "</li>"
81
+ "<li>" +
82
+ "<div class='btn-group'>" +
83
+ "<a class='btn' data-wysihtml5-action='change_view' title='" + locale.html.edit + "'><i class='icon-pencil'></i></a>" +
84
+ "</div>" +
85
+ "</li>",
86
+
87
+ "color":
88
+ "<li class='dropdown'>" +
89
+ "<a class='btn dropdown-toggle' data-toggle='dropdown' href='#'>" +
90
+ "<span class='current-color'>" + locale.colours.black + "</span>&nbsp;<b class='caret'></b>" +
91
+ "</a>" +
92
+ "<ul class='dropdown-menu'>" +
93
+ "<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>" +
94
+ "<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>" +
95
+ "<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>" +
96
+ "<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>" +
97
+ "<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>" +
98
+ "<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>" +
99
+ "<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>" +
100
+ "<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>" +
101
+ "<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>" +
102
+ "<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>" +
103
+ "<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>" +
104
+ "</ul>" +
105
+ "</li>"
93
106
  };
94
107
  return tpl[key];
95
108
  };
96
109
 
97
- var defaultOptions = {
98
- "font-styles": true,
99
- "color": false,
100
- "emphasis": true,
101
- "lists": true,
102
- "html": false,
103
- "link": true,
104
- "image": true,
105
- "imageUpload": false,
106
- imageUploadCallback: undefined,
107
- events: {},
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
- },
130
- tags: {
131
- "b": {},
132
- "i": {},
133
- "br": {},
134
- "ol": {},
135
- "ul": {},
136
- "li": {},
137
- "h1": {},
138
- "h2": {},
139
- "h3": {},
140
- "blockquote": {},
141
- "u": 1,
142
- "img": {
143
- "check_attributes": {
144
- "width": "numbers",
145
- "alt": "alt",
146
- "src": "src",
147
- "height": "numbers"
148
- },
149
- "add_class": {
150
- "align": "align_img"
151
- }
152
- },
153
- "a": {
154
- set_attributes: {
155
- target: "_blank",
156
- rel: "nofollow"
157
- },
158
- check_attributes: {
159
- href: "url" // important to avoid XSS
160
- }
161
- },
162
- "span": 1,
163
- "div": 1
164
- }
165
- },
166
- stylesheets: ["/assets/bootsy/bootsy.css"], // (path_to_project/lib/css/wysiwyg-color.css)
167
- locale: "en"
168
- };
169
110
 
170
111
  var Wysihtml5 = function(el, options) {
171
112
  this.el = el;
@@ -176,9 +117,9 @@
176
117
 
177
118
  $('iframe.wysihtml5-sandbox').each(function(i, el){
178
119
  $(el.contentWindow).off('focus.wysihtml5').on({
179
- 'focus.wysihtml5' : function(){
180
- $('li.dropdown').removeClass('open');
181
- }
120
+ 'focus.wysihtml5' : function(){
121
+ $('li.dropdown').removeClass('open');
122
+ }
182
123
  });
183
124
  });
184
125
  };
@@ -188,17 +129,16 @@
188
129
  constructor: Wysihtml5,
189
130
 
190
131
  createEditor: function(options) {
191
- options = $.extend({}, defaultOptions, options || {});
192
- options.toolbar = this.toolbar[0];
132
+ options = options || {};
133
+ options.toolbar = this.toolbar[0];
193
134
 
194
- var editor = new wysi.Editor(this.el[0], options);
135
+ var editor = new wysi.Editor(this.el[0], options);
195
136
 
196
137
  if(options && options.events) {
197
138
  for(var eventName in options.events) {
198
139
  editor.on(eventName, options.events[eventName]);
199
140
  }
200
141
  }
201
-
202
142
  return editor;
203
143
  },
204
144
 
@@ -208,7 +148,7 @@
208
148
  'class' : "wysihtml5-toolbar",
209
149
  'style': "display:none"
210
150
  });
211
- var culture = options.locale || defaultOptions.locale || "en";
151
+ var culture = options.locale || defaultOptions.locale || "en";
212
152
  for(var key in defaultOptions) {
213
153
  var value = false;
214
154
 
@@ -243,7 +183,7 @@
243
183
 
244
184
  if(options.toolbar) {
245
185
  for(key in options.toolbar) {
246
- toolbar.append(options.toolbar[key]);
186
+ toolbar.append(options.toolbar[key]);
247
187
  }
248
188
  }
249
189
 
@@ -302,25 +242,32 @@
302
242
  });
303
243
 
304
244
  toolbar.find('a[data-wysihtml5-command=insertImage]').click(function() {
305
- var activeButton = $(this).hasClass("wysihtml5-command-active");
306
-
307
- if (!activeButton) {
308
- insertImageModal.modal('show');
309
- insertImageModal.on('click.dismiss.modal', '[data-dismiss="modal"]', function(e) {
310
- e.stopPropagation();
311
- });
312
- return false;
313
- }
314
- else {
315
- return true;
316
- }
245
+ var activeButton = $(this).hasClass("wysihtml5-command-active");
246
+
247
+ if (!activeButton) {
248
+ insertImageModal.modal('show');
249
+ insertImageModal.on('click.dismiss.modal', '[data-dismiss="modal"]', function(e) {
250
+ e.stopPropagation();
251
+ });
252
+ return false;
253
+ }
254
+ else {
255
+ return true;
256
+ }
317
257
  });
318
258
  },
319
259
 
320
260
  initInsertUploadedImage: function(toolbar, callback) {
321
261
  toolbar.find('a[data-wysihtml5-command=insertUploadedImage]').click(function() {
322
- callback(this.editor);
323
- return false;
262
+ var activeButton = $(this).hasClass("wysihtml5-command-active");
263
+
264
+ if (!activeButton) {
265
+ callback(this.editor);
266
+ return false;
267
+ }
268
+ else {
269
+ return true;
270
+ }
324
271
  });
325
272
  },
326
273
 
@@ -360,31 +307,145 @@
360
307
  });
361
308
 
362
309
  toolbar.find('a[data-wysihtml5-command=createLink]').click(function() {
363
- var activeButton = $(this).hasClass("wysihtml5-command-active");
364
-
365
- if (!activeButton) {
366
- insertLinkModal.append('body').modal('show');
367
- insertLinkModal.on('click.dismiss.modal', '[data-dismiss="modal"]', function(e) {
368
- e.stopPropagation();
369
- });
370
- return false;
371
- }
372
- else {
373
- return true;
374
- }
310
+ var activeButton = $(this).hasClass("wysihtml5-command-active");
311
+
312
+ if (!activeButton) {
313
+ insertLinkModal.append('body').modal('show');
314
+ insertLinkModal.on('click.dismiss.modal', '[data-dismiss="modal"]', function(e) {
315
+ e.stopPropagation();
316
+ });
317
+ return false;
318
+ }
319
+ else {
320
+ return true;
321
+ }
375
322
  });
376
323
  }
377
324
  };
378
325
 
379
- $.fn.wysihtml5 = function (options) {
380
- return this.each(function () {
381
- var $this = $(this);
382
- $this.data('wysihtml5', new Wysihtml5($this, options));
383
- });
326
+ // these define our public api
327
+ var methods = {
328
+ resetDefaults: function() {
329
+ $.fn.wysihtml5.defaultOptions = $.extend(true, {}, $.fn.wysihtml5.defaultOptionsCache);
330
+ },
331
+ bypassDefaults: function(options) {
332
+ return this.each(function () {
333
+ var $this = $(this);
334
+ $this.data('wysihtml5', new Wysihtml5($this, options));
335
+ });
336
+ },
337
+ shallowExtend: function (options) {
338
+ var settings = $.extend({}, $.fn.wysihtml5.defaultOptions, options || {});
339
+ var that = this;
340
+ return methods.bypassDefaults.apply(that, [settings]);
341
+ },
342
+ deepExtend: function(options) {
343
+ var settings = $.extend(true, {}, $.fn.wysihtml5.defaultOptions, options || {});
344
+ var that = this;
345
+ return methods.bypassDefaults.apply(that, [settings]);
346
+ },
347
+ init: function(options) {
348
+ var that = this;
349
+ return methods.shallowExtend.apply(that, [options]);
350
+ }
351
+ };
352
+
353
+ $.fn.wysihtml5 = function ( method ) {
354
+ if ( methods[method] ) {
355
+ return methods[method].apply( this, Array.prototype.slice.call( arguments, 1 ));
356
+ } else if ( typeof method === 'object' || ! method ) {
357
+ return methods.init.apply( this, arguments );
358
+ } else {
359
+ $.error( 'Method ' + method + ' does not exist on jQuery.wysihtml5' );
360
+ }
384
361
  };
385
362
 
386
363
  $.fn.wysihtml5.Constructor = Wysihtml5;
387
364
 
365
+ var defaultOptions = $.fn.wysihtml5.defaultOptions = {
366
+ "font-styles": true,
367
+ "color": false,
368
+ "emphasis": true,
369
+ "lists": true,
370
+ "html": false,
371
+ "link": true,
372
+ "image": true,
373
+ "imageUpload": false,
374
+ imageUploadCallback: undefined,
375
+ events: {},
376
+ parserRules: {
377
+ classes: {
378
+ // (path_to_project/lib/css/wysiwyg-color.css)
379
+ "wysiwyg-color-silver" : 1,
380
+ "wysiwyg-color-gray" : 1,
381
+ "wysiwyg-color-white" : 1,
382
+ "wysiwyg-color-maroon" : 1,
383
+ "wysiwyg-color-red" : 1,
384
+ "wysiwyg-color-purple" : 1,
385
+ "wysiwyg-color-fuchsia" : 1,
386
+ "wysiwyg-color-green" : 1,
387
+ "wysiwyg-color-lime" : 1,
388
+ "wysiwyg-color-olive" : 1,
389
+ "wysiwyg-color-yellow" : 1,
390
+ "wysiwyg-color-navy" : 1,
391
+ "wysiwyg-color-blue" : 1,
392
+ "wysiwyg-color-teal" : 1,
393
+ "wysiwyg-color-aqua" : 1,
394
+ "wysiwyg-color-orange" : 1,
395
+ "wysiwyg-float-left": 1,
396
+ "wysiwyg-float-right": 1
397
+ },
398
+ tags: {
399
+ "b": {},
400
+ "i": {},
401
+ "br": {},
402
+ "ol": {},
403
+ "ul": {},
404
+ "li": {},
405
+ "h1": {},
406
+ "h2": {},
407
+ "h3": {},
408
+ "blockquote": {},
409
+ "small": {},
410
+ "p": {},
411
+ "cite": {
412
+ "check_attributes": {
413
+ "title": "alt"
414
+ }
415
+ },
416
+ "u": 1,
417
+ "img": {
418
+ "check_attributes": {
419
+ "width": "numbers",
420
+ "alt": "alt",
421
+ "src": "src",
422
+ "height": "numbers"
423
+ },
424
+ "add_class": {
425
+ "align": "align_img"
426
+ }
427
+ },
428
+ "a": {
429
+ set_attributes: {
430
+ target: "_blank",
431
+ rel: "nofollow"
432
+ },
433
+ check_attributes: {
434
+ href: "url" // important to avoid XSS
435
+ }
436
+ },
437
+ "span": 1,
438
+ "div": 1
439
+ }
440
+ },
441
+ stylesheets: ["./lib/css/wysiwyg-color.css"], // (path_to_project/lib/css/wysiwyg-color.css)
442
+ locale: "en"
443
+ };
444
+
445
+ if (typeof $.fn.wysihtml5.defaultOptionsCache === 'undefined') {
446
+ $.fn.wysihtml5.defaultOptionsCache = $.extend(true, {}, $.fn.wysihtml5.defaultOptions);
447
+ }
448
+
388
449
  var locale = $.fn.wysihtml5.locale = {
389
450
  en: {
390
451
  font_styles: {
@@ -432,3 +493,4 @@
432
493
  };
433
494
 
434
495
  }(window.jQuery, window.wysihtml5);
496
+
@@ -50,7 +50,9 @@ window.Bootsy = (function(){
50
50
  Bootsy.ready = function(){
51
51
  if($('textarea.bootsy_text_area').length > 0){
52
52
 
53
- Bootsy.editorOptions = {color: true, locale: "<%= I18n.default_locale %>"};
53
+ Bootsy.editorOptions = {color: true, locale: "<%= I18n.locale %>"};
54
+
55
+ Bootsy.editorOptions.stylesheets = ["/assets/bootsy/bootsy.css"];
54
56
 
55
57
  if($('textarea.bootsy_text_area').attr('data-enable-image') == 'false'){
56
58
  Bootsy.editorOptions.image = false;
@@ -74,4 +74,59 @@
74
74
 
75
75
  form.bootsy .field_with_errors {
76
76
  display: inline-block;
77
+ }
78
+
79
+ blockquote {
80
+ padding: 0 0 0 15px;
81
+ margin: 0 0 20px;
82
+ border-left: 5px solid #eeeeee;
83
+ }
84
+
85
+ blockquote p {
86
+ margin-bottom: 0;
87
+ /*font-size: 16px;
88
+ font-weight: 300;
89
+ line-height: 25px;*/
90
+ }
91
+
92
+ blockquote small {
93
+ display: block;
94
+ line-height: 20px;
95
+ color: #999999;
96
+ }
97
+
98
+ blockquote small:before {
99
+ content: '\2014 \00A0';
100
+ }
101
+
102
+ blockquote.pull-right {
103
+ float: right;
104
+ padding-right: 15px;
105
+ padding-left: 0;
106
+ border-right: 5px solid #eeeeee;
107
+ border-left: 0;
108
+ }
109
+
110
+ blockquote.pull-right p,
111
+ blockquote.pull-right small {
112
+ text-align: right;
113
+ }
114
+
115
+ blockquote.pull-right small:before {
116
+ content: '';
117
+ }
118
+
119
+ blockquote.pull-right small:after {
120
+ content: '\00A0 \2014';
121
+ }
122
+
123
+ q:before,
124
+ q:after,
125
+ blockquote:before,
126
+ blockquote:after {
127
+ content: "";
128
+ }
129
+
130
+ textarea.bootsy:required:invalid {
131
+ color: inherit;
77
132
  }
@@ -1,3 +1,3 @@
1
1
  module Bootsy
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
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.5
4
+ version: 0.1.6
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-23 00:00:00.000000000 Z
12
+ date: 2012-10-03 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.js.erb
167
166
  - app/views/bootsy/images/_index.html.erb
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
167
  - app/views/bootsy/images/_new.html.erb
168
+ - app/views/bootsy/images/index.js.erb
169
+ - app/views/bootsy/images/_modal.html.erb
170
+ - app/views/bootsy/images/create.js.erb
171
+ - app/views/bootsy/images/destroy.js.erb
172
172
  - app/controllers/bootsy/application_controller.rb
173
173
  - app/controllers/bootsy/images_controller.rb
174
- - app/helpers/bootsy/application_helper.rb
175
174
  - app/assets/javascripts/bootsy.js
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
175
  - app/assets/javascripts/bootsy/bootsy.js.erb
176
+ - app/assets/javascripts/bootsy/bootstrap-wysihtml5.js
177
+ - app/assets/javascripts/bootsy/wysihtml5.js
178
+ - app/assets/javascripts/bootsy/locales/bootstrap-wysihtml5.pt-BR.js
180
179
  - app/assets/stylesheets/bootsy.css
181
180
  - app/assets/stylesheets/bootsy/bootstrap-wysihtml5.css
182
181
  - app/assets/stylesheets/bootsy/bootsy.css
183
- - config/locales/en.yml
184
- - config/locales/pt-BR.yml
185
- - config/routes.rb
186
- - config/bootsy.yml
182
+ - app/helpers/bootsy/application_helper.rb
187
183
  - config/cucumber.yml
188
- - db/migrate/20120624171333_create_bootsy_images.rb
184
+ - config/bootsy.yml
185
+ - config/routes.rb
186
+ - config/locales/pt-BR.yml
187
+ - config/locales/en.yml
189
188
  - db/migrate/20120628124845_create_bootsy_image_galleries.rb
189
+ - db/migrate/20120624171333_create_bootsy_images.rb
190
+ - lib/tasks/bootsy_tasks.rake
191
+ - lib/tasks/cucumber.rake
192
+ - lib/generators/bootsy/USAGE
190
193
  - lib/generators/bootsy/install_generator.rb
191
194
  - lib/generators/bootsy/templates/bootsy.rb
192
- - lib/generators/bootsy/USAGE
193
195
  - lib/bootsy.rb
194
- - lib/tasks/bootsy_tasks.rake
195
- - lib/tasks/cucumber.rake
196
- - lib/bootsy/form_helper.rb
197
- - lib/bootsy/version.rb
196
+ - lib/bootsy/core_ext.rb
198
197
  - lib/bootsy/activerecord/image_gallery.rb
199
198
  - lib/bootsy/activerecord/image.rb
200
- - lib/bootsy/core_ext.rb
199
+ - lib/bootsy/form_helper.rb
200
+ - lib/bootsy/version.rb
201
201
  - lib/bootsy/container.rb
202
- - lib/bootsy/form_builder.rb
203
202
  - lib/bootsy/engine.rb
203
+ - lib/bootsy/form_builder.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: -500388282163322188
221
+ hash: -234283299
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: -500388282163322188
230
+ hash: -234283299
231
231
  requirements: []
232
232
  rubyforge_project:
233
233
  rubygems_version: 1.8.24