jhtmlarea 0.0.8 → 0.0.9
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.
- checksums.yaml +4 -4
- data/README.md +3 -4
- data/lib/jhtmlarea/version.rb +1 -1
- data/vendor/assets/javascripts/browserDetect.js +118 -0
- data/vendor/assets/javascripts/jHtmlArea-0.7.5.js +50 -12
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e1279607fe08d4f1a29b6e29818f5a03adfc98f
|
4
|
+
data.tar.gz: e2e68165f32c2c997979383b72fa1bc002bf533c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67079ac2e2cfec53ca73d61006978aaa54a5d97fe3050253a7205e7e95e4872f5d4317af60ca39aa8ac72701a772a2a2ddc90fe6ab7f8ba8fa81ce3d1fe79f0f
|
7
|
+
data.tar.gz: 318d4e146276601a989a2e03c142e76badc6ca631f9082b4840c3490304edce5f3d8ee6e921e7b2f043464764234dad14bbb953aa949d100916c6326ca9f7a97
|
data/README.md
CHANGED
@@ -20,6 +20,7 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
Add the following to app/assets/javascripts/application.js:
|
22
22
|
|
23
|
+
//= require browserDetect
|
23
24
|
//= require jHtmlArea-0.7.5
|
24
25
|
//= require jHtmlArea.ColorPickerMenu-0.7.0
|
25
26
|
|
@@ -60,11 +61,9 @@ Then add this code to the view with your form (you can edit out any buttons you
|
|
60
61
|
</script>
|
61
62
|
~~~
|
62
63
|
|
63
|
-
##
|
64
|
+
## Notes
|
64
65
|
|
65
|
-
|
66
|
-
|
67
|
-
The original jHtmlArea 0.7.5 source caused errors in Rails 4 since it calls the `$.browser` function which is [no longer supported in jQuery 1.9](http://stackoverflow.com/questions/14524289/browser-is-undefined-error). [jQuery recommends](http://jquery.com/upgrade-guide/1.9/#jquery-browser-removed) using a library such as [Modernizer](http://modernizr.com/) for feature detection. In the interest of getting a working editor as quickly as possible, I edited out this feature detection code from the original jHtmlArea source code.
|
66
|
+
The original jHtmlArea 0.7.5 source caused errors in Rails 4 since it calls the `$.browser` function which is [no longer supported in jQuery 1.9](http://stackoverflow.com/questions/14524289/browser-is-undefined-error). [jQuery recommends](http://jquery.com/upgrade-guide/1.9/#jquery-browser-removed) using a library such as [Modernizer](http://modernizr.com/) for feature detection, but I have not been able to use modernizer to address the browser incompatibilities handled with $.browser() in the original javascript. These issues could be dealt with by including jquery-migrate, but instead I have included a simple browser detection script and modified the original javascript accordingly.
|
68
67
|
|
69
68
|
## Contributing
|
70
69
|
|
data/lib/jhtmlarea/version.rb
CHANGED
@@ -0,0 +1,118 @@
|
|
1
|
+
// http://www.quirksmode.org/js/detect.htmlvar
|
2
|
+
BrowserDetect = {
|
3
|
+
init: function () {
|
4
|
+
this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
|
5
|
+
this.version = this.searchVersion(navigator.userAgent)
|
6
|
+
|| this.searchVersion(navigator.appVersion)
|
7
|
+
|| "an unknown version";
|
8
|
+
this.OS = this.searchString(this.dataOS) || "an unknown OS";
|
9
|
+
},
|
10
|
+
searchString: function (data) {
|
11
|
+
for (var i=0;i<data.length;i++) {
|
12
|
+
var dataString = data[i].string;
|
13
|
+
var dataProp = data[i].prop;
|
14
|
+
this.versionSearchString = data[i].versionSearch || data[i].identity;
|
15
|
+
if (dataString) {
|
16
|
+
if (dataString.indexOf(data[i].subString) != -1)
|
17
|
+
return data[i].identity;
|
18
|
+
}
|
19
|
+
else if (dataProp)
|
20
|
+
return data[i].identity;
|
21
|
+
}
|
22
|
+
},
|
23
|
+
searchVersion: function (dataString) {
|
24
|
+
var index = dataString.indexOf(this.versionSearchString);
|
25
|
+
if (index == -1) return;
|
26
|
+
return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
|
27
|
+
},
|
28
|
+
dataBrowser: [
|
29
|
+
{
|
30
|
+
string: navigator.userAgent,
|
31
|
+
subString: "Chrome",
|
32
|
+
identity: "Chrome"
|
33
|
+
},
|
34
|
+
{ string: navigator.userAgent,
|
35
|
+
subString: "OmniWeb",
|
36
|
+
versionSearch: "OmniWeb/",
|
37
|
+
identity: "OmniWeb"
|
38
|
+
},
|
39
|
+
{
|
40
|
+
string: navigator.vendor,
|
41
|
+
subString: "Apple",
|
42
|
+
identity: "Safari",
|
43
|
+
versionSearch: "Version"
|
44
|
+
},
|
45
|
+
{
|
46
|
+
prop: window.opera,
|
47
|
+
identity: "Opera",
|
48
|
+
versionSearch: "Version"
|
49
|
+
},
|
50
|
+
{
|
51
|
+
string: navigator.vendor,
|
52
|
+
subString: "iCab",
|
53
|
+
identity: "iCab"
|
54
|
+
},
|
55
|
+
{
|
56
|
+
string: navigator.vendor,
|
57
|
+
subString: "KDE",
|
58
|
+
identity: "Konqueror"
|
59
|
+
},
|
60
|
+
{
|
61
|
+
string: navigator.userAgent,
|
62
|
+
subString: "Firefox",
|
63
|
+
identity: "Firefox"
|
64
|
+
},
|
65
|
+
{
|
66
|
+
string: navigator.vendor,
|
67
|
+
subString: "Camino",
|
68
|
+
identity: "Camino"
|
69
|
+
},
|
70
|
+
{ // for newer Netscapes (6+)
|
71
|
+
string: navigator.userAgent,
|
72
|
+
subString: "Netscape",
|
73
|
+
identity: "Netscape"
|
74
|
+
},
|
75
|
+
{
|
76
|
+
string: navigator.userAgent,
|
77
|
+
subString: "MSIE",
|
78
|
+
identity: "Explorer",
|
79
|
+
versionSearch: "MSIE"
|
80
|
+
},
|
81
|
+
{
|
82
|
+
string: navigator.userAgent,
|
83
|
+
subString: "Gecko",
|
84
|
+
identity: "Mozilla",
|
85
|
+
versionSearch: "rv"
|
86
|
+
},
|
87
|
+
{ // for older Netscapes (4-)
|
88
|
+
string: navigator.userAgent,
|
89
|
+
subString: "Mozilla",
|
90
|
+
identity: "Netscape",
|
91
|
+
versionSearch: "Mozilla"
|
92
|
+
}
|
93
|
+
],
|
94
|
+
dataOS : [
|
95
|
+
{
|
96
|
+
string: navigator.platform,
|
97
|
+
subString: "Win",
|
98
|
+
identity: "Windows"
|
99
|
+
},
|
100
|
+
{
|
101
|
+
string: navigator.platform,
|
102
|
+
subString: "Mac",
|
103
|
+
identity: "Mac"
|
104
|
+
},
|
105
|
+
{
|
106
|
+
string: navigator.userAgent,
|
107
|
+
subString: "iPhone",
|
108
|
+
identity: "iPhone/iPod"
|
109
|
+
},
|
110
|
+
{
|
111
|
+
string: navigator.platform,
|
112
|
+
subString: "Linux",
|
113
|
+
identity: "Linux"
|
114
|
+
}
|
115
|
+
]
|
116
|
+
|
117
|
+
};
|
118
|
+
BrowserDetect.init();
|
@@ -4,6 +4,8 @@
|
|
4
4
|
* http://jhtmlarea.codeplex.com
|
5
5
|
* Licensed under the Microsoft Reciprocal License (Ms-RL)
|
6
6
|
* http://jhtmlarea.codeplex.com/license
|
7
|
+
|
8
|
+
* Modified by Dow Drake to use browserDetect.js for jQuery 1.9+ compatibility
|
7
9
|
*/
|
8
10
|
(function ($) {
|
9
11
|
$.fn.htmlarea = function (opts) {
|
@@ -45,7 +47,7 @@
|
|
45
47
|
var iframe = this.iframe = $("<iframe/>").height(textarea.height());
|
46
48
|
// jQuery.browser is deprecated
|
47
49
|
//iframe.width(textarea.width() - ($.browser.msie ? 0 : 4));
|
48
|
-
iframe.width(textarea.width() - 4);
|
50
|
+
iframe.width(textarea.width() - (BrowserDetect.browser === "Explorer" ? 0 : 4));
|
49
51
|
var htmlarea = this.htmlarea = $("<div/>").append(iframe);
|
50
52
|
|
51
53
|
container.append(htmlarea).append(textarea.hide());
|
@@ -87,8 +89,12 @@
|
|
87
89
|
// var elem = this.getRange().cloneContents();
|
88
90
|
// return $("<p/>").append($(elem)).html();
|
89
91
|
// }
|
90
|
-
|
91
|
-
|
92
|
+
if (BrowserDetect.browser === "Explorer") {
|
93
|
+
return this.getRange().htmlText;
|
94
|
+
} else {
|
95
|
+
var elem = this.getRange().cloneContents();
|
96
|
+
return $("<p/>").append($(elem)).html();
|
97
|
+
}
|
92
98
|
|
93
99
|
},
|
94
100
|
getSelection: function () {
|
@@ -98,8 +104,13 @@
|
|
98
104
|
// } else {
|
99
105
|
// return this.iframe[0].contentDocument.defaultView.getSelection();
|
100
106
|
// }
|
101
|
-
|
102
|
-
|
107
|
+
if (BrowserDetect.browser === "Explorer") {
|
108
|
+
//return (this.editor.parentWindow.getSelection) ? this.editor.parentWindow.getSelection() : this.editor.selection;
|
109
|
+
return this.editor.selection;
|
110
|
+
} else {
|
111
|
+
return this.iframe[0].contentDocument.defaultView.getSelection();
|
112
|
+
}
|
113
|
+
},
|
103
114
|
getRange: function () {
|
104
115
|
var s = this.getSelection();
|
105
116
|
if (!s) { return null; }
|
@@ -126,8 +137,15 @@
|
|
126
137
|
// r.deleteContents();
|
127
138
|
// r.insertNode($(this.iframe[0].contentWindow.document.createElement("span")).append($((html.indexOf("<") != 0) ? "<span>" + html + "</span>" : html))[0]);
|
128
139
|
// }
|
129
|
-
|
130
|
-
|
140
|
+
if (BrowserDetect.browser === "Explorer") {
|
141
|
+
r.pasteHTML(html);
|
142
|
+
} else if (BrowserDetect.browser === "Firefox" || BrowserDetect.browser === "Mozilla") {
|
143
|
+
r.deleteContents();
|
144
|
+
r.insertNode($((html.indexOf("<") != 0) ? $("<span/>").append(html) : html)[0]);
|
145
|
+
} else { // Safari
|
146
|
+
r.deleteContents();
|
147
|
+
r.insertNode($(this.iframe[0].contentWindow.document.createElement("span")).append($((html.indexOf("<") != 0) ? "<span>" + html + "</span>" : html))[0]);
|
148
|
+
}
|
131
149
|
r.collapse(false);
|
132
150
|
r.select();
|
133
151
|
},
|
@@ -150,7 +168,11 @@
|
|
150
168
|
// } else {
|
151
169
|
// this.ec("insertImage", false, (url || prompt("Image URL:", "http://")));
|
152
170
|
// }
|
153
|
-
|
171
|
+
if (BrowserDetect.browser === "Explorer" && !url) {
|
172
|
+
this.ec("insertImage", true);
|
173
|
+
} else {
|
174
|
+
this.ec("insertImage", false, (url || prompt("Image URL:", "http://")));
|
175
|
+
}
|
154
176
|
},
|
155
177
|
removeFormat: function () {
|
156
178
|
this.ec("removeFormat", false, []);
|
@@ -162,7 +184,11 @@
|
|
162
184
|
// } else {
|
163
185
|
// this.ec("createLink", false, prompt("Link URL:", "http://"));
|
164
186
|
// }
|
165
|
-
|
187
|
+
if (BrowserDetect.browser === "Explorer") {
|
188
|
+
this.ec("createLink", true);
|
189
|
+
} else {
|
190
|
+
this.ec("createLink", false, prompt("Link URL:", "http://"));
|
191
|
+
}
|
166
192
|
},
|
167
193
|
unlink: function () { this.ec("unlink", false, []); },
|
168
194
|
orderedList: function () { this.ec("insertorderedlist"); },
|
@@ -193,7 +219,7 @@
|
|
193
219
|
},
|
194
220
|
heading: function (h) {
|
195
221
|
// this.formatBlock($.browser.msie ? "Heading " + h : "h" + h);
|
196
|
-
this.formatBlock("h" + h);
|
222
|
+
this.formatBlock(BrowserDetect.browser === "Explorer" ? "Heading " + h : "h" + h);
|
197
223
|
},
|
198
224
|
|
199
225
|
indent: function () {
|
@@ -225,7 +251,13 @@
|
|
225
251
|
// } else {
|
226
252
|
// this.ec("increaseFontSize", false, "big");
|
227
253
|
// }
|
228
|
-
|
254
|
+
if (BrowserDetect.browser === "Explorer") {
|
255
|
+
this.ec("fontSize", false, this.qc("fontSize") + 1);
|
256
|
+
} else if (BrowserDetect.browser === "Safari") {
|
257
|
+
this.getRange().surroundContents($(this.iframe[0].contentWindow.document.createElement("span")).css("font-size", "larger")[0]);
|
258
|
+
} else {
|
259
|
+
this.ec("increaseFontSize", false, "big");
|
260
|
+
}
|
229
261
|
},
|
230
262
|
decreaseFontSize: function () {
|
231
263
|
// if ($.browser.msie) {
|
@@ -235,7 +267,13 @@
|
|
235
267
|
// } else {
|
236
268
|
// this.ec("decreaseFontSize", false, "small");
|
237
269
|
// }
|
238
|
-
|
270
|
+
if (BrowserDetect.browser === "Explorer") {
|
271
|
+
this.ec("fontSize", false, this.qc("fontSize") - 1);
|
272
|
+
} else if (BrowserDetect.browser === "Safari") {
|
273
|
+
this.getRange().surroundContents($(this.iframe[0].contentWindow.document.createElement("span")).css("font-size", "smaller")[0]);
|
274
|
+
} else {
|
275
|
+
this.ec("decreaseFontSize", false, "small");
|
276
|
+
}
|
239
277
|
},
|
240
278
|
|
241
279
|
forecolor: function (c) {
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jhtmlarea
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dow Drake
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-08-
|
11
|
+
date: 2013-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -72,6 +72,7 @@ files:
|
|
72
72
|
- vendor/assets/images/jHtmlArea.png
|
73
73
|
- vendor/assets/images/jHtmlArea_Toolbar_Group_BG.png
|
74
74
|
- vendor/assets/images/jHtmlArea_Toolbar_Group__Btn_Select_BG.png
|
75
|
+
- vendor/assets/javascripts/browserDetect.js
|
75
76
|
- vendor/assets/javascripts/jHtmlArea-0.7.5.js
|
76
77
|
- vendor/assets/javascripts/jHtmlArea.ColorPickerMenu-0.7.0.js
|
77
78
|
- vendor/assets/stylesheets/jHtmlArea.ColorPickerMenu.css.scss
|