bootsy 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -106,12 +106,12 @@ You can set the image sizes available (small, medium, large and/or its original)
106
106
 
107
107
  ## I18n
108
108
 
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).
109
+ Bootsy defines some i18n keys. The ruby english translation is automatically added to your `config/locales` directory as `bootsy.en.yml`. You can follow that template in order to translate Bootsy to 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). If you are using the alert for unsaved changes, you have to define a translation for it as well. Just follow [this example](https://github.com/volmer/bootsy/tree/master/app/assets/bootsy/locales/bootsy.pt-BR.js).
110
110
 
111
111
 
112
112
  ## Mongoid support
113
113
 
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.
114
+ By default, Bootsy only supports ActiveRecord. In order to use Bootsy with Mongoid, please use [Bootsy-Mongoid](https://github.com/volmer/bootsy-mongoid) instead.
115
115
 
116
116
 
117
117
  ## Bootsy with SimpleForm
@@ -1,116 +1,129 @@
1
1
  !function($, wysi) {
2
2
  "use strict";
3
3
 
4
- var templates = function(key, locale) {
5
-
6
- var tpl = {
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
-
80
- "html":
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>"
106
- };
107
- return tpl[key];
4
+ var tpl = {
5
+ "font-styles": function(locale, options) {
6
+ var size = (options && options.size) ? ' btn-'+options.size : '';
7
+ return "<li class='dropdown'>" +
8
+ "<a class='btn dropdown-toggle" + size + "' 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' tabindex='-1'>" + locale.font_styles.normal + "</a></li>" +
13
+ "<li><a data-wysihtml5-command='formatBlock' data-wysihtml5-command-value='h1' tabindex='-1'>" + locale.font_styles.h1 + "</a></li>" +
14
+ "<li><a data-wysihtml5-command='formatBlock' data-wysihtml5-command-value='h2' tabindex='-1'>" + locale.font_styles.h2 + "</a></li>" +
15
+ "<li><a data-wysihtml5-command='formatBlock' data-wysihtml5-command-value='h3' tabindex='-1'>" + locale.font_styles.h3 + "</a></li>" +
16
+ "</ul>" +
17
+ "</li>";
18
+ },
19
+
20
+ "emphasis": function(locale, options) {
21
+ var size = (options && options.size) ? ' btn-'+options.size : '';
22
+ return "<li>" +
23
+ "<div class='btn-group'>" +
24
+ "<a class='btn" + size + "' data-wysihtml5-command='bold' title='CTRL+B' tabindex='-1'>" + locale.emphasis.bold + "</a>" +
25
+ "<a class='btn" + size + "' data-wysihtml5-command='italic' title='CTRL+I' tabindex='-1'>" + locale.emphasis.italic + "</a>" +
26
+ "<a class='btn" + size + "' data-wysihtml5-command='underline' title='CTRL+U' tabindex='-1'>" + locale.emphasis.underline + "</a>" +
27
+ "</div>" +
28
+ "</li>";
29
+ },
30
+
31
+ "lists": function(locale, options) {
32
+ var size = (options && options.size) ? ' btn-'+options.size : '';
33
+ return "<li>" +
34
+ "<div class='btn-group'>" +
35
+ "<a class='btn" + size + "' data-wysihtml5-command='insertUnorderedList' title='" + locale.lists.unordered + "' tabindex='-1'><i class='icon-list'></i></a>" +
36
+ "<a class='btn" + size + "' data-wysihtml5-command='insertOrderedList' title='" + locale.lists.ordered + "' tabindex='-1'><i class='icon-th-list'></i></a>" +
37
+ "<a class='btn" + size + "' data-wysihtml5-command='Outdent' title='" + locale.lists.outdent + "' tabindex='-1'><i class='icon-indent-right'></i></a>" +
38
+ "<a class='btn" + size + "' data-wysihtml5-command='Indent' title='" + locale.lists.indent + "' tabindex='-1'><i class='icon-indent-left'></i></a>" +
39
+ "</div>" +
40
+ "</li>";
41
+ },
42
+
43
+ "link": function(locale, options) {
44
+ var size = (options && options.size) ? ' btn-'+options.size : '';
45
+ return "<li>" +
46
+ "<div class='bootstrap-wysihtml5-insert-link-modal modal hide fade'>" +
47
+ "<div class='modal-header'>" +
48
+ "<a class='close' data-dismiss='modal'>&times;</a>" +
49
+ "<h3>" + locale.link.insert + "</h3>" +
50
+ "</div>" +
51
+ "<div class='modal-body'>" +
52
+ "<input value='http://' class='bootstrap-wysihtml5-insert-link-url input-xlarge'>" +
53
+ "</div>" +
54
+ "<div class='modal-footer'>" +
55
+ "<a href='#' class='btn' data-dismiss='modal'>" + locale.link.cancel + "</a>" +
56
+ "<a href='#' class='btn btn-primary' data-dismiss='modal'>" + locale.link.insert + "</a>" +
57
+ "</div>" +
58
+ "</div>" +
59
+ "<a class='btn" + size + "' data-wysihtml5-command='createLink' title='" + locale.link.insert + "' tabindex='-1'><i class='icon-share'></i></a>" +
60
+ "</li>";
61
+ },
62
+
63
+ "image": function(locale, options) {
64
+ var size = (options && options.size) ? ' btn-'+options.size : '';
65
+ return "<li>" +
66
+ "<div class='bootstrap-wysihtml5-insert-image-modal modal hide fade'>" +
67
+ "<div class='modal-header'>" +
68
+ "<a class='close' data-dismiss='modal'>&times;</a>" +
69
+ "<h3>" + locale.image.insert + "</h3>" +
70
+ "</div>" +
71
+ "<div class='modal-body'>" +
72
+ "<input value='http://' class='bootstrap-wysihtml5-insert-image-url input-xlarge'>" +
73
+ "</div>" +
74
+ "<div class='modal-footer'>" +
75
+ "<a href='#' class='btn' data-dismiss='modal'>" + locale.image.cancel + "</a>" +
76
+ "<a href='#' class='btn btn-primary' data-dismiss='modal'>" + locale.image.insert + "</a>" +
77
+ "</div>" +
78
+ "</div>" +
79
+ "<a class='btn" + size + "' data-wysihtml5-command='insertImage' title='" + locale.image.insert + "' tabindex='-1'><i class='icon-picture'></i></a>" +
80
+ "</li>";
81
+ },
82
+
83
+ "html": function(locale, options) {
84
+ var size = (options && options.size) ? ' btn-'+options.size : '';
85
+ return "<li>" +
86
+ "<div class='btn-group'>" +
87
+ "<a class='btn" + size + "' data-wysihtml5-action='change_view' title='" + locale.html.edit + "' tabindex='-1'><i class='icon-pencil'></i></a>" +
88
+ "</div>" +
89
+ "</li>";
90
+ },
91
+
92
+ "color": function(locale, options) {
93
+ var size = (options && options.size) ? ' btn-'+options.size : '';
94
+ return "<li class='dropdown'>" +
95
+ "<a class='btn dropdown-toggle" + size + "' data-toggle='dropdown' href='#' tabindex='-1'>" +
96
+ "<span class='current-color'>" + locale.colours.black + "</span>&nbsp;<b class='caret'></b>" +
97
+ "</a>" +
98
+ "<ul class='dropdown-menu'>" +
99
+ "<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>" +
100
+ "<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>" +
101
+ "<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>" +
102
+ "<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>" +
103
+ "<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>" +
104
+ "<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>" +
105
+ "<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>" +
106
+ "<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>" +
107
+ "<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>" +
108
+ "<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>" +
109
+ "<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>" +
110
+ "</ul>" +
111
+ "</li>";
112
+ }
113
+ };
114
+
115
+ var templates = function(key, locale, options) {
116
+ return tpl[key](locale, options);
108
117
  };
109
118
 
110
119
 
111
120
  var Wysihtml5 = function(el, options) {
112
121
  this.el = el;
113
- this.toolbar = this.createToolbar(el, options || defaultOptions);
122
+ var toolbarOpts = options || defaultOptions;
123
+ for(var t in toolbarOpts.customTemplates) {
124
+ tpl[t] = toolbarOpts.customTemplates[t];
125
+ }
126
+ this.toolbar = this.createToolbar(el, toolbarOpts);
114
127
  this.editor = this.createEditor(options);
115
128
 
116
129
  window.editor = this.editor;
@@ -161,7 +174,7 @@
161
174
  }
162
175
 
163
176
  if(value === true) {
164
- toolbar.append(templates(key, locale[culture]));
177
+ toolbar.append(templates(key, locale[culture], options));
165
178
 
166
179
  if(key === "html") {
167
180
  this.initHtml(toolbar);
@@ -175,8 +188,8 @@
175
188
  this.initInsertImage(toolbar);
176
189
  }
177
190
 
178
- if(key == "imageUpload") {
179
- this.initInsertUploadedImage(toolbar, options.imageUploadCallback);
191
+ if(key == "customCommand") {
192
+ this.initCustomCommand(toolbar, options.customCommandCallback);
180
193
  }
181
194
  }
182
195
  }
@@ -217,10 +230,16 @@
217
230
  var urlInput = insertImageModal.find('.bootstrap-wysihtml5-insert-image-url');
218
231
  var insertButton = insertImageModal.find('a.btn-primary');
219
232
  var initialValue = urlInput.val();
233
+ var caretBookmark;
220
234
 
221
235
  var insertImage = function() {
222
236
  var url = urlInput.val();
223
237
  urlInput.val(initialValue);
238
+ self.editor.currentView.element.focus();
239
+ if (caretBookmark) {
240
+ self.editor.composer.selection.setBookmark(caretBookmark);
241
+ caretBookmark = null;
242
+ }
224
243
  self.editor.composer.commands.exec("insertImage", url);
225
244
  };
226
245
 
@@ -245,6 +264,8 @@
245
264
  var activeButton = $(this).hasClass("wysihtml5-command-active");
246
265
 
247
266
  if (!activeButton) {
267
+ self.editor.currentView.element.focus(false);
268
+ caretBookmark = self.editor.composer.selection.getBookmark();
248
269
  insertImageModal.modal('show');
249
270
  insertImageModal.on('click.dismiss.modal', '[data-dismiss="modal"]', function(e) {
250
271
  e.stopPropagation();
@@ -257,12 +278,14 @@
257
278
  });
258
279
  },
259
280
 
260
- initInsertUploadedImage: function(toolbar, callback) {
261
- toolbar.find('a[data-wysihtml5-command=insertUploadedImage]').click(function() {
281
+ initCustomCommand: function(toolbar, callback) {
282
+ var self = this;
283
+
284
+ toolbar.find('a[data-wysihtml5-command=customCommand]').click(function() {
262
285
  var activeButton = $(this).hasClass("wysihtml5-command-active");
263
286
 
264
287
  if (!activeButton) {
265
- callback(this.editor);
288
+ callback(self.editor);
266
289
  return false;
267
290
  }
268
291
  else {
@@ -277,10 +300,16 @@
277
300
  var urlInput = insertLinkModal.find('.bootstrap-wysihtml5-insert-link-url');
278
301
  var insertButton = insertLinkModal.find('a.btn-primary');
279
302
  var initialValue = urlInput.val();
303
+ var caretBookmark;
280
304
 
281
305
  var insertLink = function() {
282
306
  var url = urlInput.val();
283
307
  urlInput.val(initialValue);
308
+ self.editor.currentView.element.focus();
309
+ if (caretBookmark) {
310
+ self.editor.composer.selection.setBookmark(caretBookmark);
311
+ caretBookmark = null;
312
+ }
284
313
  self.editor.composer.commands.exec("createLink", {
285
314
  href: url,
286
315
  target: "_blank",
@@ -310,7 +339,9 @@
310
339
  var activeButton = $(this).hasClass("wysihtml5-command-active");
311
340
 
312
341
  if (!activeButton) {
313
- insertLinkModal.append('body').modal('show');
342
+ self.editor.currentView.element.focus(false);
343
+ caretBookmark = self.editor.composer.selection.getBookmark();
344
+ insertLinkModal.appendTo('body').modal('show');
314
345
  insertLinkModal.on('click.dismiss.modal', '[data-dismiss="modal"]', function(e) {
315
346
  e.stopPropagation();
316
347
  });
@@ -370,8 +401,7 @@
370
401
  "html": false,
371
402
  "link": true,
372
403
  "image": true,
373
- "imageUpload": false,
374
- imageUploadCallback: undefined,
404
+ customCommand: false,
375
405
  events: {},
376
406
  parserRules: {
377
407
  classes: {
@@ -391,9 +421,7 @@
391
421
  "wysiwyg-color-blue" : 1,
392
422
  "wysiwyg-color-teal" : 1,
393
423
  "wysiwyg-color-aqua" : 1,
394
- "wysiwyg-color-orange" : 1,
395
- "wysiwyg-float-left": 1,
396
- "wysiwyg-float-right": 1
424
+ "wysiwyg-color-orange" : 1
397
425
  },
398
426
  tags: {
399
427
  "b": {},
@@ -406,23 +434,13 @@
406
434
  "h2": {},
407
435
  "h3": {},
408
436
  "blockquote": {},
409
- "small": {},
410
- "p": {},
411
- "cite": {
412
- "check_attributes": {
413
- "title": "alt"
414
- }
415
- },
416
437
  "u": 1,
417
438
  "img": {
418
439
  "check_attributes": {
419
440
  "width": "numbers",
420
441
  "alt": "alt",
421
- "src": "src",
442
+ "src": "url",
422
443
  "height": "numbers"
423
- },
424
- "add_class": {
425
- "align": "align_img"
426
444
  }
427
445
  },
428
446
  "a": {
@@ -493,4 +511,3 @@
493
511
  };
494
512
 
495
513
  }(window.jQuery, window.wysihtml5);
496
-
@@ -1,8 +1,12 @@
1
- <%# encoding: UTF-8 %>
2
-
3
1
  window.Bootsy = (function(){
4
2
 
5
- var Bootsy = {unsavedChanges: false, editor: false, editorOptions: {}, eventCallbacks: {'loaded': []}, triggeredEvents: []};
3
+ var Bootsy = {caretBookmark: false, unsavedChanges: false, editor: false, editorOptions: {}, eventCallbacks: {'loaded': []}, triggeredEvents: []};
4
+
5
+ Bootsy.translations = {
6
+ en: {
7
+ alert_unsaved: 'You have unsaved changes.'
8
+ }
9
+ };
6
10
 
7
11
  Bootsy.on = function(eventName, callback){
8
12
  Bootsy.eventCallbacks[eventName].push(callback);
@@ -33,41 +37,86 @@ window.Bootsy = (function(){
33
37
  };
34
38
 
35
39
  Bootsy.openImageGallery = function(editor){
40
+ editor.currentView.element.focus(false);
41
+ Bootsy.caretBookmark = editor.composer.selection.getBookmark();
36
42
  $('#bootsy_image_gallery').modal('show');
37
43
  };
38
44
 
39
45
  Bootsy.insertImage = function(image, editor){
40
46
  $('#bootsy_image_gallery').modal('hide');
47
+ editor.currentView.element.focus();
48
+ if (Bootsy.caretBookmark) {
49
+ editor.composer.selection.setBookmark(Bootsy.caretBookmark);
50
+ Bootsy.caretBookmark = null;
51
+ }
41
52
  editor.composer.commands.exec("insertImage", image);
42
53
  }
43
54
 
44
55
  Bootsy.alertUnsavedChanges = function(){
45
56
  if(Bootsy.unsavedChanges){
46
- return "<%= I18n.t 'bootsy.js.alert_unsaved' %>";
57
+ return Bootsy.translations[Bootsy.locale].alert_unsaved;
47
58
  }
48
59
  };
49
60
 
50
61
  Bootsy.ready = function(){
51
62
  if($('textarea.bootsy_text_area').length > 0){
52
-
53
- Bootsy.editorOptions = {color: true, locale: "<%= I18n.locale %>"};
63
+ Bootsy.locale = $('textarea.bootsy_text_area').attr('data-locale');
64
+
65
+ var templates = {
66
+ customCommand: function(locale, options) {
67
+ var size = (options && options.size) ? ' btn-'+options.size : '';
68
+ return "<li>" +
69
+ "<a class='btn" + size + "' data-wysihtml5-command='customCommand' title='" + locale.image.insert + "' tabindex='-1'><i class='icon-picture'></i></a>" +
70
+ "</li>";
71
+ },
72
+ };
73
+
74
+ Bootsy.editorOptions = {
75
+ parserRules: {
76
+ classes: {
77
+ "wysiwyg-float-left": 1,
78
+ "wysiwyg-float-right": 1
79
+ },
80
+
81
+ tags: {
82
+ "small": {},
83
+ "p": {},
84
+ "cite": {
85
+ "check_attributes": {
86
+ "title": "alt"
87
+ }
88
+ },
89
+ "img": {
90
+ "check_attributes": {
91
+ "src": "src"
92
+ },
93
+ "add_class": {
94
+ "align": "align_img"
95
+ }
96
+ },
97
+ }
98
+ },
99
+ color: true,
100
+ locale: Bootsy.locale,
101
+ customTemplates: templates
102
+ };
54
103
 
55
104
  Bootsy.editorOptions.stylesheets = ["/assets/bootsy/bootsy.css"];
56
105
 
57
- if($('textarea.bootsy_text_area').attr('data-enable-image') == 'false'){
106
+ if($('textarea.bootsy_text_area').attr('data-image') == 'false'){
58
107
  Bootsy.editorOptions.image = false;
59
108
  }else{
60
109
 
61
- if($('textarea.bootsy_text_area').attr('data-enable-uploader') != 'false'){
110
+ if($('textarea.bootsy_text_area').attr('data-uploader') != 'false'){
62
111
  Bootsy.editorOptions.image = false;
63
- Bootsy.editorOptions.imageUpload = true;
64
- Bootsy.editorOptions.imageUploadCallback = Bootsy.openImageGallery;
112
+ Bootsy.editorOptions.customCommand = true;
113
+ Bootsy.editorOptions.customCommandCallback = Bootsy.openImageGallery;
65
114
 
66
115
  element = $('#bootsy_image_gallery');
67
116
 
68
117
  element.parents('form').after(element);
69
118
 
70
- element.find('a.refresh_btn').live('click', function(e){
119
+ element.on('click', 'a.refresh_btn', function(e){
71
120
  $(this).hide();
72
121
  Bootsy.progressBar(element);
73
122
  });
@@ -76,11 +125,6 @@ window.Bootsy = (function(){
76
125
  Bootsy.progressBar(element);
77
126
  });
78
127
 
79
- // element.find('#new_image').live('ajax:before', function(e){
80
- // console.log('sending...')
81
- // Bootsy.progressBar(element);
82
- // });
83
-
84
128
  element.modal({show: false});
85
129
  element.on('shown', function(){
86
130
  Bootsy.refreshGallery(element);
@@ -94,7 +138,7 @@ window.Bootsy = (function(){
94
138
  e.stopPropagation();
95
139
  });
96
140
 
97
- element.find('ul.dropdown-menu a.insert').live('click', function(e){
141
+ element.on('click', 'ul.dropdown-menu a.insert', function(e){
98
142
  var imagePrefix = "/"+$(this).attr('data-image-size')+"_";
99
143
  if($(this).attr('data-image-size') == 'original'){
100
144
  imagePrefix = '/';
@@ -112,12 +156,12 @@ window.Bootsy = (function(){
112
156
  }
113
157
  }
114
158
 
115
- if($('textarea.bootsy_text_area').attr('data-enable-font-styles') == 'false') Bootsy.editorOptions['font-styles'] = false;
116
- if($('textarea.bootsy_text_area').attr('data-enable-emphasis') == 'false') Bootsy.editorOptions.emphasis = false;
117
- if($('textarea.bootsy_text_area').attr('data-enable-lists') == 'false') Bootsy.editorOptions.lists = false;
118
- if($('textarea.bootsy_text_area').attr('data-enable-html') == 'true') Bootsy.editorOptions.html = true;
119
- if($('textarea.bootsy_text_area').attr('data-enable-link') == 'false') Bootsy.editorOptions.link = false;
120
- if($('textarea.bootsy_text_area').attr('data-enable-color') == 'false') Bootsy.editorOptions.color = false;
159
+ if($('textarea.bootsy_text_area').attr('data-font-styles') == 'false') Bootsy.editorOptions['font-styles'] = false;
160
+ if($('textarea.bootsy_text_area').attr('data-emphasis') == 'false') Bootsy.editorOptions.emphasis = false;
161
+ if($('textarea.bootsy_text_area').attr('data-lists') == 'false') Bootsy.editorOptions.lists = false;
162
+ if($('textarea.bootsy_text_area').attr('data-html') == 'true') Bootsy.editorOptions.html = true;
163
+ if($('textarea.bootsy_text_area').attr('data-link') == 'false') Bootsy.editorOptions.link = false;
164
+ if($('textarea.bootsy_text_area').attr('data-color') == 'false') Bootsy.editorOptions.color = false;
121
165
 
122
166
  Bootsy.editor = $('textarea.bootsy_text_area').wysihtml5(Bootsy.editorOptions).data("wysihtml5").editor;
123
167
 
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Brazilian portuguese translation for Bootsy
3
+ */
4
+ jQuery(function(){
5
+ Bootsy.translations['pt-BR'] = {
6
+ alert_unsaved: 'As suas modificações ainda não foram gravadas.'
7
+ };
8
+ });
@@ -99,4 +99,4 @@ ul.wysihtml5-toolbar div[data-wysihtml5-command-value="blue"] {
99
99
 
100
100
  ul.wysihtml5-toolbar div[data-wysihtml5-command-value="orange"] {
101
101
  background: orange !important;
102
- }
102
+ }
@@ -1,7 +1,7 @@
1
1
  module Bootsy
2
2
  module ApplicationHelper
3
3
  def refresh_btn gallery, collection
4
- link_to t('bootsy.refresh'), [bootsy, resource_or_nil(gallery), collection], remote: true, :class => 'btn btn-mini refresh_btn'
4
+ link_to t('bootsy.action.refresh'), [bootsy, resource_or_nil(gallery), collection], remote: true, :class => 'btn btn-mini refresh_btn'
5
5
  end
6
6
 
7
7
  def resource_or_nil resource
@@ -20,6 +20,4 @@ en:
20
20
  position:
21
21
  left: Left
22
22
  right: Right
23
- inline: Inline
24
- js:
25
- alert_unsaved: You have unsaved changes.
23
+ inline: Inline
@@ -20,6 +20,4 @@ pt-BR:
20
20
  position:
21
21
  left: Esquerda
22
22
  right: Direita
23
- inline: Mesma linha
24
- js:
25
- alert_unsaved: As suas modificações ainda não foram gravadas.
23
+ inline: Mesma linha
@@ -1,43 +1,27 @@
1
1
  module Bootsy
2
2
  module FormHelper
3
3
  def bootsy_area object, method, options = {}
4
-
5
4
  foreign_container = options.delete :container
6
- enable_uploader = true
7
5
 
8
- unless foreign_container.kind_of?(Container) || (foreign_container.nil? && object.kind_of?(Container))
9
- enable_uploader = false
10
- end
6
+ data = options.delete(:editor_options) || {}
7
+ data[:locale] = I18n.locale
11
8
 
12
- editor_options = options.delete :editor_options
13
-
14
- unless editor_options.nil?
15
- enable_uploader = false if editor_options[:uploader] == false
16
- options[:'data-alert-unsaved'] = 'false' if editor_options[:alert_unsaved] == false
17
- options[:'data-enable-font-styles'] = 'false' if editor_options[:font_styles] == false
18
- options[:'data-enable-emphasis'] = 'false' if editor_options[:emphasis] == false
19
- options[:'data-enable-lists'] = 'false' if editor_options[:lists] == false
20
- options[:'data-enable-html'] = 'true' if editor_options[:html] == true
21
- options[:'data-enable-link'] = 'false' if editor_options[:link] == false
22
- options[:'data-enable-image'] = 'false' if editor_options[:image] == false
23
- options[:'data-enable-color'] = 'false' if editor_options[:color] == false
24
- end
9
+ data[:uploader] = false unless foreign_container.kind_of?(Container) || (foreign_container.nil? && object.kind_of?(Container))
25
10
 
26
- options[:'data-enable-uploader'] = 'false' unless enable_uploader
11
+ enable_uploader = !(data[:uploader] == false)
12
+
13
+ options[:data] = options[:data] ? options[:data] + data : data
27
14
 
28
15
  object_name = object.class.name.underscore
29
16
 
30
- output = raw ''
31
-
32
- output = self.render 'bootsy/images/modal', {container: foreign_container || object} if enable_uploader
17
+ output = enable_uploader ? self.render('bootsy/images/modal', {container: foreign_container || object}) : raw('')
33
18
 
34
19
  options[:class] = (options[:class].nil? ? [] : (options[:class].kind_of?(Array) ? options[:class] : [options[:class]])) + [:bootsy_text_area]
20
+
35
21
  output += self.text_area object_name, method, options
36
22
 
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
23
+ if enable_uploader && (foreign_container.nil? || (foreign_container == object))
24
+ output += self.hidden_field object_name, :bootsy_image_gallery_id, :class => 'bootsy_image_gallery_id'
41
25
  end
42
26
 
43
27
  output
@@ -1,3 +1,3 @@
1
1
  module Bootsy
2
- VERSION = "0.1.7"
2
+ VERSION = "0.1.8"
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.7
4
+ version: 0.1.8
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-10-30 00:00:00.000000000 Z
12
+ date: 2013-02-10 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.7.0
37
+ version: 0.8.0
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.7.0
45
+ version: 0.8.0
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: remotipart
48
48
  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'
101
+ version: '2.12'
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'
109
+ version: '2.12'
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'
117
+ version: '4.2'
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'
125
+ version: '4.2'
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'
133
+ version: '0.9'
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'
141
+ version: '0.9'
142
142
  - !ruby/object:Gem::Dependency
143
143
  name: cucumber-rails
144
144
  requirement: !ruby/object:Gem::Requirement
@@ -163,44 +163,45 @@ 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/locales/bootsy.pt-BR.js
178
+ - app/assets/javascripts/bootsy/bootsy.js
179
+ - app/assets/javascripts/bootsy/wysihtml5.js
180
+ - app/assets/javascripts/bootsy/bootstrap-wysihtml5.js
179
181
  - app/assets/stylesheets/bootsy.css
180
182
  - app/assets/stylesheets/bootsy/bootstrap-wysihtml5.css
181
183
  - 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
184
  - config/locales/en.yml
188
- - db/migrate/20120628124845_create_bootsy_image_galleries.rb
185
+ - config/locales/pt-BR.yml
186
+ - config/routes.rb
187
+ - config/bootsy.yml
188
+ - config/cucumber.yml
189
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
+ - db/migrate/20120628124845_create_bootsy_image_galleries.rb
193
191
  - lib/generators/bootsy/install_generator.rb
194
192
  - lib/generators/bootsy/templates/bootsy.rb
193
+ - lib/generators/bootsy/USAGE
195
194
  - lib/bootsy.rb
196
- - lib/bootsy/core_ext.rb
197
- - lib/bootsy/activerecord/image_gallery.rb
198
- - lib/bootsy/activerecord/image.rb
195
+ - lib/tasks/bootsy_tasks.rake
196
+ - lib/tasks/cucumber.rake
199
197
  - lib/bootsy/form_helper.rb
200
198
  - lib/bootsy/version.rb
199
+ - lib/bootsy/activerecord/image_gallery.rb
200
+ - lib/bootsy/activerecord/image.rb
201
+ - lib/bootsy/core_ext.rb
201
202
  - lib/bootsy/container.rb
202
- - lib/bootsy/engine.rb
203
203
  - lib/bootsy/form_builder.rb
204
+ - lib/bootsy/engine.rb
204
205
  - MIT-LICENSE
205
206
  - Rakefile
206
207
  - README.md
@@ -218,7 +219,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
218
219
  version: '0'
219
220
  segments:
220
221
  - 0
221
- hash: 258846397
222
+ hash: 2775965369323801409
222
223
  required_rubygems_version: !ruby/object:Gem::Requirement
223
224
  none: false
224
225
  requirements:
@@ -227,7 +228,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
227
228
  version: '0'
228
229
  segments:
229
230
  - 0
230
- hash: 258846397
231
+ hash: 2775965369323801409
231
232
  requirements: []
232
233
  rubyforge_project:
233
234
  rubygems_version: 1.8.24