Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #5 from raderj89/master

Updated jQuery, specified version of RDiscount
  • Loading branch information...
commit 56819288bb02ffe504dd45e870da329e25404d48 2 parents d88ed15 + a97cb22
@jeffmcfadden authored
View
6 README.md
@@ -5,8 +5,10 @@ This gem gives you instant markdown preview for any textarea you want, anywhere
## Installation
1. Add to your Gemfile:
-
- `gem 'markdown_preview'`
+ ```ruby
+ gem 'markdown_preview', :git => 'git@github.com:raderj89/markdown_preview.git'
+ gem 'rdiscount', '1.6.8' # Markdown Preview will fail with newer versions of RDiscount
+ ```
2. Run the Rake task:
View
1  lib/markdown_preview/assets/markdown_preview/markdown_preview.css
@@ -11,7 +11,6 @@
.markdown_wrap_menu{
height: 1.5em;
- background-color: #CCC;
margin: 0px;
padding: 2px;
}
View
180 lib/markdown_preview/assets/markdown_preview/markdown_preview.js
@@ -1,106 +1,88 @@
- (function( $ ){
-
- $.fn.markdownPreview = function( type ) {
-
- return this.each(function() {
-
- var $this = $(this);
-
- $this.wrap( '<div class="markdown_wrap editing"></div>' );
-
- $this.before( '<div class="markdown_wrap_menu"><div class="markdown_wrap_menu_help">Help</div><div class="markdown_wrap_menu_edit">Write</div><div class="markdown_wrap_menu_preview">Preview</div></div>' );
-
- var help_text = [
-'<div class="content cheatsheet">',
- '<h2>Markdown Cheat Sheet</h2>',
- '<div class="cheatsheet-content">',
- '<div class="mod">',
- '<div class="col">',
- '<h3>Format Text</h3>',
- '<p>Headers</p>',
- '<pre># This is an &lt;h1&gt; tag',
-'## This is an &lt;h2&gt; tag',
-'###### This is an &lt;h6&gt; tag</pre>',
-' <p>Text styles</p>',
-' <pre>*This text will be italic*',
-'_This will also be italic_',
-'**This text will be bold**',
-'__This will also be bold__',
-'',
-'*You **can** combine them*',
-'</pre>',
- '</div>',
- '<div class="col">',
- '<h3>Lists</h3>',
- '<p>Unordered</p>',
- '<pre>* Item 1',
-'* Item 2',
-' * Item 2a',
-' * Item 2b</pre>',
-' <p>Ordered</p>',
-' <pre>1. Item 1',
-'2. Item 2',
-'3. Item 3',
-' * Item 3a',
-' * Item 3b</pre>',
- '</div>',
- '<div class="col">',
- '<h3>Miscellaneous</h3>',
- '<p>Images</p>',
- '<pre>![GitHub Logo](/images/logo.png)',
-'Format: ![Alt Text](url)',
-'</pre>',
- '<p>Links</p>',
- '<pre>http://github.com - automatic!',
-'[GitHub](http://github.com)</pre>',
-'<p>Blockquotes</p>',
- '<pre>As Kanye West said:',
-'&gt; We\'re living the future so',
-'&gt; the present is our past.',
-'</pre>',
- '</div>',
- '</div>',
- '<div class="rule"></div>',
- '</div>',
- '</div>' ].join( "\n" );
-
-
- $this.before( '<div class="markdown_wrap_help">' + help_text + '</div>' );
-
- $this.wrap( '<div class="markdown_wrap_content"></div>' );
- $this.after( '<div class="markdown_wrap_preview"></div>' );
-
- $this.wrap( '<div class="markdown_wrap_editor"></div>' );
-
- /*
- if ( !type || type == 'width' ) {
- $this.width( $this.width() );
- }
-
- if ( !type || type == 'height' ) {
- $this.height( $this.height() );
- }*/
-
- });
-
- };
-
- $( '.markdown_wrap_menu_help' ).live( 'click', function(){
- //console.log( 'Clicked Help' );
+(function( $ ){
+ $.fn.markdownPreview = function() {
+ return this.each(function() {
+
+ var $this = $(this);
+
+ $this.wrap( '<div class="markdown_wrap editing"></div>' );
+
+ $this.before( '<div class="markdown_wrap_menu"><div class="markdown_wrap_menu_help">Help</div><div class="markdown_wrap_menu_edit">Write</div><div class="markdown_wrap_menu_preview">Preview</div></div>' );
+
+ var help_text = [
+ '<div class="content cheatsheet">',
+ '<h2>Markdown Cheat Sheet</h2>',
+ '<div class="cheatsheet-content">',
+ '<div class="mod">',
+ '<div class="col">',
+ '<h3>Format Text</h3>',
+ '<p>Headers</p>',
+ '<pre># This is an &lt;h1&gt; tag',
+ '## This is an &lt;h2&gt; tag',
+ '###### This is an &lt;h6&gt; tag</pre>',
+ ' <p>Text styles</p>',
+ ' <pre>*This text will be italic*',
+ '_This will also be italic_',
+ '**This text will be bold**',
+ '__This will also be bold__',
+ '',
+ '*You **can** combine them*',
+ '</pre>',
+ '</div>',
+ '<div class="col">',
+ '<h3>Lists</h3>',
+ '<p>Unordered</p>',
+ '<pre>* Item 1',
+ '* Item 2',
+ ' * Item 2a',
+ ' * Item 2b</pre>',
+ ' <p>Ordered</p>',
+ ' <pre>1. Item 1',
+ '2. Item 2',
+ '3. Item 3',
+ ' * Item 3a',
+ ' * Item 3b</pre>',
+ '</div>',
+ '<div class="col">',
+ '<h3>Miscellaneous</h3>',
+ '<p>Images</p>',
+ '<pre>![GitHub Logo](/images/logo.png)',
+ 'Format: ![Alt Text](url)',
+ '</pre>',
+ '<p>Links</p>',
+ '<pre>http://github.com - automatic!',
+ '[GitHub](http://github.com)</pre>',
+ '<p>Blockquotes</p>',
+ '<pre>As Kanye West said:',
+ '&gt; We\'re living the future so',
+ '&gt; the present is our past.',
+ '</pre>',
+ '</div>',
+ '</div>',
+ '<div class="rule"></div>',
+ '</div>',
+ '</div>' ].join( "\n" );
+
+ $this.before( '<div class="markdown_wrap_help">' + help_text + '</div>' );
+ $this.wrap( '<div class="markdown_wrap_content"></div>' );
+ $this.after( '<div class="markdown_wrap_preview"></div>' );
+ $this.wrap( '<div class="markdown_wrap_editor"></div>' );
+
+ $( '.markdown_wrap_menu_help' ).on('click', function(){
$( this ).closest( '.markdown_wrap' ).toggleClass( 'helping' );
-
+
$( this ).closest( '.markdown_wrap' ).find( '.markdown_wrap_help' ).slideToggle( 'fast' );
});
- $( '.markdown_wrap_menu_edit' ).live( 'click', function(){
+ $( '.markdown_wrap_menu_edit' ).on( 'click', function(){
//console.log( 'Clicked Edit' );
$( this ).closest( '.markdown_wrap' ).removeClass( 'previewing' ).addClass( 'editing' );
$( this ).closest( '.markdown_wrap' ).find( '.markdown_wrap_preview' ).hide();
+ $( this ).closest( '.markdown_wrap' ).find( '.markdown_wrap_help' ).hide();
$( this ).closest( '.markdown_wrap' ).find( '.markdown_wrap_editor' ).show();
});
-
- $( '.markdown_wrap_menu_preview' ).live( 'click', function(){
+
+ $( '.markdown_wrap_menu_preview' ).on( 'click', function(){
//console.log( 'Clicked Preview' );
$( this ).closest( '.markdown_wrap' ).removeClass( 'editing' ).addClass( 'previewing' );
@@ -129,12 +111,12 @@
},
dataType: 'text json'
});
-
});
- })( jQuery );
-
-
- $( document ).ready( function(){
- $( '.markdown_preview' ).markdownPreview();
});
+ };
+})( jQuery );
+
+$( document ).ready( function(){
+ $( '.markdown_preview' ).markdownPreview();
+});
Please sign in to comment.
Something went wrong with that request. Please try again.