beautiful_scaffold 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,295 @@
1
+ !function($, wysi) {
2
+ "use strict";
3
+
4
+ var templates = {
5
+ "font-styles": "<li class='dropdown'>" +
6
+ "<a class='btn dropdown-toggle' data-toggle='dropdown' href='#'>" +
7
+ "<i class='icon-font'></i>&nbsp;<span class='current-font'>Normal text</span>&nbsp;<b class='caret'></b>" +
8
+ "</a>" +
9
+ "<ul class='dropdown-menu'>" +
10
+ "<li><a data-wysihtml5-command='formatBlock' data-wysihtml5-command-value='div'>Normal text</a></li>" +
11
+ "<li><a data-wysihtml5-command='formatBlock' data-wysihtml5-command-value='h1'>Heading 1</a></li>" +
12
+ "<li><a data-wysihtml5-command='formatBlock' data-wysihtml5-command-value='h2'>Heading 2</a></li>" +
13
+ "</ul>" +
14
+ "</li>",
15
+ "emphasis": "<li>" +
16
+ "<div class='btn-group'>" +
17
+ "<a class='btn' data-wysihtml5-command='bold' title='CTRL+B'>Bold</a>" +
18
+ "<a class='btn' data-wysihtml5-command='italic' title='CTRL+I'>Italic</a>" +
19
+ "<a class='btn' data-wysihtml5-command='underline' title='CTRL+U'>Underline</a>" +
20
+ "</div>" +
21
+ "</li>",
22
+ "lists": "<li>" +
23
+ "<div class='btn-group'>" +
24
+ "<a class='btn' data-wysihtml5-command='insertUnorderedList' title='Unordered List'><i class='icon-list'></i></a>" +
25
+ "<a class='btn' data-wysihtml5-command='insertOrderedList' title='Ordered List'><i class='icon-th-list'></i></a>" +
26
+ "<a class='btn' data-wysihtml5-command='Outdent' title='Outdent'><i class='icon-indent-right'></i></a>" +
27
+ "<a class='btn' data-wysihtml5-command='Indent' title='Indent'><i class='icon-indent-left'></i></a>" +
28
+ "</div>" +
29
+ "</li>",
30
+ "link": "<li>" +
31
+ "<div class='bootstrap-wysihtml5-insert-link-modal modal hide fade'>" +
32
+ "<div class='modal-header'>" +
33
+ "<a class='close' data-dismiss='modal'>&times;</a>" +
34
+ "<h3>Insert Link</h3>" +
35
+ "</div>" +
36
+ "<div class='modal-body'>" +
37
+ "<input value='http://' class='bootstrap-wysihtml5-insert-link-url input-xlarge'>" +
38
+ "</div>" +
39
+ "<div class='modal-footer'>" +
40
+ "<a href='#' class='btn' data-dismiss='modal'>Cancel</a>" +
41
+ "<a href='#' class='btn btn-primary' data-dismiss='modal'>Insert link</a>" +
42
+ "</div>" +
43
+ "</div>" +
44
+ "<a class='btn' data-wysihtml5-command='createLink' title='Link'><i class='icon-share'></i></a>" +
45
+ "</li>",
46
+ "image": "<li>" +
47
+ "<div class='bootstrap-wysihtml5-insert-image-modal modal hide fade'>" +
48
+ "<div class='modal-header'>" +
49
+ "<a class='close' data-dismiss='modal'>&times;</a>" +
50
+ "<h3>Insert Image</h3>" +
51
+ "</div>" +
52
+ "<div class='modal-body'>" +
53
+ "<input value='http://' class='bootstrap-wysihtml5-insert-image-url input-xlarge'>" +
54
+ "</div>" +
55
+ "<div class='modal-footer'>" +
56
+ "<a href='#' class='btn' data-dismiss='modal'>Cancel</a>" +
57
+ "<a href='#' class='btn btn-primary' data-dismiss='modal'>Insert image</a>" +
58
+ "</div>" +
59
+ "</div>" +
60
+ "<a class='btn' data-wysihtml5-command='insertImage' title='Insert image'><i class='icon-picture'></i></a>" +
61
+ "</li>",
62
+
63
+ "html":
64
+ "<li>" +
65
+ "<div class='btn-group'>" +
66
+ "<a class='btn' data-wysihtml5-action='change_view' title='Edit HTML'><i class='icon-pencil'></i></a>" +
67
+ "</div>" +
68
+ "</li>"
69
+ };
70
+
71
+ var defaultOptions = {
72
+ "font-styles": true,
73
+ "emphasis": true,
74
+ "lists": true,
75
+ "html": false,
76
+ "link": true,
77
+ "image": true,
78
+ events: {},
79
+ parserRules: {
80
+ tags: {
81
+ "b": {},
82
+ "i": {},
83
+ "br": {},
84
+ "ol": {},
85
+ "ul": {},
86
+ "li": {},
87
+ "h1": {},
88
+ "h2": {},
89
+ "blockquote": {},
90
+ "u": 1,
91
+ "img": {
92
+ "check_attributes": {
93
+ "width": "numbers",
94
+ "alt": "alt",
95
+ "src": "url",
96
+ "height": "numbers"
97
+ }
98
+ },
99
+ "a": {
100
+ set_attributes: {
101
+ target: "_blank",
102
+ rel: "nofollow"
103
+ },
104
+ check_attributes: {
105
+ href: "url" // important to avoid XSS
106
+ }
107
+ }
108
+ }
109
+ },
110
+ stylesheets: []
111
+ };
112
+
113
+ var Wysihtml5 = function(el, options) {
114
+ this.el = el;
115
+ this.toolbar = this.createToolbar(el, options || defaultOptions);
116
+ this.editor = this.createEditor(options);
117
+
118
+ window.editor = this.editor;
119
+
120
+ $('iframe.wysihtml5-sandbox').each(function(i, el){
121
+ $(el.contentWindow).off('focus.wysihtml5').on({
122
+ 'focus.wysihtml5' : function(){
123
+ $('li.dropdown').removeClass('open');
124
+ }
125
+ });
126
+ });
127
+ };
128
+
129
+ Wysihtml5.prototype = {
130
+
131
+ constructor: Wysihtml5,
132
+
133
+ createEditor: function(options) {
134
+ options = $.extend(defaultOptions, options || {});
135
+ options.toolbar = this.toolbar[0];
136
+
137
+ var editor = new wysi.Editor(this.el[0], options);
138
+
139
+ if(options && options.events) {
140
+ for(var eventName in options.events) {
141
+ editor.on(eventName, options.events[eventName]);
142
+ }
143
+ }
144
+
145
+ return editor;
146
+ },
147
+
148
+ createToolbar: function(el, options) {
149
+ var self = this;
150
+ var toolbar = $("<ul/>", {
151
+ 'class' : "wysihtml5-toolbar",
152
+ 'style': "display:none"
153
+ });
154
+
155
+ for(var key in defaultOptions) {
156
+ var value = false;
157
+
158
+ if(options[key] !== undefined) {
159
+ if(options[key] === true) {
160
+ value = true;
161
+ }
162
+ } else {
163
+ value = defaultOptions[key];
164
+ }
165
+
166
+ if(value === true) {
167
+ toolbar.append(templates[key]);
168
+
169
+ if(key == "html") {
170
+ this.initHtml(toolbar);
171
+ }
172
+
173
+ if(key == "link") {
174
+ this.initInsertLink(toolbar);
175
+ }
176
+
177
+ if(key == "image") {
178
+ this.initInsertImage(toolbar);
179
+ }
180
+ }
181
+ }
182
+
183
+ toolbar.find("a[data-wysihtml5-command='formatBlock']").click(function(e) {
184
+ var el = $(e.srcElement);
185
+ self.toolbar.find('.current-font').text(el.html());
186
+ });
187
+
188
+ this.el.before(toolbar);
189
+
190
+ return toolbar;
191
+ },
192
+
193
+ initHtml: function(toolbar) {
194
+ var changeViewSelector = "a[data-wysihtml5-action='change_view']";
195
+ toolbar.find(changeViewSelector).click(function(e) {
196
+ toolbar.find('a.btn').not(changeViewSelector).toggleClass('disabled');
197
+ });
198
+ },
199
+
200
+ initInsertImage: function(toolbar) {
201
+ var self = this;
202
+ var insertImageModal = toolbar.find('.bootstrap-wysihtml5-insert-image-modal');
203
+ var urlInput = insertImageModal.find('.bootstrap-wysihtml5-insert-image-url');
204
+ var insertButton = insertImageModal.find('a.btn-primary');
205
+ var initialValue = urlInput.val();
206
+
207
+ var insertImage = function() {
208
+ var url = urlInput.val();
209
+ urlInput.val(initialValue);
210
+ self.editor.composer.commands.exec("insertImage", url);
211
+ };
212
+
213
+ urlInput.keypress(function(e) {
214
+ if(e.which == 13) {
215
+ insertImage();
216
+ insertImageModal.modal('hide');
217
+ }
218
+ });
219
+
220
+ insertButton.click(insertImage);
221
+
222
+ insertImageModal.on('shown', function() {
223
+ urlInput.focus();
224
+ });
225
+
226
+ insertImageModal.on('hide', function() {
227
+ self.editor.currentView.element.focus();
228
+ });
229
+
230
+ toolbar.find('a[data-wysihtml5-command=insertImage]').click(function() {
231
+ insertImageModal.modal('show');
232
+ insertImageModal.on('click.dismiss.modal', '[data-dismiss="modal"]', function(e) {
233
+ e.stopPropagation();
234
+ });
235
+ return false;
236
+ });
237
+ },
238
+
239
+ initInsertLink: function(toolbar) {
240
+ var self = this;
241
+ var insertLinkModal = toolbar.find('.bootstrap-wysihtml5-insert-link-modal');
242
+ var urlInput = insertLinkModal.find('.bootstrap-wysihtml5-insert-link-url');
243
+ var insertButton = insertLinkModal.find('a.btn-primary');
244
+ var initialValue = urlInput.val();
245
+
246
+ var insertLink = function() {
247
+ var url = urlInput.val();
248
+ urlInput.val(initialValue);
249
+ self.editor.composer.commands.exec("createLink", {
250
+ href: url,
251
+ target: "_blank",
252
+ rel: "nofollow"
253
+ });
254
+ };
255
+ var pressedEnter = false;
256
+
257
+ urlInput.keypress(function(e) {
258
+ if(e.which == 13) {
259
+ insertLink();
260
+ insertLinkModal.modal('hide');
261
+ }
262
+ });
263
+
264
+ insertButton.click(insertLink);
265
+
266
+ insertLinkModal.on('shown', function() {
267
+ urlInput.focus();
268
+ });
269
+
270
+ insertLinkModal.on('hide', function() {
271
+ self.editor.currentView.element.focus();
272
+ });
273
+
274
+ toolbar.find('a[data-wysihtml5-command=createLink]').click(function() {
275
+ insertLinkModal.modal('show');
276
+ insertLinkModal.on('click.dismiss.modal', '[data-dismiss="modal"]', function(e) {
277
+ e.stopPropagation();
278
+ });
279
+ return false;
280
+ });
281
+
282
+
283
+ }
284
+ };
285
+
286
+ $.fn.wysihtml5 = function (options) {
287
+ return this.each(function () {
288
+ var $this = $(this);
289
+ $this.data('wysihtml5', new Wysihtml5($this, options));
290
+ });
291
+ };
292
+
293
+ $.fn.wysihtml5.Constructor = Wysihtml5;
294
+
295
+ }(window.jQuery, window.wysihtml5);
@@ -0,0 +1,44 @@
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-toolbar a.btn.wysihtml5-command-active {
33
+ background-image: none;
34
+ -webkit-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15),0 1px 2px rgba(0, 0, 0, 0.05);
35
+ -moz-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15),0 1px 2px rgba(0, 0, 0, 0.05);
36
+ box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15),0 1px 2px rgba(0, 0, 0, 0.05);
37
+ background-color: #E6E6E6;
38
+ background-color: #D9D9D9 9;
39
+ outline: 0;
40
+ }
41
+
42
+ ul.wysihtml5-commands-disabled .dropdown-menu {
43
+ display: none !important;
44
+ }
@@ -7,7 +7,7 @@
7
7
  <meta name="description" content="Beautiful Scaffold">
8
8
  <meta name="author" content="You or me Sylvain Claudel (http://blog.escarworld.com)">
9
9
 
10
- <%%= stylesheet_link_tag "reset", "bootstrap.min", "bootstrap-responsive.min", "datepicker", "timepicker", "beautiful-scaffold", "tagit-dark-grey", "colorpicker" %>
10
+ <%%= stylesheet_link_tag "reset", "bootstrap.min", "bootstrap-responsive.min", "datepicker", "timepicker", "beautiful-scaffold", "tagit-dark-grey", "colorpicker", "bootstrap-wysihtml5" %>
11
11
  <style>
12
12
  body {
13
13
  padding-top: 60px; /* 60px to make the container go all the way to the bottom of the topbar */
@@ -91,7 +91,7 @@
91
91
  <div class="circle1"></div>
92
92
  </div>
93
93
 
94
- <%%= javascript_include_tag "bootstrap.min", "bootstrap-alert", "bootstrap-datepicker" ,"bootstrap-timepicker", "bootstrap-dropdown", "bootstrap-modal", "bootstrap-tooltip", "bootstrap-colorpicker" %>
94
+ <%%= javascript_include_tag "bootstrap.min", "bootstrap-alert", "bootstrap-datepicker" ,"bootstrap-timepicker", "bootstrap-dropdown", "bootstrap-modal", "bootstrap-tooltip", "bootstrap-colorpicker", "wysihtml5-0.3.0.min", "bootstrap-wysihtml5" %>
95
95
  <script type="text/javascript">
96
96
  ;(function($){
97
97
  $.fn.datepicker.dates['<%= I18n.locale.to_s %>'] = {
@@ -29,7 +29,17 @@
29
29
  });
30
30
  </script>
31
31
  <%% end %>
32
-
32
+ <%- elsif @beautiful_attributes.include?(attribute.name + ':wysiwyg') then -%>
33
+ <div class="control-group">
34
+ <%%= f.label :<%= attribute.name %>, t(:<%= attribute.name %>, :default => "<%= attribute.name.capitalize %>"), :class => "control-label" %>
35
+ <div class="controls">
36
+ <%%= f.text_area :<%= attribute.name %>, :class => "wysiwyg-editor" %>
37
+ </div>
38
+ </div>
39
+ <%%= f.hidden_field :<%= attribute.name %>_typetext, :value => "html" %>
40
+ <script type="text/javascript">
41
+ $('.wysiwyg-editor').wysihtml5({"html": true});
42
+ </script>
33
43
  <%- elsif @beautiful_attributes.include?(attribute.name + ':references') then -%>
34
44
  <div class="control-group">
35
45
  <%%= f.label :<%= attribute.name %>, t(:<%= attribute.name %>, :default => "<%= attribute.name.capitalize %>"), :class => "control-label" %>
@@ -79,13 +89,13 @@
79
89
  <div class="control-group">
80
90
  <%%= f.label :<%= attribute.name %>, t(:<%= attribute.name %>, :default => "<%= attribute.name.capitalize %>"), :class => "control-label" %>
81
91
  <div class="controls">
82
- <div class="input-append color" data-color="rgb(0, 0, 0)" data-color-format="rgb">
92
+ <div class="input-append color" data-color="<%%= (@<%= model %>.<%= attribute.name %> || "rgba(0, 0, 0)") %>" data-color-format="rgba">
83
93
  <%%= f.<%= attribute.field_type %> :<%= attribute.name %> %><span class="add-on"><i style="background-color: rgb(0, 0, 0)"></i></span>
84
94
  </div>
85
95
  </div>
86
96
  </div>
87
97
  <script type="text/javascript">
88
- $('.color').colorpicker();
98
+ $('.color').colorpicker({format: 'rgba'});
89
99
  </script>
90
100
  <%- else -%>
91
101
  <div class="control-group">
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beautiful_scaffold
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:
@@ -34,6 +34,8 @@ files:
34
34
  - lib/generators/templates/app/assets/images/hue.png
35
35
  - lib/generators/templates/app/assets/images/saturation.png
36
36
  - lib/generators/templates/app/assets/images/ui-anim_basic_16x16.gif
37
+ - lib/generators/templates/app/assets/javascripts/a-wysihtml5-0.3.0.min.js
38
+ - lib/generators/templates/app/assets/javascripts/advanced.js
37
39
  - lib/generators/templates/app/assets/javascripts/beautiful_scaffold.js
38
40
  - lib/generators/templates/app/assets/javascripts/bootstrap-alert.js
39
41
  - lib/generators/templates/app/assets/javascripts/bootstrap-colorpicker.js
@@ -43,6 +45,7 @@ files:
43
45
  - lib/generators/templates/app/assets/javascripts/bootstrap-modal.js
44
46
  - lib/generators/templates/app/assets/javascripts/bootstrap-timepicker.js
45
47
  - lib/generators/templates/app/assets/javascripts/bootstrap-tooltip.js
48
+ - lib/generators/templates/app/assets/javascripts/bootstrap-wysihtml5.js
46
49
  - lib/generators/templates/app/assets/javascripts/bootstrap.js
47
50
  - lib/generators/templates/app/assets/javascripts/bootstrap.min.js
48
51
  - lib/generators/templates/app/assets/javascripts/jquery.jstree.js
@@ -53,6 +56,7 @@ files:
53
56
  - lib/generators/templates/app/assets/stylesheets/beautiful-scaffold.css.scss
54
57
  - lib/generators/templates/app/assets/stylesheets/bootstrap-responsive.css
55
58
  - lib/generators/templates/app/assets/stylesheets/bootstrap-responsive.min.css
59
+ - lib/generators/templates/app/assets/stylesheets/bootstrap-wysihtml5.css
56
60
  - lib/generators/templates/app/assets/stylesheets/bootstrap.css
57
61
  - lib/generators/templates/app/assets/stylesheets/bootstrap.min.css
58
62
  - lib/generators/templates/app/assets/stylesheets/colorpicker.css