bootstrap-wysihtml5-rails 0.3.1.22 → 0.3.1.23

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fc11d8b9f16cd5487e7e0ef00f318b35b588ded9
4
- data.tar.gz: 58f93bf3869bbd9af8c6108d45704640a16ba4ef
3
+ metadata.gz: a630de9ab06c30ad1e99a6463d98be54e8fa080e
4
+ data.tar.gz: 4e12246cec1e36f44dcf5591452bb4c6656ec388
5
5
  SHA512:
6
- metadata.gz: 714fc1a765365161538a85d8630ef9209ad240b9879502571678c6e1c73764abfa2a522d7e44c62925ec51994675790dc1bee0dd18b6761a969ce5b27b457dae
7
- data.tar.gz: e312dbee6827dfde7b907d7be7416aee7be7946dcc0b05445ce7355453e76280b9c2247a7f88f0681332e08891b2e4cea15741fd8cc9c25f352f088d85fced0c
6
+ metadata.gz: 86bfcb021af75d8c112e4d870105485c061ffc869b8e352f101f4890eb408aae840eb8fbede9652b460f69c4b3929b90e15b0dec8a98735a7acf23468034128c
7
+ data.tar.gz: 293e8886add2d7479a9b3bc11a3e88d001c06d1f3a08ba56369fd1144c75d117b06ec7a9ac022f073f15d27e037771b6c0a600d5820aaba8894da0ea6f30a94c
data/README.md CHANGED
@@ -43,11 +43,16 @@ Bootstrap-wysihtml5 depends on jquery and bootstrap.
43
43
  app/assets/stylesheets/application.css
44
44
  ``` css
45
45
  *= require bootstrap-wysihtml5
46
+ // or
47
+ *= require bootstrap-wysihtml5/b3
46
48
  ```
47
49
 
48
50
  app/assets/javascripts/application.js
49
51
  ```javascript
50
52
  //= require bootstrap-wysihtml5
53
+ // or
54
+ //= require bootstrap-wysihtml5/b3
55
+
51
56
 
52
57
  You may include all locales like this:
53
58
 
@@ -69,9 +74,13 @@ Just call wysihtml5() with any selector.
69
74
  <textarea id="some-textarea" class='wysihtml5' placeholder="Enter text ..."></textarea>
70
75
 
71
76
  <script type="text/javascript">
72
- $('.wysihtml5').each(function(i, elem) {
73
- $(elem).wysihtml5();
74
- });
77
+ $(document).ready(function(){
78
+
79
+ $('.wysihtml5').each(function(i, elem) {
80
+ $(elem).wysihtml5();
81
+ });
82
+
83
+ })
75
84
  </script>
76
85
 
77
86
  ```
data/Rakefile CHANGED
@@ -1,39 +1,64 @@
1
1
  #!/usr/bin/env rake
2
2
  require File.expand_path('../lib/bootstrap-wysihtml5-rails/version', __FILE__)
3
3
 
4
+ ORIGIN_LIB_PATH = "bootstrap-wysihtml5/lib"
5
+ ORIGIN_SRC_PATH = "bootstrap-wysihtml5/src"
6
+ DEST_JAVASCRIPT_PATH = "vendor/assets/javascripts/bootstrap-wysihtml5"
7
+ DEST_CSS_PATH = "vendor/assets/stylesheets/bootstrap-wysihtml5"
8
+
9
+ def b2
10
+ system("cd bootstrap-wysihtml5 && git checkout master")
11
+
12
+ system("cp #{ORIGIN_SRC_PATH}/bootstrap-wysihtml5.css #{DEST_CSS_PATH}/core.css")
13
+
14
+ core_file = File.read("#{ORIGIN_SRC_PATH}/bootstrap-wysihtml5.js")
15
+ original_string = /stylesheets: \[".\/lib\/css\/wysiwyg-color.css"\]/
16
+ objective_string = "stylesheets: [\"<%= stylesheet_path('bootstrap-wysihtml5/wysiwyg-color.css') %>\"]"
17
+
18
+ replaced = core_file.gsub(original_string, objective_string)
19
+
20
+ File.open("#{DEST_JAVASCRIPT_PATH}/core.js.erb", "w") { |file| file.puts replaced }
21
+ end
22
+
23
+ def b3
24
+ system("cd bootstrap-wysihtml5 && git checkout tb3")
25
+
26
+ system("cp #{ORIGIN_SRC_PATH}/bootstrap-wysihtml5.css #{DEST_CSS_PATH}/core-b3.css")
27
+
28
+ core_file = File.read("#{ORIGIN_SRC_PATH}/bootstrap-wysihtml5.js")
29
+ original_string = /stylesheets: \[".\/lib\/css\/wysiwyg-color.css"\]/
30
+ objective_string = "stylesheets: [\"<%= stylesheet_path('bootstrap-wysihtml5/wysiwyg-color.css') %>\"]"
31
+
32
+ replaced = core_file.gsub(original_string, objective_string)
33
+
34
+ File.open("#{DEST_JAVASCRIPT_PATH}/core-b3.js.erb", "w") { |file| file.puts replaced }
35
+ end
36
+
37
+
38
+
4
39
  desc "Update assets"
5
40
  task 'update' do
6
- origin_lib_path = "bootstrap-wysihtml5/lib"
7
- origin_src_path = "bootstrap-wysihtml5/src"
8
- dest_javascript_path = "vendor/assets/javascripts/bootstrap-wysihtml5"
9
- dest_css_path = "vendor/assets/stylesheets/bootstrap-wysihtml5"
10
-
11
41
  if Dir.exist?('bootstrap-wysihtml5')
12
42
  system("cd bootstrap-wysihtml5 && git pull && cd ..")
13
43
  else
14
44
  system("git clone git://github.com/jhollingworth/bootstrap-wysihtml5.git bootstrap-wysihtml5")
45
+ system("cd bootstrap-wysihtml5 && git remote add b3 git@github.com:artillery/bootstrap-wysihtml5.git")
46
+ system("cd bootstrap-wysihtml5 && git fetch b3")
47
+ system("cd bootstrap-wysihtml5 && git checkout -b tb3 b3/master")
15
48
  end
16
49
 
17
- system("cp #{origin_src_path}/bootstrap-wysihtml5.css #{dest_css_path}/core.css")
18
-
19
50
  Dir.foreach("bootstrap-wysihtml5/src/locales") do |file|
20
51
  unless file == '.' || file == '..'
21
52
  abbreviated_file_name = file.gsub('bootstrap-wysihtml5.', '')
22
- system("cp #{origin_src_path}/locales/#{file} #{dest_javascript_path}/locales/#{abbreviated_file_name}")
53
+ system("cp #{ORIGIN_SRC_PATH}/locales/#{file} #{DEST_JAVASCRIPT_PATH}/locales/#{abbreviated_file_name}")
23
54
  end
24
55
  end
25
56
 
26
- core_file = File.read("#{origin_src_path}/bootstrap-wysihtml5.js")
27
- original_string = /stylesheets: \[".\/lib\/css\/wysiwyg-color.css"\]/
28
- objective_string = "stylesheets: [\"<%= stylesheet_path('bootstrap-wysihtml5/wysiwyg-color.css') %>\"]"
29
-
30
- replaced = core_file.gsub(original_string, objective_string)
31
-
32
- File.open("#{dest_javascript_path}/core.js.erb", "w") { |file| file.puts replaced }
33
-
34
- system("cp #{origin_lib_path}/js/wysihtml5-0.3.0.js #{dest_javascript_path}/wysihtml5.js")
35
- system("cp #{origin_lib_path}/css/wysiwyg-color.css #{dest_css_path}/wysiwyg-color.css")
57
+ system("cp #{ORIGIN_LIB_PATH}/js/wysihtml5-0.3.0.js #{DEST_JAVASCRIPT_PATH}/wysihtml5.js")
58
+ system("cp #{ORIGIN_LIB_PATH}/css/wysiwyg-color.css #{DEST_CSS_PATH}/wysiwyg-color.css")
36
59
 
60
+ b2
61
+ b3
37
62
 
38
63
  system("git status")
39
64
  end
@@ -1,5 +1,5 @@
1
1
  module BootstrapWysihtml5Rails
2
2
  module Rails
3
- VERSION = "0.3.1.22"
3
+ VERSION = "0.3.1.23"
4
4
  end
5
5
  end
@@ -0,0 +1,2 @@
1
+ //= require ./wysihtml5
2
+ //= require ./core-b3
@@ -0,0 +1,520 @@
1
+ !function($, wysi) {
2
+ "use strict";
3
+
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 btn-default btn" + size + " dropdown-toggle' data-toggle='dropdown' href='#'>" +
9
+ "<i class='glyphicon glyphicon-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
+ "<li><a data-wysihtml5-command='formatBlock' data-wysihtml5-command-value='h4'>" + locale.font_styles.h4 + "</a></li>" +
17
+ "<li><a data-wysihtml5-command='formatBlock' data-wysihtml5-command-value='h5'>" + locale.font_styles.h5 + "</a></li>" +
18
+ "<li><a data-wysihtml5-command='formatBlock' data-wysihtml5-command-value='h6'>" + locale.font_styles.h6 + "</a></li>" +
19
+ "</ul>" +
20
+ "</li>";
21
+ },
22
+
23
+ "emphasis": function(locale, options) {
24
+ var size = (options && options.size) ? ' btn-'+options.size : '';
25
+ return "<li>" +
26
+ "<div class='btn-group'>" +
27
+ "<a class='btn btn-default btn" + size + "' data-wysihtml5-command='bold' title='CTRL+B' tabindex='-1'>" + locale.emphasis.bold + "</a>" +
28
+ "<a class='btn btn-default btn" + size + "' data-wysihtml5-command='italic' title='CTRL+I' tabindex='-1'>" + locale.emphasis.italic + "</a>" +
29
+ "<a class='btn btn-default btn" + size + "' data-wysihtml5-command='underline' title='CTRL+U' tabindex='-1'>" + locale.emphasis.underline + "</a>" +
30
+ "</div>" +
31
+ "</li>";
32
+ },
33
+
34
+ "lists": function(locale, options) {
35
+ var size = (options && options.size) ? ' btn-'+options.size : '';
36
+ return "<li>" +
37
+ "<div class='btn-group'>" +
38
+ "<a class='btn btn-default btn" + size + "' data-wysihtml5-command='insertUnorderedList' title='" + locale.lists.unordered + "' tabindex='-1'><i class='glyphicon glyphicon-list'></i></a>" +
39
+ "<a class='btn btn-default btn" + size + "' data-wysihtml5-command='insertOrderedList' title='" + locale.lists.ordered + "' tabindex='-1'><i class='glyphicon glyphicon-th-list'></i></a>" +
40
+ "<a class='btn btn-default btn" + size + "' data-wysihtml5-command='Outdent' title='" + locale.lists.outdent + "' tabindex='-1'><i class='glyphicon glyphicon-indent-right'></i></a>" +
41
+ "<a class='btn btn-default btn" + size + "' data-wysihtml5-command='Indent' title='" + locale.lists.indent + "' tabindex='-1'><i class='glyphicon glyphicon-indent-left'></i></a>" +
42
+ "</div>" +
43
+ "</li>";
44
+ },
45
+
46
+ "link": function(locale, options) {
47
+ var size = (options && options.size) ? ' btn-'+options.size : '';
48
+ return "<li>" +
49
+ "<div class='bootstrap-wysihtml5-insert-link-modal modal fade'>" +
50
+ "<div class='modal-dialog'>" +
51
+ "<div class='modal-content'>" +
52
+ "<div class='modal-header'>" +
53
+ "<a class='close' data-dismiss='modal'>&times;</a>" +
54
+ "<h3 class='modal-title'>" + locale.link.insert + "</h3>" +
55
+ "</div>" +
56
+ "<div class='modal-body'>" +
57
+ "<input value='http://' class='bootstrap-wysihtml5-insert-link-url form-control'>" +
58
+ "<label class='checkbox'> <input type='checkbox' class='bootstrap-wysihtml5-insert-link-target' checked>" + locale.link.target + "</label>" +
59
+ "</div>" +
60
+ "<div class='modal-footer'>" +
61
+ "<a href='#' class='btn btn-default' data-dismiss='modal'>" + locale.link.cancel + "</a>" +
62
+ "<a href='#' class='btn btn-primary' data-dismiss='modal'>" + locale.link.insert + "</a>" +
63
+ "</div>" +
64
+ "</div>" +
65
+ "</div>" +
66
+ "</div>" +
67
+ "<a class='btn btn-default" + size + "' data-wysihtml5-command='createLink' title='" + locale.link.insert + "' tabindex='-1'><i class='glyphicon glyphicon-share'></i></a>" +
68
+ "</li>";
69
+ },
70
+
71
+ "image": function(locale, options) {
72
+ var size = (options && options.size) ? ' btn-'+options.size : '';
73
+ return "<li>" +
74
+ "<div class='bootstrap-wysihtml5-insert-image-modal modal fade'>" +
75
+ "<div class='modal-dialog'>" +
76
+ "<div class='modal-content'>" +
77
+ "<div class='modal-header'>" +
78
+ "<a class='close' data-dismiss='modal'>&times;</a>" +
79
+ "<h3 class='modal-title'>" + locale.image.insert + "</h3>" +
80
+ "</div>" +
81
+ "<div class='modal-body'>" +
82
+ "<input value='http://' class='bootstrap-wysihtml5-insert-image-url form-control'>" +
83
+ "</div>" +
84
+ "<div class='modal-footer'>" +
85
+ "<a href='#' class='btn btn-default' data-dismiss='modal'>" + locale.image.cancel + "</a>" +
86
+ "<a href='#' class='btn btn-primary' data-dismiss='modal'>" + locale.image.insert + "</a>" +
87
+ "</div>" +
88
+ "</div>" +
89
+ "</div>" +
90
+ "</div>" +
91
+ "<a class='btn btn-default btn" + size + "' data-wysihtml5-command='insertImage' title='" + locale.image.insert + "' tabindex='-1'><i class='glyphicon glyphicon-picture'></i></a>" +
92
+ "</li>";
93
+ },
94
+
95
+ "html": function(locale, options) {
96
+ var size = (options && options.size) ? ' btn-'+options.size : '';
97
+ return "<li>" +
98
+ "<div class='btn-group'>" +
99
+ "<a class='btn btn-default btn" + size + "' data-wysihtml5-action='change_view' title='" + locale.html.edit + "' tabindex='-1'><i class='glyphicon glyphicon-pencil'></i></a>" +
100
+ "</div>" +
101
+ "</li>";
102
+ },
103
+
104
+ "color": function(locale, options) {
105
+ var size = (options && options.size) ? ' btn-'+options.size : '';
106
+ return "<li class='dropdown'>" +
107
+ "<a class='btn btn-default dropdown-toggle" + size + "' data-toggle='dropdown' href='#' tabindex='-1'>" +
108
+ "<span class='current-color'>" + locale.colours.black + "</span>&nbsp;<b class='caret'></b>" +
109
+ "</a>" +
110
+ "<ul class='dropdown-menu'>" +
111
+ "<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>" +
112
+ "<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>" +
113
+ "<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>" +
114
+ "<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>" +
115
+ "<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>" +
116
+ "<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>" +
117
+ "<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>" +
118
+ "<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>" +
119
+ "<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>" +
120
+ "<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>" +
121
+ "<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>" +
122
+ "</ul>" +
123
+ "</li>";
124
+ }
125
+ };
126
+
127
+ var templates = function(key, locale, options) {
128
+ return tpl[key](locale, options);
129
+ };
130
+
131
+
132
+ var Wysihtml5 = function(el, options) {
133
+ this.el = el;
134
+ var toolbarOpts = options || defaultOptions;
135
+ for(var t in toolbarOpts.customTemplates) {
136
+ tpl[t] = toolbarOpts.customTemplates[t];
137
+ }
138
+ this.toolbar = this.createToolbar(el, toolbarOpts);
139
+ this.editor = this.createEditor(options);
140
+
141
+ window.editor = this.editor;
142
+
143
+ $('iframe.wysihtml5-sandbox').each(function(i, el){
144
+ $(el.contentWindow).off('focus.wysihtml5').on({
145
+ 'focus.wysihtml5' : function(){
146
+ $('li.dropdown').removeClass('open');
147
+ }
148
+ });
149
+ });
150
+ };
151
+
152
+ Wysihtml5.prototype = {
153
+
154
+ constructor: Wysihtml5,
155
+
156
+ createEditor: function(options) {
157
+ options = options || {};
158
+
159
+ // Add the toolbar to a clone of the options object so multiple instances
160
+ // of the WYISYWG don't break because "toolbar" is already defined
161
+ options = $.extend(true, {}, options);
162
+ options.toolbar = this.toolbar[0];
163
+
164
+ var editor = new wysi.Editor(this.el[0], options);
165
+
166
+ if(options && options.events) {
167
+ for(var eventName in options.events) {
168
+ editor.on(eventName, options.events[eventName]);
169
+ }
170
+ }
171
+ return editor;
172
+ },
173
+
174
+ createToolbar: function(el, options) {
175
+ var self = this;
176
+ var toolbar = $("<ul/>", {
177
+ 'class' : "wysihtml5-toolbar",
178
+ 'style': "display:none"
179
+ });
180
+ var culture = options.locale || defaultOptions.locale || "en";
181
+ for(var key in defaultOptions) {
182
+ var value = false;
183
+
184
+ if(options[key] !== undefined) {
185
+ if(options[key] === true) {
186
+ value = true;
187
+ }
188
+ } else {
189
+ value = defaultOptions[key];
190
+ }
191
+
192
+ if(value === true) {
193
+ toolbar.append(templates(key, locale[culture], options));
194
+
195
+ if(key === "html") {
196
+ this.initHtml(toolbar);
197
+ }
198
+
199
+ if(key === "link") {
200
+ this.initInsertLink(toolbar);
201
+ }
202
+
203
+ if(key === "image") {
204
+ this.initInsertImage(toolbar);
205
+ }
206
+ }
207
+ }
208
+
209
+ if(options.toolbar) {
210
+ for(key in options.toolbar) {
211
+ toolbar.append(options.toolbar[key]);
212
+ }
213
+ }
214
+
215
+ toolbar.find("a[data-wysihtml5-command='formatBlock']").click(function(e) {
216
+ var target = e.target || e.srcElement;
217
+ var el = $(target);
218
+ self.toolbar.find('.current-font').text(el.html());
219
+ });
220
+
221
+ toolbar.find("a[data-wysihtml5-command='foreColor']").click(function(e) {
222
+ var target = e.target || e.srcElement;
223
+ var el = $(target);
224
+ self.toolbar.find('.current-color').text(el.html());
225
+ });
226
+
227
+ this.el.before(toolbar);
228
+
229
+ return toolbar;
230
+ },
231
+
232
+ initHtml: function(toolbar) {
233
+ var changeViewSelector = "a[data-wysihtml5-action='change_view']";
234
+ toolbar.find(changeViewSelector).click(function(e) {
235
+ toolbar.find('a.btn').not(changeViewSelector).toggleClass('disabled');
236
+ });
237
+ },
238
+
239
+ initInsertImage: function(toolbar) {
240
+ var self = this;
241
+ var insertImageModal = toolbar.find('.bootstrap-wysihtml5-insert-image-modal');
242
+ var urlInput = insertImageModal.find('.bootstrap-wysihtml5-insert-image-url');
243
+ var insertButton = insertImageModal.find('a.btn-primary');
244
+ var initialValue = urlInput.val();
245
+ var caretBookmark;
246
+
247
+ var insertImage = function() {
248
+ var url = urlInput.val();
249
+ urlInput.val(initialValue);
250
+ self.editor.currentView.element.focus();
251
+ if (caretBookmark) {
252
+ self.editor.composer.selection.setBookmark(caretBookmark);
253
+ caretBookmark = null;
254
+ }
255
+ self.editor.composer.commands.exec("insertImage", url);
256
+ };
257
+
258
+ urlInput.keypress(function(e) {
259
+ if(e.which == 13) {
260
+ insertImage();
261
+ insertImageModal.modal('hide');
262
+ }
263
+ });
264
+
265
+ insertButton.click(insertImage);
266
+
267
+ insertImageModal.on('shown', function() {
268
+ urlInput.focus();
269
+ });
270
+
271
+ insertImageModal.on('hide', function() {
272
+ self.editor.currentView.element.focus();
273
+ });
274
+
275
+ toolbar.find('a[data-wysihtml5-command=insertImage]').click(function() {
276
+ var activeButton = $(this).hasClass("wysihtml5-command-active");
277
+
278
+ if (!activeButton) {
279
+ self.editor.currentView.element.focus(false);
280
+ caretBookmark = self.editor.composer.selection.getBookmark();
281
+ insertImageModal.appendTo('body').modal('show');
282
+ insertImageModal.on('click.dismiss.modal', '[data-dismiss="modal"]', function(e) {
283
+ e.stopPropagation();
284
+ });
285
+ return false;
286
+ }
287
+ else {
288
+ return true;
289
+ }
290
+ });
291
+ },
292
+
293
+ initInsertLink: function(toolbar) {
294
+ var self = this;
295
+ var insertLinkModal = toolbar.find('.bootstrap-wysihtml5-insert-link-modal');
296
+ var urlInput = insertLinkModal.find('.bootstrap-wysihtml5-insert-link-url');
297
+ var targetInput = insertLinkModal.find('.bootstrap-wysihtml5-insert-link-target');
298
+ var insertButton = insertLinkModal.find('a.btn-primary');
299
+ var initialValue = urlInput.val();
300
+ var caretBookmark;
301
+
302
+ var insertLink = function() {
303
+ var url = urlInput.val();
304
+ urlInput.val(initialValue);
305
+ self.editor.currentView.element.focus();
306
+ if (caretBookmark) {
307
+ self.editor.composer.selection.setBookmark(caretBookmark);
308
+ caretBookmark = null;
309
+ }
310
+
311
+ var newWindow = targetInput.prop("checked");
312
+ self.editor.composer.commands.exec("createLink", {
313
+ 'href' : url,
314
+ 'target' : (newWindow ? '_blank' : '_self'),
315
+ 'rel' : (newWindow ? 'nofollow' : '')
316
+ });
317
+ };
318
+ var pressedEnter = false;
319
+
320
+ urlInput.keypress(function(e) {
321
+ if(e.which == 13) {
322
+ insertLink();
323
+ insertLinkModal.modal('hide');
324
+ }
325
+ });
326
+
327
+ insertButton.click(insertLink);
328
+
329
+ insertLinkModal.on('shown', function() {
330
+ urlInput.focus();
331
+ });
332
+
333
+ insertLinkModal.on('hide', function() {
334
+ self.editor.currentView.element.focus();
335
+ });
336
+
337
+ toolbar.find('a[data-wysihtml5-command=createLink]').click(function() {
338
+ var activeButton = $(this).hasClass("wysihtml5-command-active");
339
+
340
+ if (!activeButton) {
341
+ self.editor.currentView.element.focus(false);
342
+ caretBookmark = self.editor.composer.selection.getBookmark();
343
+ insertLinkModal.appendTo('body').modal('show');
344
+ insertLinkModal.on('click.dismiss.modal', '[data-dismiss="modal"]', function(e) {
345
+ e.stopPropagation();
346
+ });
347
+ return false;
348
+ }
349
+ else {
350
+ return true;
351
+ }
352
+ });
353
+ }
354
+ };
355
+
356
+ // these define our public api
357
+ var methods = {
358
+ resetDefaults: function() {
359
+ $.fn.wysihtml5.defaultOptions = $.extend(true, {}, $.fn.wysihtml5.defaultOptionsCache);
360
+ },
361
+ bypassDefaults: function(options) {
362
+ return this.each(function () {
363
+ var $this = $(this);
364
+ $this.data('wysihtml5', new Wysihtml5($this, options));
365
+ });
366
+ },
367
+ shallowExtend: function (options) {
368
+ var settings = $.extend({}, $.fn.wysihtml5.defaultOptions, options || {}, $(this).data());
369
+ var that = this;
370
+ return methods.bypassDefaults.apply(that, [settings]);
371
+ },
372
+ deepExtend: function(options) {
373
+ var settings = $.extend(true, {}, $.fn.wysihtml5.defaultOptions, options || {});
374
+ var that = this;
375
+ return methods.bypassDefaults.apply(that, [settings]);
376
+ },
377
+ init: function(options) {
378
+ var that = this;
379
+ return methods.shallowExtend.apply(that, [options]);
380
+ }
381
+ };
382
+
383
+ $.fn.wysihtml5 = function ( method ) {
384
+ if ( methods[method] ) {
385
+ return methods[method].apply( this, Array.prototype.slice.call( arguments, 1 ));
386
+ } else if ( typeof method === 'object' || ! method ) {
387
+ return methods.init.apply( this, arguments );
388
+ } else {
389
+ $.error( 'Method ' + method + ' does not exist on jQuery.wysihtml5' );
390
+ }
391
+ };
392
+
393
+ $.fn.wysihtml5.Constructor = Wysihtml5;
394
+
395
+ var defaultOptions = $.fn.wysihtml5.defaultOptions = {
396
+ "font-styles": true,
397
+ "color": false,
398
+ "emphasis": true,
399
+ "lists": true,
400
+ "html": false,
401
+ "link": true,
402
+ "image": true,
403
+ events: {},
404
+ parserRules: {
405
+ classes: {
406
+ // (path_to_project/lib/css/wysiwyg-color.css)
407
+ "wysiwyg-color-silver" : 1,
408
+ "wysiwyg-color-gray" : 1,
409
+ "wysiwyg-color-white" : 1,
410
+ "wysiwyg-color-maroon" : 1,
411
+ "wysiwyg-color-red" : 1,
412
+ "wysiwyg-color-purple" : 1,
413
+ "wysiwyg-color-fuchsia" : 1,
414
+ "wysiwyg-color-green" : 1,
415
+ "wysiwyg-color-lime" : 1,
416
+ "wysiwyg-color-olive" : 1,
417
+ "wysiwyg-color-yellow" : 1,
418
+ "wysiwyg-color-navy" : 1,
419
+ "wysiwyg-color-blue" : 1,
420
+ "wysiwyg-color-teal" : 1,
421
+ "wysiwyg-color-aqua" : 1,
422
+ "wysiwyg-color-orange" : 1
423
+ },
424
+ tags: {
425
+ "b": {},
426
+ "i": {},
427
+ "br": {},
428
+ "ol": {},
429
+ "ul": {},
430
+ "li": {},
431
+ "h1": {},
432
+ "h2": {},
433
+ "h3": {},
434
+ "h4": {},
435
+ "h5": {},
436
+ "h6": {},
437
+ "blockquote": {},
438
+ "u": 1,
439
+ "img": {
440
+ "check_attributes": {
441
+ "width": "numbers",
442
+ "alt": "alt",
443
+ "src": "url",
444
+ "height": "numbers"
445
+ }
446
+ },
447
+ "a": {
448
+ check_attributes: {
449
+ 'href': "url", // important to avoid XSS
450
+ 'target': 'alt',
451
+ 'rel': 'alt'
452
+ }
453
+ },
454
+ "span": 1,
455
+ "div": 1,
456
+ // to allow save and edit files with code tag hacks
457
+ "code": 1,
458
+ "pre": 1
459
+ }
460
+ },
461
+ stylesheets: ["<%= stylesheet_path('bootstrap-wysihtml5/wysiwyg-color.css') %>"], // (path_to_project/lib/css/wysiwyg-color.css)
462
+ locale: "en"
463
+ };
464
+
465
+ if (typeof $.fn.wysihtml5.defaultOptionsCache === 'undefined') {
466
+ $.fn.wysihtml5.defaultOptionsCache = $.extend(true, {}, $.fn.wysihtml5.defaultOptions);
467
+ }
468
+
469
+ var locale = $.fn.wysihtml5.locale = {
470
+ en: {
471
+ font_styles: {
472
+ normal: "Normal text",
473
+ h1: "Heading 1",
474
+ h2: "Heading 2",
475
+ h3: "Heading 3",
476
+ h4: "Heading 4",
477
+ h5: "Heading 5",
478
+ h6: "Heading 6"
479
+ },
480
+ emphasis: {
481
+ bold: "Bold",
482
+ italic: "Italic",
483
+ underline: "Underline"
484
+ },
485
+ lists: {
486
+ unordered: "Unordered list",
487
+ ordered: "Ordered list",
488
+ outdent: "Outdent",
489
+ indent: "Indent"
490
+ },
491
+ link: {
492
+ insert: "Insert link",
493
+ cancel: "Cancel",
494
+ target: "Open link in new window"
495
+ },
496
+ image: {
497
+ insert: "Insert image",
498
+ cancel: "Cancel"
499
+ },
500
+ html: {
501
+ edit: "Edit HTML"
502
+ },
503
+ colours: {
504
+ black: "Black",
505
+ silver: "Silver",
506
+ gray: "Grey",
507
+ maroon: "Maroon",
508
+ red: "Red",
509
+ purple: "Purple",
510
+ green: "Green",
511
+ olive: "Olive",
512
+ navy: "Navy",
513
+ blue: "Blue",
514
+ orange: "Orange"
515
+ }
516
+ }
517
+ };
518
+
519
+ }(window.jQuery, window.wysihtml5);
520
+
@@ -0,0 +1,3 @@
1
+ /*
2
+ *= require ./core-b3
3
+ */
@@ -0,0 +1,92 @@
1
+ ul.wysihtml5-toolbar {
2
+ margin: 0;
3
+ padding: 0;
4
+ display: block;
5
+ }
6
+
7
+ ul.wysihtml5-toolbar::after {
8
+ clear: both;
9
+ display: table;
10
+ content: "";
11
+ }
12
+
13
+ ul.wysihtml5-toolbar > li {
14
+ float: left;
15
+ display: list-item;
16
+ list-style: none;
17
+ margin: 0 5px 10px 0;
18
+ }
19
+
20
+ ul.wysihtml5-toolbar a[data-wysihtml5-command=bold] {
21
+ font-weight: bold;
22
+ }
23
+
24
+ ul.wysihtml5-toolbar a[data-wysihtml5-command=italic] {
25
+ font-style: italic;
26
+ }
27
+
28
+ ul.wysihtml5-toolbar a[data-wysihtml5-command=underline] {
29
+ text-decoration: underline;
30
+ }
31
+
32
+ ul.wysihtml5-commands-disabled .dropdown-menu {
33
+ display: none !important;
34
+ }
35
+
36
+ ul.wysihtml5-toolbar div.wysihtml5-colors {
37
+ display:block;
38
+ width: 50px;
39
+ height: 20px;
40
+ margin-top: 2px;
41
+ margin-left: 5px;
42
+ position: absolute;
43
+ pointer-events: none;
44
+ }
45
+
46
+ ul.wysihtml5-toolbar a.wysihtml5-colors-title {
47
+ padding-left: 70px;
48
+ }
49
+
50
+ ul.wysihtml5-toolbar div[data-wysihtml5-command-value="black"] {
51
+ background: black !important;
52
+ }
53
+
54
+ ul.wysihtml5-toolbar div[data-wysihtml5-command-value="silver"] {
55
+ background: silver !important;
56
+ }
57
+
58
+ ul.wysihtml5-toolbar div[data-wysihtml5-command-value="gray"] {
59
+ background: gray !important;
60
+ }
61
+
62
+ ul.wysihtml5-toolbar div[data-wysihtml5-command-value="maroon"] {
63
+ background: maroon !important;
64
+ }
65
+
66
+ ul.wysihtml5-toolbar div[data-wysihtml5-command-value="red"] {
67
+ background: red !important;
68
+ }
69
+
70
+ ul.wysihtml5-toolbar div[data-wysihtml5-command-value="purple"] {
71
+ background: purple !important;
72
+ }
73
+
74
+ ul.wysihtml5-toolbar div[data-wysihtml5-command-value="green"] {
75
+ background: green !important;
76
+ }
77
+
78
+ ul.wysihtml5-toolbar div[data-wysihtml5-command-value="olive"] {
79
+ background: olive !important;
80
+ }
81
+
82
+ ul.wysihtml5-toolbar div[data-wysihtml5-command-value="navy"] {
83
+ background: navy !important;
84
+ }
85
+
86
+ ul.wysihtml5-toolbar div[data-wysihtml5-command-value="blue"] {
87
+ background: blue !important;
88
+ }
89
+
90
+ ul.wysihtml5-toolbar div[data-wysihtml5-command-value="orange"] {
91
+ background: orange !important;
92
+ }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootstrap-wysihtml5-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1.22
4
+ version: 0.3.1.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gonzalo Rodríguez-Baltanás Díaz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-23 00:00:00.000000000 Z
11
+ date: 2013-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -70,6 +70,8 @@ files:
70
70
  - lib/bootstrap-wysihtml5-rails/engine.rb
71
71
  - lib/bootstrap-wysihtml5-rails/railtie.rb
72
72
  - lib/bootstrap-wysihtml5-rails/version.rb
73
+ - vendor/assets/javascripts/bootstrap-wysihtml5/b3.js
74
+ - vendor/assets/javascripts/bootstrap-wysihtml5/core-b3.js.erb
73
75
  - vendor/assets/javascripts/bootstrap-wysihtml5/core.js.erb
74
76
  - vendor/assets/javascripts/bootstrap-wysihtml5/index.js
75
77
  - vendor/assets/javascripts/bootstrap-wysihtml5/locales/ar-AR.js
@@ -102,6 +104,8 @@ files:
102
104
  - vendor/assets/javascripts/bootstrap-wysihtml5/locales/zh-CN.js
103
105
  - vendor/assets/javascripts/bootstrap-wysihtml5/locales/zh-TW.js
104
106
  - vendor/assets/javascripts/bootstrap-wysihtml5/wysihtml5.js
107
+ - vendor/assets/stylesheets/bootstrap-wysihtml5/b3.css
108
+ - vendor/assets/stylesheets/bootstrap-wysihtml5/core-b3.css
105
109
  - vendor/assets/stylesheets/bootstrap-wysihtml5/core.css
106
110
  - vendor/assets/stylesheets/bootstrap-wysihtml5/index.css
107
111
  - vendor/assets/stylesheets/bootstrap-wysihtml5/wysiwyg-color.css