jhtmlarea 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -5
- data/Rakefile +4 -4
- data/lib/jhtmlarea/version.rb +1 -1
- data/vendor/assets/javascripts/{jHtmlArea-0.7.5.js → jHtmlArea-0.8.0.js} +443 -455
- data/vendor/assets/javascripts/{jHtmlArea.ColorPickerMenu-0.7.0.js → jHtmlArea.ColorPickerMenu-0.8.0.js} +190 -190
- data/vendor/assets/stylesheets/jHtmlArea.ColorPickerMenu.css.scss +3 -3
- data/vendor/assets/stylesheets/jHtmlArea.css.scss +44 -87
- metadata +4 -5
- data/vendor/assets/javascripts/browserDetect.js +0 -118
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 536e0c99eec093a2cccfddf5c0d13dacfc4be81e
|
4
|
+
data.tar.gz: 417d430346ffa49a2dd1cf4f1aca797b62df079c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0a8259070d831c0163f3c4cfd037c17d67387902d9f5c9aceafc7ee47a2dd8d4d1beaedc422ed79467646a69231b3d56eb4d9ed7c1f5ab4809e21eb13239d5d
|
7
|
+
data.tar.gz: c5451dbe2efc2b1bbf01458f15f353710e007fd2d0cc8161737a38a9452875fed5373189c0ab902e7f5d27e890348c38631b70f057a4bef1b17032cdc76a3064
|
data/README.md
CHANGED
@@ -20,7 +20,6 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
Add the following to app/assets/javascripts/application.js:
|
22
22
|
|
23
|
-
//= require browserDetect
|
24
23
|
//= require jHtmlArea-0.7.5
|
25
24
|
//= require jHtmlArea.ColorPickerMenu-0.7.0
|
26
25
|
|
@@ -61,10 +60,6 @@ Then add this code to the view with your form (you can edit out any buttons you
|
|
61
60
|
</script>
|
62
61
|
~~~
|
63
62
|
|
64
|
-
## Notes
|
65
|
-
|
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.
|
67
|
-
|
68
63
|
## Contributing
|
69
64
|
|
70
65
|
1. Fork it
|
data/Rakefile
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
2
|
|
3
|
-
# borrowed from jquery-datatables-rails
|
3
|
+
# borrowed and adapted from jquery-datatables-rails
|
4
4
|
desc "Fixes css image paths in scss files."
|
5
5
|
task :fix_css do
|
6
|
-
Dir.glob(File.join("vendor/assets/stylesheets/
|
6
|
+
Dir.glob(File.join("vendor/assets/stylesheets/", "*.css.scss")).each do |filename|
|
7
7
|
content = File.read(filename)
|
8
|
-
content.gsub!(/url\(
|
9
|
-
"image-url('
|
8
|
+
content.gsub!(/url\(([A-Za-z0-9_]*\.png)\)/) do
|
9
|
+
"image-url('#{$1}')"
|
10
10
|
end
|
11
11
|
File.open(filename, 'w') { |f| f << content }
|
12
12
|
end
|
data/lib/jhtmlarea/version.rb
CHANGED
@@ -1,455 +1,443 @@
|
|
1
|
-
|
2
|
-
* jHtmlArea 0.
|
3
|
-
* Copyright (c)
|
4
|
-
* http://jhtmlarea.codeplex.com
|
5
|
-
* Licensed under the Microsoft Reciprocal License (Ms-RL)
|
6
|
-
* http://jhtmlarea.codeplex.com/license
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
}
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
if (
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
}
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
this.
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
//
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
} else {
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
},
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
this.ec("createLink",
|
191
|
-
}
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
},
|
282
|
-
|
283
|
-
|
284
|
-
this.
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
this.
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
this.
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
}
|
445
|
-
}
|
446
|
-
return old__doPostBack.apply(window, arguments);
|
447
|
-
};
|
448
|
-
}
|
449
|
-
|
450
|
-
},
|
451
|
-
isArray: function (v) {
|
452
|
-
return v && typeof v === 'object' && typeof v.length === 'number' && typeof v.splice === 'function' && !(v.propertyIsEnumerable('length'));
|
453
|
-
}
|
454
|
-
};
|
455
|
-
})(jQuery);
|
1
|
+
/*
|
2
|
+
* jHtmlArea 0.8 - WYSIWYG Html Editor jQuery Plugin
|
3
|
+
* Copyright (c) 2013 Chris Pietschmann
|
4
|
+
* http://jhtmlarea.codeplex.com
|
5
|
+
* Licensed under the Microsoft Reciprocal License (Ms-RL)
|
6
|
+
* http://jhtmlarea.codeplex.com/license
|
7
|
+
*/
|
8
|
+
(function ($, window) {
|
9
|
+
|
10
|
+
var $jhtmlarea = window.$jhtmlarea = {};
|
11
|
+
var $browser = $jhtmlarea.browser = {};
|
12
|
+
(function () {
|
13
|
+
$browser.msie = false;
|
14
|
+
$browser.mozilla = false;
|
15
|
+
$browser.safari = false;
|
16
|
+
$browser.version = 0;
|
17
|
+
|
18
|
+
if (navigator.userAgent.match(/MSIE ([0-9]+)\./)) {
|
19
|
+
$browser.msie = true;
|
20
|
+
$browser.version = parseFloat(RegExp.$1);
|
21
|
+
} else if (navigator.userAgent.match(/Trident\/([0-9]+)\./)) {
|
22
|
+
$browser.msie = true;
|
23
|
+
$browser.version = RegExp.$1;
|
24
|
+
if (navigator.userAgent.match(/rv:([0-9]+)\./)) {
|
25
|
+
$browser.version = parseFloat(RegExp.$1);
|
26
|
+
}
|
27
|
+
}
|
28
|
+
if (navigator.userAgent.match(/Mozilla\/([0-9]+)\./)) {
|
29
|
+
$browser.mozilla = true;
|
30
|
+
if ($browser.version === 0) {
|
31
|
+
$browser.version = parseFloat(RegExp.$1);
|
32
|
+
}
|
33
|
+
}
|
34
|
+
if (navigator.userAgent.match(/Safari ([0-9]+)\./)) {
|
35
|
+
$browser.safari = true;
|
36
|
+
$browser.version = RegExp.$1;
|
37
|
+
if (navigator.userAgent.match(/Version\/([0-9]+)\./)) {
|
38
|
+
if ($browser.version === 0) {
|
39
|
+
$browser.version = parseFloat(RegExp.$1);
|
40
|
+
}
|
41
|
+
}
|
42
|
+
}
|
43
|
+
})();
|
44
|
+
|
45
|
+
$.fn.htmlarea = function (opts) {
|
46
|
+
if (opts && typeof (opts) === "string") {
|
47
|
+
var args = [];
|
48
|
+
for (var i = 1; i < arguments.length; i++) { args.push(arguments[i]); }
|
49
|
+
var htmlarea = jHtmlArea(this[0]);
|
50
|
+
var f = htmlarea[opts];
|
51
|
+
if (f) { return f.apply(htmlarea, args); }
|
52
|
+
}
|
53
|
+
return this.each(function () { jHtmlArea(this, opts); });
|
54
|
+
};
|
55
|
+
var jHtmlArea = window.jHtmlArea = function (elem, options) {
|
56
|
+
if (elem.jquery) {
|
57
|
+
return jHtmlArea(elem[0]);
|
58
|
+
}
|
59
|
+
if (elem.jhtmlareaObject) {
|
60
|
+
return elem.jhtmlareaObject;
|
61
|
+
} else {
|
62
|
+
return new jHtmlArea.fn.init(elem, options);
|
63
|
+
}
|
64
|
+
};
|
65
|
+
jHtmlArea.fn = jHtmlArea.prototype = {
|
66
|
+
|
67
|
+
// The current version of jHtmlArea being used
|
68
|
+
jhtmlarea: "0.8",
|
69
|
+
|
70
|
+
init: function (elem, options) {
|
71
|
+
if (elem.nodeName.toLowerCase() === "textarea") {
|
72
|
+
var opts = $.extend({}, jHtmlArea.defaultOptions, options);
|
73
|
+
elem.jhtmlareaObject = this;
|
74
|
+
|
75
|
+
var textarea = this.textarea = $(elem);
|
76
|
+
var container = this.container = $("<div/>").addClass("jHtmlArea").width(textarea.width()).insertAfter(textarea);
|
77
|
+
|
78
|
+
var toolbar = this.toolbar = $("<div/>").addClass("ToolBar").appendTo(container);
|
79
|
+
priv.initToolBar.call(this, opts);
|
80
|
+
|
81
|
+
var iframe = this.iframe = $("<iframe/>").height(textarea.height());
|
82
|
+
iframe.width(textarea.width());
|
83
|
+
|
84
|
+
var htmlarea = this.htmlarea = $("<div/>").append(iframe);
|
85
|
+
|
86
|
+
container.append(htmlarea).append(textarea.hide());
|
87
|
+
|
88
|
+
priv.initEditor.call(this, opts);
|
89
|
+
priv.attachEditorEvents.call(this);
|
90
|
+
|
91
|
+
// Fix total height to match TextArea
|
92
|
+
iframe.height(iframe.height() - toolbar.height());
|
93
|
+
toolbar.width(textarea.width());
|
94
|
+
|
95
|
+
|
96
|
+
if (opts.loaded) { opts.loaded.call(this); }
|
97
|
+
}
|
98
|
+
},
|
99
|
+
dispose: function () {
|
100
|
+
this.textarea.show().insertAfter(this.container);
|
101
|
+
this.container.remove();
|
102
|
+
this.textarea[0].jhtmlareaObject = null;
|
103
|
+
},
|
104
|
+
execCommand: function (a, b, c) {
|
105
|
+
this.iframe[0].contentWindow.focus();
|
106
|
+
this.editor.execCommand(a, b || false, c || null);
|
107
|
+
this.updateTextArea();
|
108
|
+
},
|
109
|
+
ec: function (a, b, c) {
|
110
|
+
this.execCommand(a, b, c);
|
111
|
+
},
|
112
|
+
queryCommandValue: function (a) {
|
113
|
+
this.iframe[0].contentWindow.focus();
|
114
|
+
return this.editor.queryCommandValue(a);
|
115
|
+
},
|
116
|
+
qc: function (a) {
|
117
|
+
return this.queryCommandValue(a);
|
118
|
+
},
|
119
|
+
getSelectedHTML: function () {
|
120
|
+
if ($browser.msie) {
|
121
|
+
return this.getRange().htmlText;
|
122
|
+
} else {
|
123
|
+
var elem = this.getRange().cloneContents();
|
124
|
+
return $("<p/>").append($(elem)).html();
|
125
|
+
}
|
126
|
+
},
|
127
|
+
getSelection: function () {
|
128
|
+
if ($browser.msie === true && $browser.version < 11) {
|
129
|
+
//return (this.editor.parentWindow.getSelection) ? this.editor.parentWindow.getSelection() : this.editor.selection;
|
130
|
+
return this.editor.selection;
|
131
|
+
} else {
|
132
|
+
return this.iframe[0].contentDocument.defaultView.getSelection();
|
133
|
+
}
|
134
|
+
},
|
135
|
+
getRange: function () {
|
136
|
+
var s = this.getSelection();
|
137
|
+
if (!s) { return null; }
|
138
|
+
//return (s.rangeCount > 0) ? s.getRangeAt(0) : s.createRange();
|
139
|
+
return (s.getRangeAt) ? s.getRangeAt(0) : s.createRange();
|
140
|
+
},
|
141
|
+
html: function (v) {
|
142
|
+
if (v !== undefined) {
|
143
|
+
this.textarea.val(v);
|
144
|
+
this.updateHtmlArea();
|
145
|
+
} else {
|
146
|
+
return this.toHtmlString();
|
147
|
+
}
|
148
|
+
},
|
149
|
+
pasteHTML: function (html) {
|
150
|
+
this.iframe[0].contentWindow.focus();
|
151
|
+
var r = this.getRange();
|
152
|
+
if ($browser.msie) {
|
153
|
+
r.pasteHTML(html);
|
154
|
+
} else if ($browser.mozilla) {
|
155
|
+
r.deleteContents();
|
156
|
+
r.insertNode($((html.indexOf("<") != 0) ? $("<span/>").append(html) : html)[0]);
|
157
|
+
} else { // Safari
|
158
|
+
r.deleteContents();
|
159
|
+
r.insertNode($(this.iframe[0].contentWindow.document.createElement("span")).append($((html.indexOf("<") != 0) ? "<span>" + html + "</span>" : html))[0]);
|
160
|
+
}
|
161
|
+
r.collapse(false);
|
162
|
+
r.select();
|
163
|
+
},
|
164
|
+
cut: function () {
|
165
|
+
this.ec("cut");
|
166
|
+
},
|
167
|
+
copy: function () {
|
168
|
+
this.ec("copy");
|
169
|
+
},
|
170
|
+
paste: function () {
|
171
|
+
this.ec("paste");
|
172
|
+
},
|
173
|
+
bold: function () { this.ec("bold"); },
|
174
|
+
italic: function () { this.ec("italic"); },
|
175
|
+
underline: function () { this.ec("underline"); },
|
176
|
+
strikeThrough: function () { this.ec("strikethrough"); },
|
177
|
+
image: function (url) {
|
178
|
+
if ($browser.msie === true && !url) {
|
179
|
+
this.ec("insertImage", true);
|
180
|
+
} else {
|
181
|
+
this.ec("insertImage", false, (url || prompt("Image URL:", "http://")));
|
182
|
+
}
|
183
|
+
},
|
184
|
+
removeFormat: function () {
|
185
|
+
this.ec("removeFormat", false, []);
|
186
|
+
this.unlink();
|
187
|
+
},
|
188
|
+
link: function () {
|
189
|
+
if ($browser.msie === true) {
|
190
|
+
this.ec("createLink", true);
|
191
|
+
} else {
|
192
|
+
this.ec("createLink", false, prompt("Link URL:", "http://"));
|
193
|
+
}
|
194
|
+
},
|
195
|
+
unlink: function () { this.ec("unlink", false, []); },
|
196
|
+
orderedList: function () { this.ec("insertorderedlist"); },
|
197
|
+
unorderedList: function () { this.ec("insertunorderedlist"); },
|
198
|
+
superscript: function () { this.ec("superscript"); },
|
199
|
+
subscript: function () { this.ec("subscript"); },
|
200
|
+
|
201
|
+
p: function () {
|
202
|
+
this.formatBlock("<p>");
|
203
|
+
},
|
204
|
+
h1: function () {
|
205
|
+
this.heading(1);
|
206
|
+
},
|
207
|
+
h2: function () {
|
208
|
+
this.heading(2);
|
209
|
+
},
|
210
|
+
h3: function () {
|
211
|
+
this.heading(3);
|
212
|
+
},
|
213
|
+
h4: function () {
|
214
|
+
this.heading(4);
|
215
|
+
},
|
216
|
+
h5: function () {
|
217
|
+
this.heading(5);
|
218
|
+
},
|
219
|
+
h6: function () {
|
220
|
+
this.heading(6);
|
221
|
+
},
|
222
|
+
heading: function (h) {
|
223
|
+
this.formatBlock($browser.msie === true ? "Heading " + h : "h" + h);
|
224
|
+
},
|
225
|
+
|
226
|
+
indent: function () {
|
227
|
+
this.ec("indent");
|
228
|
+
},
|
229
|
+
outdent: function () {
|
230
|
+
this.ec("outdent");
|
231
|
+
},
|
232
|
+
|
233
|
+
insertHorizontalRule: function () {
|
234
|
+
this.ec("insertHorizontalRule", false, "ht");
|
235
|
+
},
|
236
|
+
|
237
|
+
justifyLeft: function () {
|
238
|
+
this.ec("justifyLeft");
|
239
|
+
},
|
240
|
+
justifyCenter: function () {
|
241
|
+
this.ec("justifyCenter");
|
242
|
+
},
|
243
|
+
justifyRight: function () {
|
244
|
+
this.ec("justifyRight");
|
245
|
+
},
|
246
|
+
|
247
|
+
increaseFontSize: function () {
|
248
|
+
if ($browser.msie === true) {
|
249
|
+
this.ec("fontSize", false, this.qc("fontSize") + 1);
|
250
|
+
} else if ($browser.safari) {
|
251
|
+
this.getRange().surroundContents($(this.iframe[0].contentWindow.document.createElement("span")).css("font-size", "larger")[0]);
|
252
|
+
} else {
|
253
|
+
this.ec("increaseFontSize", false, "big");
|
254
|
+
}
|
255
|
+
},
|
256
|
+
decreaseFontSize: function () {
|
257
|
+
if ($browser.msie === true) {
|
258
|
+
this.ec("fontSize", false, this.qc("fontSize") - 1);
|
259
|
+
} else if ($browser.safari) {
|
260
|
+
this.getRange().surroundContents($(this.iframe[0].contentWindow.document.createElement("span")).css("font-size", "smaller")[0]);
|
261
|
+
} else {
|
262
|
+
this.ec("decreaseFontSize", false, "small");
|
263
|
+
}
|
264
|
+
},
|
265
|
+
|
266
|
+
forecolor: function (c) {
|
267
|
+
this.ec("foreColor", false, c !== undefined ? c : prompt("Enter HTML Color:", "#"));
|
268
|
+
},
|
269
|
+
|
270
|
+
formatBlock: function (v) {
|
271
|
+
this.ec("formatblock", false, v || null);
|
272
|
+
},
|
273
|
+
|
274
|
+
showHTMLView: function () {
|
275
|
+
this.updateTextArea();
|
276
|
+
this.textarea.show();
|
277
|
+
this.htmlarea.hide();
|
278
|
+
$("ul li:not(li:has(a.html))", this.toolbar).hide();
|
279
|
+
$("ul:not(:has(:visible))", this.toolbar).hide();
|
280
|
+
$("ul li a.html", this.toolbar).addClass("highlighted");
|
281
|
+
},
|
282
|
+
hideHTMLView: function () {
|
283
|
+
this.updateHtmlArea();
|
284
|
+
this.textarea.hide();
|
285
|
+
this.htmlarea.show();
|
286
|
+
$("ul", this.toolbar).show();
|
287
|
+
$("ul li", this.toolbar).show().find("a.html").removeClass("highlighted");
|
288
|
+
},
|
289
|
+
toggleHTMLView: function () {
|
290
|
+
(this.textarea.is(":hidden")) ? this.showHTMLView() : this.hideHTMLView();
|
291
|
+
},
|
292
|
+
|
293
|
+
toHtmlString: function () {
|
294
|
+
return this.editor.body.innerHTML;
|
295
|
+
},
|
296
|
+
toString: function () {
|
297
|
+
return this.editor.body.innerText;
|
298
|
+
},
|
299
|
+
|
300
|
+
updateTextArea: function () {
|
301
|
+
this.textarea.val(this.toHtmlString());
|
302
|
+
},
|
303
|
+
updateHtmlArea: function () {
|
304
|
+
this.editor.body.innerHTML = this.textarea.val();
|
305
|
+
}
|
306
|
+
};
|
307
|
+
jHtmlArea.fn.init.prototype = jHtmlArea.fn;
|
308
|
+
|
309
|
+
jHtmlArea.defaultOptions = {
|
310
|
+
toolbar: [
|
311
|
+
["html"], ["bold", "italic", "underline", "strikethrough", "|", "subscript", "superscript"],
|
312
|
+
["increasefontsize", "decreasefontsize"],
|
313
|
+
["orderedlist", "unorderedlist"],
|
314
|
+
["indent", "outdent"],
|
315
|
+
["justifyleft", "justifycenter", "justifyright"],
|
316
|
+
["link", "unlink", "image", "horizontalrule"],
|
317
|
+
["p", "h1", "h2", "h3", "h4", "h5", "h6"],
|
318
|
+
["cut", "copy", "paste"]
|
319
|
+
],
|
320
|
+
css: null,
|
321
|
+
toolbarText: {
|
322
|
+
bold: "Bold", italic: "Italic", underline: "Underline", strikethrough: "Strike-Through",
|
323
|
+
cut: "Cut", copy: "Copy", paste: "Paste",
|
324
|
+
h1: "Heading 1", h2: "Heading 2", h3: "Heading 3", h4: "Heading 4", h5: "Heading 5", h6: "Heading 6", p: "Paragraph",
|
325
|
+
indent: "Indent", outdent: "Outdent", horizontalrule: "Insert Horizontal Rule",
|
326
|
+
justifyleft: "Left Justify", justifycenter: "Center Justify", justifyright: "Right Justify",
|
327
|
+
increasefontsize: "Increase Font Size", decreasefontsize: "Decrease Font Size", forecolor: "Text Color",
|
328
|
+
link: "Insert Link", unlink: "Remove Link", image: "Insert Image",
|
329
|
+
orderedlist: "Insert Ordered List", unorderedlist: "Insert Unordered List",
|
330
|
+
subscript: "Subscript", superscript: "Superscript",
|
331
|
+
html: "Show/Hide HTML Source View"
|
332
|
+
}
|
333
|
+
};
|
334
|
+
var priv = {
|
335
|
+
toolbarButtons: {
|
336
|
+
strikethrough: "strikeThrough", orderedlist: "orderedList", unorderedlist: "unorderedList",
|
337
|
+
horizontalrule: "insertHorizontalRule",
|
338
|
+
justifyleft: "justifyLeft", justifycenter: "justifyCenter", justifyright: "justifyRight",
|
339
|
+
increasefontsize: "increaseFontSize", decreasefontsize: "decreaseFontSize",
|
340
|
+
html: function (btn) {
|
341
|
+
this.toggleHTMLView();
|
342
|
+
}
|
343
|
+
},
|
344
|
+
initEditor: function (options) {
|
345
|
+
var edit = this.editor = this.iframe[0].contentWindow.document;
|
346
|
+
edit.designMode = 'on';
|
347
|
+
edit.open();
|
348
|
+
edit.write(this.textarea.val());
|
349
|
+
edit.close();
|
350
|
+
if (options.css) {
|
351
|
+
var e = edit.createElement('link'); e.rel = 'stylesheet'; e.type = 'text/css'; e.href = options.css; edit.getElementsByTagName('head')[0].appendChild(e);
|
352
|
+
}
|
353
|
+
},
|
354
|
+
initToolBar: function (options) {
|
355
|
+
var that = this;
|
356
|
+
|
357
|
+
var menuItem = function (className, altText, action) {
|
358
|
+
return $("<li/>").append($("<a href='javascript:void(0);'/>").addClass(className).attr("title", altText).click(function () { action.call(that, $(this)); }));
|
359
|
+
};
|
360
|
+
|
361
|
+
function addButtons(arr) {
|
362
|
+
var ul = $("<ul/>").appendTo(that.toolbar);
|
363
|
+
for (var i = 0; i < arr.length; i++) {
|
364
|
+
var e = arr[i];
|
365
|
+
if ((typeof (e)).toLowerCase() === "string") {
|
366
|
+
if (e === "|") {
|
367
|
+
ul.append($('<li class="separator"/>'));
|
368
|
+
} else {
|
369
|
+
var f = (function (e) {
|
370
|
+
// If button name exists in priv.toolbarButtons then call the "method" defined there, otherwise call the method with the same name
|
371
|
+
var m = priv.toolbarButtons[e] || e;
|
372
|
+
if ((typeof (m)).toLowerCase() === "function") {
|
373
|
+
return function (btn) { m.call(this, btn); };
|
374
|
+
} else {
|
375
|
+
return function () { this[m](); this.editor.body.focus(); };
|
376
|
+
}
|
377
|
+
})(e.toLowerCase());
|
378
|
+
var t = options.toolbarText[e.toLowerCase()];
|
379
|
+
ul.append(menuItem(e.toLowerCase(), t || e, f));
|
380
|
+
}
|
381
|
+
} else {
|
382
|
+
ul.append(menuItem(e.css, e.text, e.action));
|
383
|
+
}
|
384
|
+
}
|
385
|
+
};
|
386
|
+
if (options.toolbar.length !== 0 && priv.isArray(options.toolbar[0])) {
|
387
|
+
for (var i = 0; i < options.toolbar.length; i++) {
|
388
|
+
addButtons(options.toolbar[i]);
|
389
|
+
}
|
390
|
+
} else {
|
391
|
+
addButtons(options.toolbar);
|
392
|
+
}
|
393
|
+
},
|
394
|
+
attachEditorEvents: function () {
|
395
|
+
var t = this;
|
396
|
+
|
397
|
+
var fnHA = function () {
|
398
|
+
t.updateHtmlArea();
|
399
|
+
};
|
400
|
+
|
401
|
+
this.textarea.click(fnHA).
|
402
|
+
keyup(fnHA).
|
403
|
+
keydown(fnHA).
|
404
|
+
mousedown(fnHA).
|
405
|
+
blur(fnHA);
|
406
|
+
|
407
|
+
|
408
|
+
|
409
|
+
var fnTA = function () {
|
410
|
+
t.updateTextArea();
|
411
|
+
};
|
412
|
+
|
413
|
+
$(this.editor.body).click(fnTA).
|
414
|
+
keyup(fnTA).
|
415
|
+
keydown(fnTA).
|
416
|
+
mousedown(fnTA).
|
417
|
+
blur(fnTA);
|
418
|
+
|
419
|
+
$('form').submit(function () { t.toggleHTMLView(); t.toggleHTMLView(); });
|
420
|
+
//$(this.textarea[0].form).submit(function() { //this.textarea.closest("form").submit(function() {
|
421
|
+
|
422
|
+
|
423
|
+
// Fix for ASP.NET Postback Model
|
424
|
+
if (window.__doPostBack) {
|
425
|
+
var old__doPostBack = __doPostBack;
|
426
|
+
window.__doPostBack = function () {
|
427
|
+
if (t) {
|
428
|
+
if (t.toggleHTMLView) {
|
429
|
+
t.toggleHTMLView();
|
430
|
+
t.toggleHTMLView();
|
431
|
+
}
|
432
|
+
}
|
433
|
+
return old__doPostBack.apply(window, arguments);
|
434
|
+
};
|
435
|
+
}
|
436
|
+
|
437
|
+
},
|
438
|
+
isArray: function (v) {
|
439
|
+
return v && typeof v === 'object' && typeof v.length === 'number' && typeof v.splice === 'function' && !(v.propertyIsEnumerable('length'));
|
440
|
+
}
|
441
|
+
};
|
442
|
+
})(jQuery, window);
|
443
|
+
|