forked from derobins/wmd
-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathjquery-wmd-plugin.js
44 lines (37 loc) · 1.38 KB
/
jquery-wmd-plugin.js
1
2
3
4
5
6
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
38
39
40
41
42
43
44
/*
* jQuery wmd plugin.
*/
(function($) {
var counter = 0;
$.fn.wmd = function(_options) {
this.each(function() {
var defaults = {"preview": true};
var options = $.extend({}, _options || {}, defaults);
if (!options.button_bar) {
options.button_bar = "wmd-button-bar-" + counter;
$("<div/>")
.attr("class", "wmd-button-bar")
.attr("id", options.button_bar)
.insertBefore(this);
}
if (typeof(options.preview) == "boolean" && options.preview) {
options.preview = "wmd-preview-" + counter;
$("<div/>")
.attr("class", "wmd-preview")
.attr("id", options.preview)
.insertAfter(this);
}
if (typeof(options.output) == "boolean" && options.output) {
options.output = "wmd-output-" + counter;
$("<div/>")
.attr("class", "wmd-output")
.attr("id", options.output)
.insertAfter(this);
}
this.id = this.id || "wmd-input-" + counter;
options.input = this.id;
setup_wmd(options);
counter++;
});
};
})(jQuery);