bootstrap-wysihtml5-rails 0.2.3 → 0.2.4

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/Rakefile CHANGED
@@ -7,7 +7,7 @@ task 'update' do
7
7
  system("git clone git://github.com/jhollingworth/bootstrap-wysihtml5.git")
8
8
  system("cp bootstrap-wysihtml5/src/bootstrap-wysihtml5.css vendor/assets/stylesheets/bootstrap-wysihtml5.css")
9
9
  system("cp bootstrap-wysihtml5/src/bootstrap-wysihtml5.js vendor/assets/javascripts/bootstrap-wysihtml5.js")
10
- system("cp bootstrap-wysihtml5/lib/js/wysihtml5-0.3.0_rc1.js vendor/assets/javascripts/wysihtml5.js")
10
+ system("cp bootstrap-wysihtml5/lib/js/wysihtml5-0.3.0_rc2.js vendor/assets/javascripts/wysihtml5.js")
11
11
  end
12
12
 
13
13
  desc "Build the gem"
@@ -1,5 +1,5 @@
1
1
  module BootstrapWysihtml5Rails
2
2
  module Rails
3
- VERSION = "0.2.3"
3
+ VERSION = "0.2.4"
4
4
  end
5
5
  end
@@ -13,44 +13,54 @@
13
13
  "</ul>" +
14
14
  "</li>",
15
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
- "</div>" +
20
- "</li>",
21
- "lists": "<li>" +
22
- "<div class='btn-group'>" +
23
- "<a class='btn' data-wysihtml5-command='insertUnorderedList' title='Unordered List'><i class='icon-list'></i></a>" +
24
- "<a class='btn' data-wysihtml5-command='insertOrderedList' title='Ordered List'><i class='icon-th-list'></i></a>" +
25
- "<a class='btn' data-wysihtml5-command='Indent' title='Indent'><i class='icon-indent-left'></i></a>" +
26
- "<a class='btn' data-wysihtml5-command='Outdent' title='Outdent'><i class='icon-indent-right'></i></a>" +
27
- "</div>" +
28
- "</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
+
31
+ "html":
32
+ "<li>"
33
+ + "<div class='btn-group'>"
34
+ + "<a class='btn' data-wysihtml5-action='change_view' title='Edit HTML'><i class='icon-pencil'></i></a>"
35
+ + "</div>"
36
+ + "</li>"
29
37
  };
30
38
 
31
39
  var defaultOptions = {
32
40
  "font-styles": true,
33
41
  "emphasis": true,
34
- "lists": true
35
- };
36
-
37
- var parserRules = {
38
- tags: {
39
- b: {},
40
- i: {},
41
- br: {},
42
- ol: {},
43
- ul: {},
44
- li: {},
45
- h1: {},
46
- h2: {},
47
- a: {
48
- set_attributes: {
49
- target: "_blank",
50
- rel: "nofollow"
51
- },
52
- check_attributes: {
53
- href: "url" // important to avoid XSS
42
+ "lists": true,
43
+ "html": false,
44
+ events: {},
45
+ parserRules: {
46
+ tags: {
47
+ "b": {},
48
+ "i": {},
49
+ "br": {},
50
+ "ol": {},
51
+ "ul": {},
52
+ "li": {},
53
+ "h1": {},
54
+ "h2": {},
55
+ "u": 1,
56
+ "a": {
57
+ set_attributes: {
58
+ target: "_blank",
59
+ rel: "nofollow"
60
+ },
61
+ check_attributes: {
62
+ href: "url" // important to avoid XSS
63
+ }
54
64
  }
55
65
  }
56
66
  }
@@ -59,11 +69,8 @@
59
69
  var Wysihtml5 = function(el, options) {
60
70
  this.el = el;
61
71
  this.toolbar = this.createToolbar(el, options || defaultOptions);
62
- this.editor = new wysi.Editor(this.el.attr('id'), {
63
- toolbar: this.toolbar.attr('id'),
64
- parserRules: parserRules
65
- });
66
-
72
+ this.editor = this.createEditor(options);
73
+
67
74
  $('iframe.wysihtml5-sandbox').each(function(i, el){
68
75
  $(el.contentWindow).off('focus.wysihtml5').on({
69
76
  'focus.wysihtml5' : function(){
@@ -75,6 +82,27 @@
75
82
 
76
83
  Wysihtml5.prototype = {
77
84
  constructor: Wysihtml5,
85
+
86
+ createEditor: function(options) {
87
+ var parserRules = defaultOptions.parserRules;
88
+
89
+ if(options && options.parserRules) {
90
+ parserRules = options.parserRules;
91
+ }
92
+
93
+ var editor = new wysi.Editor(this.el.attr('id'), {
94
+ toolbar: this.toolbar.attr('id'),
95
+ parserRules: parserRules
96
+ });
97
+
98
+ if(options && options.events) {
99
+ for(var eventName in options.events) {
100
+ editor.on(eventName, options.events[eventName]);
101
+ }
102
+ }
103
+
104
+ return editor;
105
+ },
78
106
 
79
107
  createToolbar: function(el, options) {
80
108
  var toolbar = $("<ul/>", {
@@ -84,7 +112,7 @@
84
112
  });
85
113
 
86
114
  for(var key in defaultOptions) {
87
- var value;
115
+ var value = false;
88
116
 
89
117
  if(options[key] != undefined) {
90
118
  if(options[key] == true) {
@@ -96,6 +124,13 @@
96
124
 
97
125
  if(value == true) {
98
126
  toolbar.append(templates[key]);
127
+
128
+ if(key == "html") {
129
+ var changeViewSelector = "a[data-wysihtml5-action='change_view']";
130
+ toolbar.find(changeViewSelector).click(function(e) {
131
+ toolbar.find('a.btn').not(changeViewSelector).toggleClass('disabled');
132
+ });
133
+ }
99
134
  }
100
135
  }
101
136
 
@@ -25,6 +25,10 @@ ul.wysihtml5-toolbar a[data-wysihtml5-command=italic] {
25
25
  font-style: italic;
26
26
  }
27
27
 
28
+ ul.wysihtml5-toolbar a[data-wysihtml5-command=underline] {
29
+ text-decoration: underline;
30
+ }
31
+
28
32
  ul.wysihtml5-toolbar a.btn.wysihtml5-command-active {
29
33
  background-image: none;
30
34
  -webkit-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15),0 1px 2px rgba(0, 0, 0, 0.05);
@@ -33,4 +37,8 @@ ul.wysihtml5-toolbar a.btn.wysihtml5-command-active {
33
37
  background-color: #E6E6E6;
34
38
  background-color: #D9D9D9 9;
35
39
  outline: 0;
36
- }
40
+ }
41
+
42
+ ul.wysihtml5-commands-disabled .dropdown-menu {
43
+ display: none !important;
44
+ }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootstrap-wysihtml5-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
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-03-29 00:00:00.000000000 Z
12
+ date: 2012-04-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties
@@ -94,7 +94,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
94
94
  version: '0'
95
95
  segments:
96
96
  - 0
97
- hash: 1906620423527605515
97
+ hash: -1835191474214077747
98
98
  required_rubygems_version: !ruby/object:Gem::Requirement
99
99
  none: false
100
100
  requirements:
@@ -103,10 +103,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
103
  version: '0'
104
104
  segments:
105
105
  - 0
106
- hash: 1906620423527605515
106
+ hash: -1835191474214077747
107
107
  requirements: []
108
108
  rubyforge_project:
109
- rubygems_version: 1.8.19
109
+ rubygems_version: 1.8.21
110
110
  signing_key:
111
111
  specification_version: 3
112
112
  summary: A wysiwyg text editor for Twitter Bootstrap