jhtmlarea 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jhtmlarea/version.rb +1 -1
- data/vendor/assets/images/disk.png +0 -0
- data/vendor/assets/images/jHtmlArea.png +0 -0
- data/vendor/assets/images/jHtmlArea_Toolbar_Group_BG.png +0 -0
- data/vendor/assets/images/jHtmlArea_Toolbar_Group__Btn_Select_BG.png +0 -0
- data/vendor/assets/javascripts/jHtmlArea-0.7.5.js +404 -0
- data/vendor/assets/javascripts/jHtmlArea.ColorPickerMenu-0.7.0.js +189 -0
- data/vendor/assets/stylesheets/jHtmlArea.ColorPickerMenu.css.scss +7 -0
- data/vendor/assets/stylesheets/jHtmlArea.Editor.css.scss +6 -0
- data/vendor/assets/stylesheets/jHtmlArea.css.scss +91 -0
- metadata +11 -8
- data/.gitignore +0 -17
- data/Gemfile +0 -4
- data/LICENSE.txt +0 -22
- data/README.md +0 -29
- data/Rakefile +0 -15
- data/jhtmlarea.gemspec +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce240acff429c4b146adcf85d5b918d81ed4bf05
|
4
|
+
data.tar.gz: c623babc1788bfefd0ea7260f343254dc8ba7f0f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8dbea11c95bb98f18f1372ee47826c9b9909540ac2094c5b9b27090deb8f0c14ab06bd890c9b4a2c649fa5ab9dc247025838ad6e8d6a604845946c86a16ef340
|
7
|
+
data.tar.gz: 404a7fd8e82cc9fde5ac6a4a1e5277b863ed77e02e11cb25573c2e9d2d2cf54929b449bfb261edbd9db73c4da04f4a1931a41361fc986d6fbf447d786b3c5122
|
data/lib/jhtmlarea/version.rb
CHANGED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,404 @@
|
|
1
|
+
/*
|
2
|
+
* jHtmlArea 0.7.5 - WYSIWYG Html Editor jQuery Plugin
|
3
|
+
* Copyright (c) 2012 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 ($) {
|
9
|
+
$.fn.htmlarea = function (opts) {
|
10
|
+
if (opts && typeof (opts) === "string") {
|
11
|
+
var args = [];
|
12
|
+
for (var i = 1; i < arguments.length; i++) { args.push(arguments[i]); }
|
13
|
+
var htmlarea = jHtmlArea(this[0]);
|
14
|
+
var f = htmlarea[opts];
|
15
|
+
if (f) { return f.apply(htmlarea, args); }
|
16
|
+
}
|
17
|
+
return this.each(function () { jHtmlArea(this, opts); });
|
18
|
+
};
|
19
|
+
var jHtmlArea = window.jHtmlArea = function (elem, options) {
|
20
|
+
if (elem.jquery) {
|
21
|
+
return jHtmlArea(elem[0]);
|
22
|
+
}
|
23
|
+
if (elem.jhtmlareaObject) {
|
24
|
+
return elem.jhtmlareaObject;
|
25
|
+
} else {
|
26
|
+
return new jHtmlArea.fn.init(elem, options);
|
27
|
+
}
|
28
|
+
};
|
29
|
+
jHtmlArea.fn = jHtmlArea.prototype = {
|
30
|
+
|
31
|
+
// The current version of jHtmlArea being used
|
32
|
+
jhtmlarea: "0.7.5",
|
33
|
+
|
34
|
+
init: function (elem, options) {
|
35
|
+
if (elem.nodeName.toLowerCase() === "textarea") {
|
36
|
+
var opts = $.extend({}, jHtmlArea.defaultOptions, options);
|
37
|
+
elem.jhtmlareaObject = this;
|
38
|
+
|
39
|
+
var textarea = this.textarea = $(elem);
|
40
|
+
var container = this.container = $("<div/>").addClass("jHtmlArea").width(textarea.width()).insertAfter(textarea);
|
41
|
+
|
42
|
+
var toolbar = this.toolbar = $("<div/>").addClass("ToolBar").appendTo(container);
|
43
|
+
priv.initToolBar.call(this, opts);
|
44
|
+
|
45
|
+
var iframe = this.iframe = $("<iframe/>").height(textarea.height());
|
46
|
+
iframe.width(textarea.width() - ($.browser.msie ? 0 : 4));
|
47
|
+
var htmlarea = this.htmlarea = $("<div/>").append(iframe);
|
48
|
+
|
49
|
+
container.append(htmlarea).append(textarea.hide());
|
50
|
+
|
51
|
+
priv.initEditor.call(this, opts);
|
52
|
+
priv.attachEditorEvents.call(this);
|
53
|
+
|
54
|
+
// Fix total height to match TextArea
|
55
|
+
iframe.height(iframe.height() - toolbar.height());
|
56
|
+
toolbar.width(textarea.width() - 2);
|
57
|
+
|
58
|
+
if (opts.loaded) { opts.loaded.call(this); }
|
59
|
+
}
|
60
|
+
},
|
61
|
+
dispose: function () {
|
62
|
+
this.textarea.show().insertAfter(this.container);
|
63
|
+
this.container.remove();
|
64
|
+
this.textarea[0].jhtmlareaObject = null;
|
65
|
+
},
|
66
|
+
execCommand: function (a, b, c) {
|
67
|
+
this.iframe[0].contentWindow.focus();
|
68
|
+
this.editor.execCommand(a, b || false, c || null);
|
69
|
+
this.updateTextArea();
|
70
|
+
},
|
71
|
+
ec: function (a, b, c) {
|
72
|
+
this.execCommand(a, b, c);
|
73
|
+
},
|
74
|
+
queryCommandValue: function (a) {
|
75
|
+
this.iframe[0].contentWindow.focus();
|
76
|
+
return this.editor.queryCommandValue(a);
|
77
|
+
},
|
78
|
+
qc: function (a) {
|
79
|
+
return this.queryCommandValue(a);
|
80
|
+
},
|
81
|
+
getSelectedHTML: function () {
|
82
|
+
if ($.browser.msie) {
|
83
|
+
return this.getRange().htmlText;
|
84
|
+
} else {
|
85
|
+
var elem = this.getRange().cloneContents();
|
86
|
+
return $("<p/>").append($(elem)).html();
|
87
|
+
}
|
88
|
+
},
|
89
|
+
getSelection: function () {
|
90
|
+
if ($.browser.msie) {
|
91
|
+
//return (this.editor.parentWindow.getSelection) ? this.editor.parentWindow.getSelection() : this.editor.selection;
|
92
|
+
return this.editor.selection;
|
93
|
+
} else {
|
94
|
+
return this.iframe[0].contentDocument.defaultView.getSelection();
|
95
|
+
}
|
96
|
+
},
|
97
|
+
getRange: function () {
|
98
|
+
var s = this.getSelection();
|
99
|
+
if (!s) { return null; }
|
100
|
+
//return (s.rangeCount > 0) ? s.getRangeAt(0) : s.createRange();
|
101
|
+
return (s.getRangeAt) ? s.getRangeAt(0) : s.createRange();
|
102
|
+
},
|
103
|
+
html: function (v) {
|
104
|
+
if (v) {
|
105
|
+
this.textarea.val(v);
|
106
|
+
this.updateHtmlArea();
|
107
|
+
} else {
|
108
|
+
return this.toHtmlString();
|
109
|
+
}
|
110
|
+
},
|
111
|
+
pasteHTML: function (html) {
|
112
|
+
this.iframe[0].contentWindow.focus();
|
113
|
+
var r = this.getRange();
|
114
|
+
if ($.browser.msie) {
|
115
|
+
r.pasteHTML(html);
|
116
|
+
} else if ($.browser.mozilla) {
|
117
|
+
r.deleteContents();
|
118
|
+
r.insertNode($((html.indexOf("<") != 0) ? $("<span/>").append(html) : html)[0]);
|
119
|
+
} else { // Safari
|
120
|
+
r.deleteContents();
|
121
|
+
r.insertNode($(this.iframe[0].contentWindow.document.createElement("span")).append($((html.indexOf("<") != 0) ? "<span>" + html + "</span>" : html))[0]);
|
122
|
+
}
|
123
|
+
r.collapse(false);
|
124
|
+
r.select();
|
125
|
+
},
|
126
|
+
cut: function () {
|
127
|
+
this.ec("cut");
|
128
|
+
},
|
129
|
+
copy: function () {
|
130
|
+
this.ec("copy");
|
131
|
+
},
|
132
|
+
paste: function () {
|
133
|
+
this.ec("paste");
|
134
|
+
},
|
135
|
+
bold: function () { this.ec("bold"); },
|
136
|
+
italic: function () { this.ec("italic"); },
|
137
|
+
underline: function () { this.ec("underline"); },
|
138
|
+
strikeThrough: function () { this.ec("strikethrough"); },
|
139
|
+
image: function (url) {
|
140
|
+
if ($.browser.msie && !url) {
|
141
|
+
this.ec("insertImage", true);
|
142
|
+
} else {
|
143
|
+
this.ec("insertImage", false, (url || prompt("Image URL:", "http://")));
|
144
|
+
}
|
145
|
+
},
|
146
|
+
removeFormat: function () {
|
147
|
+
this.ec("removeFormat", false, []);
|
148
|
+
this.unlink();
|
149
|
+
},
|
150
|
+
link: function () {
|
151
|
+
if ($.browser.msie) {
|
152
|
+
this.ec("createLink", true);
|
153
|
+
} else {
|
154
|
+
this.ec("createLink", false, prompt("Link URL:", "http://"));
|
155
|
+
}
|
156
|
+
},
|
157
|
+
unlink: function () { this.ec("unlink", false, []); },
|
158
|
+
orderedList: function () { this.ec("insertorderedlist"); },
|
159
|
+
unorderedList: function () { this.ec("insertunorderedlist"); },
|
160
|
+
superscript: function () { this.ec("superscript"); },
|
161
|
+
subscript: function () { this.ec("subscript"); },
|
162
|
+
|
163
|
+
p: function () {
|
164
|
+
this.formatBlock("<p>");
|
165
|
+
},
|
166
|
+
h1: function () {
|
167
|
+
this.heading(1);
|
168
|
+
},
|
169
|
+
h2: function () {
|
170
|
+
this.heading(2);
|
171
|
+
},
|
172
|
+
h3: function () {
|
173
|
+
this.heading(3);
|
174
|
+
},
|
175
|
+
h4: function () {
|
176
|
+
this.heading(4);
|
177
|
+
},
|
178
|
+
h5: function () {
|
179
|
+
this.heading(5);
|
180
|
+
},
|
181
|
+
h6: function () {
|
182
|
+
this.heading(6);
|
183
|
+
},
|
184
|
+
heading: function (h) {
|
185
|
+
this.formatBlock($.browser.msie ? "Heading " + h : "h" + h);
|
186
|
+
},
|
187
|
+
|
188
|
+
indent: function () {
|
189
|
+
this.ec("indent");
|
190
|
+
},
|
191
|
+
outdent: function () {
|
192
|
+
this.ec("outdent");
|
193
|
+
},
|
194
|
+
|
195
|
+
insertHorizontalRule: function () {
|
196
|
+
this.ec("insertHorizontalRule", false, "ht");
|
197
|
+
},
|
198
|
+
|
199
|
+
justifyLeft: function () {
|
200
|
+
this.ec("justifyLeft");
|
201
|
+
},
|
202
|
+
justifyCenter: function () {
|
203
|
+
this.ec("justifyCenter");
|
204
|
+
},
|
205
|
+
justifyRight: function () {
|
206
|
+
this.ec("justifyRight");
|
207
|
+
},
|
208
|
+
|
209
|
+
increaseFontSize: function () {
|
210
|
+
if ($.browser.msie) {
|
211
|
+
this.ec("fontSize", false, this.qc("fontSize") + 1);
|
212
|
+
} else if ($.browser.safari) {
|
213
|
+
this.getRange().surroundContents($(this.iframe[0].contentWindow.document.createElement("span")).css("font-size", "larger")[0]);
|
214
|
+
} else {
|
215
|
+
this.ec("increaseFontSize", false, "big");
|
216
|
+
}
|
217
|
+
},
|
218
|
+
decreaseFontSize: function () {
|
219
|
+
if ($.browser.msie) {
|
220
|
+
this.ec("fontSize", false, this.qc("fontSize") - 1);
|
221
|
+
} else if ($.browser.safari) {
|
222
|
+
this.getRange().surroundContents($(this.iframe[0].contentWindow.document.createElement("span")).css("font-size", "smaller")[0]);
|
223
|
+
} else {
|
224
|
+
this.ec("decreaseFontSize", false, "small");
|
225
|
+
}
|
226
|
+
},
|
227
|
+
|
228
|
+
forecolor: function (c) {
|
229
|
+
this.ec("foreColor", false, c || prompt("Enter HTML Color:", "#"));
|
230
|
+
},
|
231
|
+
|
232
|
+
formatBlock: function (v) {
|
233
|
+
this.ec("formatblock", false, v || null);
|
234
|
+
},
|
235
|
+
|
236
|
+
showHTMLView: function () {
|
237
|
+
this.updateTextArea();
|
238
|
+
this.textarea.show();
|
239
|
+
this.htmlarea.hide();
|
240
|
+
$("ul li:not(li:has(a.html))", this.toolbar).hide();
|
241
|
+
$("ul:not(:has(:visible))", this.toolbar).hide();
|
242
|
+
$("ul li a.html", this.toolbar).addClass("highlighted");
|
243
|
+
},
|
244
|
+
hideHTMLView: function () {
|
245
|
+
this.updateHtmlArea();
|
246
|
+
this.textarea.hide();
|
247
|
+
this.htmlarea.show();
|
248
|
+
$("ul", this.toolbar).show();
|
249
|
+
$("ul li", this.toolbar).show().find("a.html").removeClass("highlighted");
|
250
|
+
},
|
251
|
+
toggleHTMLView: function () {
|
252
|
+
(this.textarea.is(":hidden")) ? this.showHTMLView() : this.hideHTMLView();
|
253
|
+
},
|
254
|
+
|
255
|
+
toHtmlString: function () {
|
256
|
+
return this.editor.body.innerHTML;
|
257
|
+
},
|
258
|
+
toString: function () {
|
259
|
+
return this.editor.body.innerText;
|
260
|
+
},
|
261
|
+
|
262
|
+
updateTextArea: function () {
|
263
|
+
this.textarea.val(this.toHtmlString());
|
264
|
+
},
|
265
|
+
updateHtmlArea: function () {
|
266
|
+
this.editor.body.innerHTML = this.textarea.val();
|
267
|
+
}
|
268
|
+
};
|
269
|
+
jHtmlArea.fn.init.prototype = jHtmlArea.fn;
|
270
|
+
|
271
|
+
jHtmlArea.defaultOptions = {
|
272
|
+
toolbar: [
|
273
|
+
["html"], ["bold", "italic", "underline", "strikethrough", "|", "subscript", "superscript"],
|
274
|
+
["increasefontsize", "decreasefontsize"],
|
275
|
+
["orderedlist", "unorderedlist"],
|
276
|
+
["indent", "outdent"],
|
277
|
+
["justifyleft", "justifycenter", "justifyright"],
|
278
|
+
["link", "unlink", "image", "horizontalrule"],
|
279
|
+
["p", "h1", "h2", "h3", "h4", "h5", "h6"],
|
280
|
+
["cut", "copy", "paste"]
|
281
|
+
],
|
282
|
+
css: null,
|
283
|
+
toolbarText: {
|
284
|
+
bold: "Bold", italic: "Italic", underline: "Underline", strikethrough: "Strike-Through",
|
285
|
+
cut: "Cut", copy: "Copy", paste: "Paste",
|
286
|
+
h1: "Heading 1", h2: "Heading 2", h3: "Heading 3", h4: "Heading 4", h5: "Heading 5", h6: "Heading 6", p: "Paragraph",
|
287
|
+
indent: "Indent", outdent: "Outdent", horizontalrule: "Insert Horizontal Rule",
|
288
|
+
justifyleft: "Left Justify", justifycenter: "Center Justify", justifyright: "Right Justify",
|
289
|
+
increasefontsize: "Increase Font Size", decreasefontsize: "Decrease Font Size", forecolor: "Text Color",
|
290
|
+
link: "Insert Link", unlink: "Remove Link", image: "Insert Image",
|
291
|
+
orderedlist: "Insert Ordered List", unorderedlist: "Insert Unordered List",
|
292
|
+
subscript: "Subscript", superscript: "Superscript",
|
293
|
+
html: "Show/Hide HTML Source View"
|
294
|
+
}
|
295
|
+
};
|
296
|
+
var priv = {
|
297
|
+
toolbarButtons: {
|
298
|
+
strikethrough: "strikeThrough", orderedlist: "orderedList", unorderedlist: "unorderedList",
|
299
|
+
horizontalrule: "insertHorizontalRule",
|
300
|
+
justifyleft: "justifyLeft", justifycenter: "justifyCenter", justifyright: "justifyRight",
|
301
|
+
increasefontsize: "increaseFontSize", decreasefontsize: "decreaseFontSize",
|
302
|
+
html: function (btn) {
|
303
|
+
this.toggleHTMLView();
|
304
|
+
}
|
305
|
+
},
|
306
|
+
initEditor: function (options) {
|
307
|
+
var edit = this.editor = this.iframe[0].contentWindow.document;
|
308
|
+
edit.designMode = 'on';
|
309
|
+
edit.open();
|
310
|
+
edit.write(this.textarea.val());
|
311
|
+
edit.close();
|
312
|
+
if (options.css) {
|
313
|
+
var e = edit.createElement('link'); e.rel = 'stylesheet'; e.type = 'text/css'; e.href = options.css; edit.getElementsByTagName('head')[0].appendChild(e);
|
314
|
+
}
|
315
|
+
},
|
316
|
+
initToolBar: function (options) {
|
317
|
+
var that = this;
|
318
|
+
|
319
|
+
var menuItem = function (className, altText, action) {
|
320
|
+
return $("<li/>").append($("<a href='javascript:void(0);'/>").addClass(className).attr("title", altText).click(function () { action.call(that, $(this)); }));
|
321
|
+
};
|
322
|
+
|
323
|
+
function addButtons(arr) {
|
324
|
+
var ul = $("<ul/>").appendTo(that.toolbar);
|
325
|
+
for (var i = 0; i < arr.length; i++) {
|
326
|
+
var e = arr[i];
|
327
|
+
if ((typeof (e)).toLowerCase() === "string") {
|
328
|
+
if (e === "|") {
|
329
|
+
ul.append($('<li class="separator"/>'));
|
330
|
+
} else {
|
331
|
+
var f = (function (e) {
|
332
|
+
// If button name exists in priv.toolbarButtons then call the "method" defined there, otherwise call the method with the same name
|
333
|
+
var m = priv.toolbarButtons[e] || e;
|
334
|
+
if ((typeof (m)).toLowerCase() === "function") {
|
335
|
+
return function (btn) { m.call(this, btn); };
|
336
|
+
} else {
|
337
|
+
return function () { this[m](); this.editor.body.focus(); };
|
338
|
+
}
|
339
|
+
})(e.toLowerCase());
|
340
|
+
var t = options.toolbarText[e.toLowerCase()];
|
341
|
+
ul.append(menuItem(e.toLowerCase(), t || e, f));
|
342
|
+
}
|
343
|
+
} else {
|
344
|
+
ul.append(menuItem(e.css, e.text, e.action));
|
345
|
+
}
|
346
|
+
}
|
347
|
+
};
|
348
|
+
if (options.toolbar.length !== 0 && priv.isArray(options.toolbar[0])) {
|
349
|
+
for (var i = 0; i < options.toolbar.length; i++) {
|
350
|
+
addButtons(options.toolbar[i]);
|
351
|
+
}
|
352
|
+
} else {
|
353
|
+
addButtons(options.toolbar);
|
354
|
+
}
|
355
|
+
},
|
356
|
+
attachEditorEvents: function () {
|
357
|
+
var t = this;
|
358
|
+
|
359
|
+
var fnHA = function () {
|
360
|
+
t.updateHtmlArea();
|
361
|
+
};
|
362
|
+
|
363
|
+
this.textarea.click(fnHA).
|
364
|
+
keyup(fnHA).
|
365
|
+
keydown(fnHA).
|
366
|
+
mousedown(fnHA).
|
367
|
+
blur(fnHA);
|
368
|
+
|
369
|
+
|
370
|
+
|
371
|
+
var fnTA = function () {
|
372
|
+
t.updateTextArea();
|
373
|
+
};
|
374
|
+
|
375
|
+
$(this.editor.body).click(fnTA).
|
376
|
+
keyup(fnTA).
|
377
|
+
keydown(fnTA).
|
378
|
+
mousedown(fnTA).
|
379
|
+
blur(fnTA);
|
380
|
+
|
381
|
+
$('form').submit(function () { t.toggleHTMLView(); t.toggleHTMLView(); });
|
382
|
+
//$(this.textarea[0].form).submit(function() { //this.textarea.closest("form").submit(function() {
|
383
|
+
|
384
|
+
|
385
|
+
// Fix for ASP.NET Postback Model
|
386
|
+
if (window.__doPostBack) {
|
387
|
+
var old__doPostBack = __doPostBack;
|
388
|
+
window.__doPostBack = function () {
|
389
|
+
if (t) {
|
390
|
+
if (t.toggleHTMLView) {
|
391
|
+
t.toggleHTMLView();
|
392
|
+
t.toggleHTMLView();
|
393
|
+
}
|
394
|
+
}
|
395
|
+
return old__doPostBack.apply(window, arguments);
|
396
|
+
};
|
397
|
+
}
|
398
|
+
|
399
|
+
},
|
400
|
+
isArray: function (v) {
|
401
|
+
return v && typeof v === 'object' && typeof v.length === 'number' && typeof v.splice === 'function' && !(v.propertyIsEnumerable('length'));
|
402
|
+
}
|
403
|
+
};
|
404
|
+
})(jQuery);
|
@@ -0,0 +1,189 @@
|
|
1
|
+
/*
|
2
|
+
* jHtmlAreaColorPickerMenu 0.7.0 - A Color Picker Extension to jHtmlArea
|
3
|
+
* Part of the jHtmlArea Project
|
4
|
+
* Copyright (c) 2009 Chris Pietschmann
|
5
|
+
* http://jhtmlarea.codeplex.com
|
6
|
+
* Licensed under the Microsoft Reciprocal License (Ms-RL)
|
7
|
+
* http://jhtmlarea.codeplex.com/license
|
8
|
+
*/
|
9
|
+
(function($) {
|
10
|
+
if (jHtmlArea) {
|
11
|
+
var oldForecolor = jHtmlArea.fn.forecolor;
|
12
|
+
jHtmlArea.fn.forecolor = function(c) {
|
13
|
+
if (c) {
|
14
|
+
// If color is specified, then use the "default" method functionality
|
15
|
+
oldForecolor.call(this, c);
|
16
|
+
} else {
|
17
|
+
// If no color is specified, then display color picker ui
|
18
|
+
var that = this;
|
19
|
+
var rng = this.getRange();
|
20
|
+
jHtmlAreaColorPickerMenu($(".forecolor", this.toolbar), {
|
21
|
+
colorChosen: function(color) {
|
22
|
+
if ($.browser.msie) {
|
23
|
+
rng.execCommand("ForeColor", false, color);
|
24
|
+
} else {
|
25
|
+
that.forecolor(color);
|
26
|
+
}
|
27
|
+
}
|
28
|
+
});
|
29
|
+
}
|
30
|
+
};
|
31
|
+
}
|
32
|
+
var menu = window.jHtmlAreaColorPickerMenu = function(ownerElement, options) {
|
33
|
+
return new jHtmlAreaColorPickerMenu.fn.init(ownerElement, options);
|
34
|
+
};
|
35
|
+
menu.fn = menu.prototype = {
|
36
|
+
jhtmlareacolorpickermenu: "0.7.0",
|
37
|
+
|
38
|
+
init: function(ownerElement, options) {
|
39
|
+
var opts = $.extend({}, menu.defaultOptions, options);
|
40
|
+
var that = this;
|
41
|
+
var owner = this.owner = $(ownerElement);
|
42
|
+
var position = owner.position();
|
43
|
+
|
44
|
+
if (menu.instance) {
|
45
|
+
menu.instance.hide();
|
46
|
+
}
|
47
|
+
jHtmlAreaColorPickerMenu.instance = this;
|
48
|
+
|
49
|
+
var picker = this.picker = $("<div/>").css({
|
50
|
+
position: "absolute",
|
51
|
+
left: position.left + opts.offsetLeft,
|
52
|
+
top: position.top + owner.height() + opts.offsetTop,
|
53
|
+
"z-index": opts["z-index"]
|
54
|
+
}).addClass("jHtmlAreaColorPickerMenu");
|
55
|
+
|
56
|
+
for (var i = 0; i < opts.colors.length; i++) {
|
57
|
+
var c = opts.colors[i];
|
58
|
+
$("<div/>").css("background-color", c).appendTo(picker).click(
|
59
|
+
(function(color) {
|
60
|
+
return function() {
|
61
|
+
if (opts.colorChosen) {
|
62
|
+
opts.colorChosen.call(this, color);
|
63
|
+
}
|
64
|
+
that.hide();
|
65
|
+
};
|
66
|
+
})(c)
|
67
|
+
);
|
68
|
+
}
|
69
|
+
|
70
|
+
$("<div/>").html("<div></div>Automatic").addClass("automatic").appendTo(picker).click(
|
71
|
+
function() {
|
72
|
+
if (opts.colorChosen) {
|
73
|
+
opts.colorChosen.call(this, null);
|
74
|
+
}
|
75
|
+
that.hide();
|
76
|
+
}
|
77
|
+
);
|
78
|
+
|
79
|
+
|
80
|
+
var autoHide = false;
|
81
|
+
picker.appendTo(owner.parent()).
|
82
|
+
show().
|
83
|
+
mouseout(function() {
|
84
|
+
autoHide = true;
|
85
|
+
that.currentTimeout = window.setTimeout(function() { if (autoHide === true) { that.hide(); } }, 1000);
|
86
|
+
}).
|
87
|
+
mouseover(function() {
|
88
|
+
if (that.currentTimeout) {
|
89
|
+
window.clearTimeout(that.currentTimeout);
|
90
|
+
that.currentTimeout = null;
|
91
|
+
}
|
92
|
+
autoHide = false;
|
93
|
+
});
|
94
|
+
},
|
95
|
+
hide: function() {
|
96
|
+
this.picker.hide();
|
97
|
+
this.picker.remove();
|
98
|
+
}
|
99
|
+
};
|
100
|
+
menu.fn.init.prototype = menu.fn;
|
101
|
+
|
102
|
+
menu.defaultOptions = {
|
103
|
+
"z-index": 0,
|
104
|
+
offsetTop: 0,
|
105
|
+
offsetLeft: 0,
|
106
|
+
colors: [
|
107
|
+
"#ffffff",
|
108
|
+
"#cccccc",
|
109
|
+
"#c0c0c0",
|
110
|
+
"#999999",
|
111
|
+
"#666666",
|
112
|
+
"#333333",
|
113
|
+
"#000000",
|
114
|
+
|
115
|
+
"#ffcccc",
|
116
|
+
"#ff6666",
|
117
|
+
"#ff0000",
|
118
|
+
"#cc0000",
|
119
|
+
"#990000",
|
120
|
+
"#660000",
|
121
|
+
"#330000",
|
122
|
+
|
123
|
+
"#ffcc99",
|
124
|
+
"#ff9966",
|
125
|
+
"#ff9900",
|
126
|
+
"#ff6600",
|
127
|
+
"#cc6600",
|
128
|
+
"#993300",
|
129
|
+
"#663300",
|
130
|
+
|
131
|
+
"#ffff99",
|
132
|
+
"#ffff66",
|
133
|
+
"#ffcc66",
|
134
|
+
"#ffcc33",
|
135
|
+
"#cc9933",
|
136
|
+
"#996633",
|
137
|
+
"#663333",
|
138
|
+
|
139
|
+
"#ffffcc",
|
140
|
+
"#ffff33",
|
141
|
+
"#ffff00",
|
142
|
+
"#ffcc00",
|
143
|
+
"#999900",
|
144
|
+
"#666600",
|
145
|
+
"#333300",
|
146
|
+
|
147
|
+
"#99ff99",
|
148
|
+
"#66ff99",
|
149
|
+
"#33ff33",
|
150
|
+
"#33cc00",
|
151
|
+
"#009900",
|
152
|
+
"#006600",
|
153
|
+
"#003300",
|
154
|
+
|
155
|
+
"#99FFFF",
|
156
|
+
"#33FFFF",
|
157
|
+
"#66CCCC",
|
158
|
+
"#00CCCC",
|
159
|
+
"#339999",
|
160
|
+
"#336666",
|
161
|
+
"#003333",
|
162
|
+
|
163
|
+
"#CCFFFF",
|
164
|
+
"#66FFFF",
|
165
|
+
"#33CCFF",
|
166
|
+
"#3366FF",
|
167
|
+
"#3333FF",
|
168
|
+
"#000099",
|
169
|
+
"#000066",
|
170
|
+
|
171
|
+
"#CCCCFF",
|
172
|
+
"#9999FF",
|
173
|
+
"#6666CC",
|
174
|
+
"#6633FF",
|
175
|
+
"#6600CC",
|
176
|
+
"#333399",
|
177
|
+
"#330099",
|
178
|
+
|
179
|
+
"#FFCCFF",
|
180
|
+
"#FF99FF",
|
181
|
+
"#CC66CC",
|
182
|
+
"#CC33CC",
|
183
|
+
"#993399",
|
184
|
+
"#663366",
|
185
|
+
"#330033"
|
186
|
+
],
|
187
|
+
colorChosen: null
|
188
|
+
};
|
189
|
+
})(jQuery);
|
@@ -0,0 +1,7 @@
|
|
1
|
+
div.jHtmlAreaColorPickerMenu {
|
2
|
+
border: solid 1px #bbb; background-color: #ddd; width: 112px;
|
3
|
+
div {float: left; margin: 2px; width: 12px; height: 14px;}
|
4
|
+
div:hover {margin: 0px; border: dotted 2px black;}
|
5
|
+
div.automatic { width: 104px; height: auto; padding: 2px;}
|
6
|
+
div.automatic div { margin: 2px; width: 12px; height: 14px; border: solid 1px black;}
|
7
|
+
}
|
@@ -0,0 +1,91 @@
|
|
1
|
+
div.jHtmlArea {
|
2
|
+
display: inline block;
|
3
|
+
div { padding: 0px; margin: 0px; }
|
4
|
+
.ToolBar {
|
5
|
+
ul {
|
6
|
+
border: solid 1px #ccc;
|
7
|
+
margin: 1px;
|
8
|
+
padding: 1px;
|
9
|
+
float: left;
|
10
|
+
background: #fff image-url('jhtmlarea/jHtmlArea_Toolbar_Group_BG.png') repeat-x;
|
11
|
+
li {
|
12
|
+
list-style-type: none;
|
13
|
+
float: left;
|
14
|
+
border: none; padding: 1px; margin: 1px;
|
15
|
+
}
|
16
|
+
li:hover {
|
17
|
+
border: solid 1px #ccc;
|
18
|
+
background: #ddd image-url('jhtmlarea/jHtmlArea_Toolbar_Group__Btn_Select_BG.png');
|
19
|
+
padding: 0;
|
20
|
+
}
|
21
|
+
li a {
|
22
|
+
display: block;
|
23
|
+
width: 16px;
|
24
|
+
height: 16px;
|
25
|
+
background: image-url('jhtmlarea/jHtmlArea.png') no-repeat -16px -500px;
|
26
|
+
border: none;
|
27
|
+
cursor: pointer;
|
28
|
+
padding: 0px;
|
29
|
+
}
|
30
|
+
li a.highlighted {
|
31
|
+
border: solid 1px #aaa;
|
32
|
+
background-color: #bbb;
|
33
|
+
padding: 0;
|
34
|
+
}
|
35
|
+
li.separator {
|
36
|
+
height: 16px;
|
37
|
+
margin: 0 2px 0 3px;
|
38
|
+
border-left: 1px solid #ccc;
|
39
|
+
}
|
40
|
+
li.separator:hover {
|
41
|
+
padding: 1px;
|
42
|
+
background-color: #fff;
|
43
|
+
border-top:none; border-bottom:none; border-right:none;
|
44
|
+
}
|
45
|
+
|
46
|
+
li a:hover { }
|
47
|
+
li a.bold { background-position: 0 0; }
|
48
|
+
li a.italic { background-position: -16px 0; }
|
49
|
+
li a.underline { background-position: -32px 0; }
|
50
|
+
li a.strikethrough { background-position: -48px 0; }
|
51
|
+
li a.link { background-position: -64px 0; }
|
52
|
+
li a.unlink { background-position: -80px 0; }
|
53
|
+
li a.orderedlist { background-position: -96px 0; }
|
54
|
+
li a.unorderedlist { background-position: -112px 0; }
|
55
|
+
li a.image { background-position: -128px 0; }
|
56
|
+
li a.cut { background-position: -144px 0; }
|
57
|
+
li a.copy { background-position: -160px 0; }
|
58
|
+
li a.paste { background-position: -176px 0; }
|
59
|
+
|
60
|
+
li a.html {
|
61
|
+
background-position: -192px 0;
|
62
|
+
opacity:0.6;
|
63
|
+
filter:alpha(opacity=60);
|
64
|
+
}
|
65
|
+
li a.html.highlighted {
|
66
|
+
opacity:1.0;
|
67
|
+
filter:alpha(opacity=100);
|
68
|
+
}
|
69
|
+
|
70
|
+
li a.h1 { background-position: 0 -16px;}
|
71
|
+
li a.h2 { background-position: -16px -16px;}
|
72
|
+
li a.h3 { background-position: -32px -16px;}
|
73
|
+
li a.h4 { background-position: -48px -16px;}
|
74
|
+
li a.h5 { background-position: -64px -16px;}
|
75
|
+
li a.h6 { background-position: -80px -16px;}
|
76
|
+
li a.subscript { background-position: -96px -16px;}
|
77
|
+
li a.superscript { background-position: -112px -16px;}
|
78
|
+
li a.indent { background-position: -128px -16px;}
|
79
|
+
li a.outdent { background-position: -144px -16px;}
|
80
|
+
li a.horizontalrule { background-position: -160px -16px;}
|
81
|
+
li a.p { background-position: -176px -16px;}
|
82
|
+
|
83
|
+
li a.justifyleft { background-position: 0 -32px;}
|
84
|
+
li a.justifycenter { background-position: -16px -32px;}
|
85
|
+
li a.justifyright { background-position: -32px -32px;}
|
86
|
+
li a.increasefontsize { background-position: -48px -32px;}
|
87
|
+
li a.decreasefontsize { background-position: -64px -32px;}
|
88
|
+
li a.forecolor { background-position: -80px -32px;}
|
89
|
+
}
|
90
|
+
}
|
91
|
+
}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dow Drake
|
@@ -59,14 +59,17 @@ executables: []
|
|
59
59
|
extensions: []
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
|
-
- .gitignore
|
63
|
-
- Gemfile
|
64
|
-
- LICENSE.txt
|
65
|
-
- README.md
|
66
|
-
- Rakefile
|
67
|
-
- jhtmlarea.gemspec
|
68
|
-
- lib/jhtmlarea.rb
|
69
62
|
- lib/jhtmlarea/version.rb
|
63
|
+
- lib/jhtmlarea.rb
|
64
|
+
- vendor/assets/images/jHtmlArea_Toolbar_Group_BG.png
|
65
|
+
- vendor/assets/images/disk.png
|
66
|
+
- vendor/assets/images/jHtmlArea_Toolbar_Group__Btn_Select_BG.png
|
67
|
+
- vendor/assets/images/jHtmlArea.png
|
68
|
+
- vendor/assets/javascripts/jHtmlArea.ColorPickerMenu-0.7.0.js
|
69
|
+
- vendor/assets/javascripts/jHtmlArea-0.7.5.js
|
70
|
+
- vendor/assets/stylesheets/jHtmlArea.css.scss
|
71
|
+
- vendor/assets/stylesheets/jHtmlArea.Editor.css.scss
|
72
|
+
- vendor/assets/stylesheets/jHtmlArea.ColorPickerMenu.css.scss
|
70
73
|
homepage: https://github.com/ddrake/jhtmlarea
|
71
74
|
licenses:
|
72
75
|
- MIT
|
data/.gitignore
DELETED
data/Gemfile
DELETED
data/LICENSE.txt
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
Copyright (c) 2013 dow
|
2
|
-
|
3
|
-
MIT License
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
-
a copy of this software and associated documentation files (the
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
11
|
-
the following conditions:
|
12
|
-
|
13
|
-
The above copyright notice and this permission notice shall be
|
14
|
-
included in all copies or substantial portions of the Software.
|
15
|
-
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
# Jhtmlarea
|
2
|
-
|
3
|
-
A wrapper for jHtmlArea, a textarea wysiwyg editor
|
4
|
-
|
5
|
-
## Installation
|
6
|
-
|
7
|
-
Add this line to your application's Gemfile:
|
8
|
-
|
9
|
-
gem 'jhtmlarea'
|
10
|
-
|
11
|
-
And then execute:
|
12
|
-
|
13
|
-
$ bundle
|
14
|
-
|
15
|
-
Or install it yourself as:
|
16
|
-
|
17
|
-
$ gem install jhtmlarea
|
18
|
-
|
19
|
-
## Usage
|
20
|
-
|
21
|
-
TODO: Write usage instructions here
|
22
|
-
|
23
|
-
## Contributing
|
24
|
-
|
25
|
-
1. Fork it
|
26
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
-
5. Create new Pull Request
|
data/Rakefile
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
require "bundler/gem_tasks"
|
2
|
-
|
3
|
-
# borrowed from jquery-datatables-rails
|
4
|
-
desc "Fixes css image paths in scss files."
|
5
|
-
task :fix_css do
|
6
|
-
Dir.glob(File.join("vendor/assets/stylesheets/dataTables", "*.css.scss")).each do |filename|
|
7
|
-
content = File.read(filename)
|
8
|
-
content.gsub!(/url\('\.\.\/images\/([A-Za-z0-9_]*\.png)'\)/) do
|
9
|
-
"image-url('dataTables/#{$1}')"
|
10
|
-
end
|
11
|
-
File.open(filename, 'w') { |f| f << content }
|
12
|
-
end
|
13
|
-
print "Done.\n"
|
14
|
-
end
|
15
|
-
|
data/jhtmlarea.gemspec
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'jhtmlarea/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = "jhtmlarea"
|
8
|
-
spec.version = Jhtmlarea::VERSION
|
9
|
-
spec.authors = ["Dow Drake"]
|
10
|
-
spec.email = ["dowdrake@msn.com"]
|
11
|
-
spec.description = %q{ A wrapper for jHtmlArea, a TextArea Wysiwyg editor }
|
12
|
-
spec.summary = %q{ The object is to simplify the installation of jHtmlArea Wysiwyg in a Rails application. }
|
13
|
-
spec.homepage = "https://github.com/ddrake/jhtmlarea"
|
14
|
-
spec.license = "MIT"
|
15
|
-
|
16
|
-
spec.files = `git ls-files`.split($/)
|
17
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = ["lib"]
|
20
|
-
|
21
|
-
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
-
spec.add_development_dependency "rake"
|
23
|
-
|
24
|
-
spec.add_dependency "jquery-rails"
|
25
|
-
end
|