Permalink
Browse files

Plugin now finds necessary elements by:

    1) Look for jQuery DOM elements passed on initialization
    2) Look for sub-classes with expected class names
    3) Create DOM elements with unique ids
  • Loading branch information...
1 parent d7f9cc6 commit c58ddc5ff5b8874c2de7803e5e230924b7afb7dc @arhpreston committed Apr 18, 2012
Showing with 7 additions and 10 deletions.
  1. +7 −10 markdown/jquery.markdown.js
View
17 markdown/jquery.markdown.js
@@ -43,29 +43,26 @@
if (!elem.data('markdown')) {
// 1) Find/create required elements
- var textarea = settings.textarea;
- var buttons = settings.button;
- var preview = settings.preview;
- //var textarea = elem.find( '.'+settings.textareaClass );
- //var buttons = elem.find( '.'+settings.buttonClass );
- //var preview = elem.find( '.'+settings.previewClass );
-
- if (!textarea) {
+ var textarea = settings.textarea || elem.find( '.'+settings.textareaClass );
+ var buttons = settings.button || elem.find( '.'+settings.buttonClass );
+ var preview = settings.preview || elem.find( '.'+settings.previewClass );
+
+ if (!textarea.length) {
textarea = $('<textarea/>', {
class: settings.textareaClass,
id : settings.textareaClass + idCounter++
});
elem.append(textarea);
}
- if (!buttons) {
+ if (!buttons.length) {
buttons = $('<div/>', {
class: settings.buttonClass,
id : settings.buttonClass + idCounter++
}).insertBefore(textarea);
}
- if (!preview) {
+ if (!preview.length) {
preview = $('<div/>', {
class: settings.previewClass,
id : settings.previewClass + idCounter++

0 comments on commit c58ddc5

Please sign in to comment.